hn.today

When Modernization Breaks Working Code: A Study of LLMs on Legacy PHP

arxiv.org21 points14 comments
Screenshot of When Modernization Breaks Working Code: A Study of LLMs on Legacy PHP

The study tests whether large language models can safely modernize legacy PHP when given only a single file, without project context or feedback from running the code. Five models were asked to update 100 files from WordPress 4.0 for PHP 8.3 while preserving behavior. Researchers assessed the results using 630 hidden behavioral checks and 511 modernization findings detected by Rector, comparing model outputs with both unchanged files and Rector’s rule-based transformations.

The untouched code performed better than the models on behavioral preservation: 83 files passed every check before modification, while the best model left only 59 passing. Each model broke 32-51 previously working files and repaired no more than 10; Rector broke 7 and repaired 6. Only 37 modernization findings - 7 percent of the total - required changes for PHP 8.3. Even among files that needed no change, models broke 36-60 percent, compared with 8 percent for Rector. Many failures made files impossible to load, often through PHP-rejected type declarations. The model with the strongest modernization score was not more behaviorally compatible than its competitors. The findings show that modernization quality and preservation of existing behavior are distinct measures, and evaluations should compare changes against doing nothing.

Read on arxiv.org14 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in AI

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.