about
When Modernization Breaks Working Code: A Study of LLMs on Legacy PHP (arxiv.org)
17 points by tambourine_man 1 day ago | hide | past | pdf | 11 comments on HN

In plain words: Five AI chatbots each rewrote 100 WordPress PHP files to a newer language version, with hidden tests checking whether behavior stayed the same. Each broke dozens of working files while fixing at most 10, worse than leaving code alone or using a rule-based tool.

Abstract · When Modernization Breaks Working Code: A Single-File Study of LLMs on Legacy PHP

Pasting a legacy file into an LLM and asking it to "modernize this" is an easy shortcut. But is the result better than leaving the code alone? In this paper, we study this single-file setting with five LLMs, each asked to modernize 100 WordPress 4.0 PHP files to PHP 8.3 while preserving behavior, with no project context or execution feedback. We evaluate every output with 630 hidden behavioral checks and 511 Rector-detected modernization findings. We compare against two baselines: the unchanged originals and the rule-based tool Rector. Often, the answer is no. Untouched, 83 files already pass every check; the best LLM leaves only 59. Each model breaks 32-51 working files while repairing at most 10, whereas Rector breaks 7 and repairs 6. Most of this damage is unnecessary. Only 37 findings (7 percent) require a change under PHP 8.3, yet in compatible files with no required change, the LLMs break 36-60 percent (Rector: 8 percent). The model with the highest modernization score is no more compatible than its closest competitors. Most regressed checks come from files that no longer load at all, often because of type declarations PHP itself rejects. These are errors that need no project context to avoid. Evaluations of LLM-based modernization should therefore measure against a no-change baseline and report modernization and behavioral preservation separately.

Afridi Mahmud, Abid Hasan Khondaker, Sadif Ahmed, Md Nafiu Rahman, Rifat Shahriyar
arXiv:2610.40269 · cs.SE · submitted Oct 29, 2026
abstract · pdf · html · 6 pages, 5 figures, 5 tables. Preprint

add comment on HN

> We study a common intermediate setting: a developer pastes one complete file into a chat assistant [5], which sees the file’s internal structure but not its callers or dependencies. We evaluate the first answer, not an agent’s result after iterating on errors.

Very unsurprising results given this methodology. The agentic approach where models are allowed to iterate on changes is a very big part of what has made LLM coding tools actually useful.

> We study a common intermediate setting: a developer pastes one complete file into a chat assistant [5], which sees the file’s internal structure but not its callers or dependencies.

Ack! Do people actually try to develop software this way?

I do it from time to time when I’ve run out of tokens at the end of the month. But even then I’ve created a script to pack multiple code files and their dependencies into a single txt, with a tree overview.

And of course you never change the test suite in the process… That would be bad developer practice, LLM or not.

Gemini 3.1 Pro can easily work with this effectively, if not a bit slower than an agent.

> But even then I’ve created a script to pack multiple code files and their dependencies into a single txt, with a tree overview.

Like:

    $ cat $(find project/ -name '*.py' -type f)

?
Not any more, but it was common before Claude Code came along (~18 months ago). Based on the model versions used it may have still been the most common thing when the paper was started.
When I need modification to a small independent Python script (<1000 loc), sure.

Not for anything serious though.

It's pretty much the standard way to develop in OOP.

You are not supposed to hold all of the code in context, but to have a single object and reason about with what it see.s

The average age of the explored models is ~1.5 years. They discuss PHP 8.3, which was released in 2023 and has not been actively supported since 2025. Agentic coding isn't used.

I'm not sure what the point is of publishing results on the mid-2025 state of the art in October 2026.

Models:

- Claude Sonnet

- Gemini 2.5 Flash

- Gemini 2.5 Pro

- GPT-5 Codex

- Llama 3.3 70B

It's inconvenient how quickly things are improving, makes potentially-interesting results like this dubiously relevant

One year ago I was very skeptical about such attempts. Today, it would be my first choice as LLMs evolved a lot and the result of carefully using a LLM for this task can be very, very good.
When code output becomes cheap, you write 15 million lines of code per weekend, and of course everything gets deprecated pretty fast version 1? that was like 4 geological ages ago (1 month) that's legacy.