PHP 8.2 stops getting security fixes on 31 December 2026. After that date, a vulnerability found in 8.2 stays in 8.2. If your application still runs on it, the upgrade is no longer something to pencil in for a quiet quarter.
I have just been through this upgrade for a client: a SaaS product with a PHP codebase that dates from 2010. I have worked on it since January 2026, and it stayed in production throughout. Production switched from 8.2 to 8.5 in November 2026.
The short version: the change to the language was the easy part. The work was in the dependencies and the test suite, and then in using the new features where they pay for themselves.
Why 8.5 and not 8.3
The cautious way out of 8.2 is one minor version at a time. I would not take it now. PHP 8.3's own security support ends on 31 December 2027, so landing there buys one year, and then you do all of this again.
I took the platform straight from 8.2 to 8.5, skipping 8.3 and 8.4, in every
environment. Skipping 8.4 matters more than it sounds, because 8.4 is the
release that added property hooks, asymmetric visibility and native lazy
objects. An 8.2 codebase that moves to 8.5 gets those and 8.5's own additions
in a single move, and pays for one migration instead of three. PHP 8.5 was
released in November 2025, so it is not a leap into the unknown either, and it
brings smaller conveniences too, such as array_first() and array_last().
Dependencies decide when you can move
Upgrading PHP is mostly a Composer problem. Every package in your lock file has to allow the new version, and the ones that do not will hold you back long before your own code is in question.
Start with what you can delete. On this codebase, unused SDKs were blocking the upgrade, so I removed them. The quickest way to upgrade a dependency nobody calls is to remove it, so for each package that stands in the way, check whether anything still uses it before you spend time on its upgrade path.
While you are in the lock file, run composer audit and fix what it reports.
An upgrade already touches most of your dependencies, which makes it the
cheapest moment to deal with known advisories as well.
The test suite is the real upgrade
A language upgrade is only as safe as the tests that run on it. On the client's application, PHP test coverage has gone from zero to above 90%. I would not attempt a jump of three minor versions in one go without a suite like that.
The test framework has to move as well. On that project I took PHPUnit from 9.6 to 11.5, two major versions, which is a migration of its own inside the PHP one. Plan it as its own piece of work rather than something that happens along the way.
During the transition, CI ran the suite on both 8.2 and 8.5. That is the part I would insist on for anyone doing this. It keeps the code deployable on the old version while you work towards the new one, and every pull request tells you whether it broke either.
Then deprecations. Clear every one of them in the suite, then make any deprecation fail the test run. That is the order I followed there. Until the second step, deprecations are warnings that scroll past in CI output, and nothing stops new ones arriving while you fix the old ones. Once a deprecation fails the build, the number stays at zero.
Let Rector do the mechanical part
Rector rewrites code by rule. I adopted it on this codebase and applied its PHP
8.2-to-8.5 rule sets across src/ and tests/, in batches small enough to
review.
The batch size is the important part. A rule set run across a whole codebase in one go produces a diff nobody can read, and a diff nobody reads is a diff nobody checked. Run one set over one area, review it like any other change, merge it, and go again. With CI running on both versions, each batch is tested on both before it lands.
What Rector will not do for you
Rector gets your code running on the new version. It does not redesign anything, and the features most worth having need a person to decide where they belong. On the platform I added the following by hand.
Property hooks and asymmetric visibility
These two came in PHP 8.4, and between them they replace most getter and setter pairs. There I used them to replace the getters and setters on every Doctrine entity. A generic example, before:
class Account
{
private string $email;
private ?\DateTimeImmutable $verifiedAt = null;
public function getEmail(): string
{
return $this->email;
}
public function setEmail(string $email): void
{
$this->email = strtolower(trim($email));
}
public function getVerifiedAt(): ?\DateTimeImmutable
{
return $this->verifiedAt;
}
public function markVerified(\DateTimeImmutable $at): void
{
$this->verifiedAt = $at;
}
}
And after:
class Account
{
public string $email {
set(string $value) => strtolower(trim($value));
}
public private(set) ?\DateTimeImmutable $verifiedAt = null;
public function markVerified(\DateTimeImmutable $at): void
{
$this->verifiedAt = $at;
}
}
The normalization now lives on the property, so it applies however the value is
set. Anything can read verifiedAt, and only the class can write it. Three of
the four methods are gone, and the one left says what it does.
I also moved the client's Doctrine setup onto PHP's native lazy objects, which arrived in the same release.
The pipe operator
PHP 8.5 added the pipe operator, |>. Nested calls read inside out:
$slug = trim(preg_replace('/[^a-z0-9]+/', '-', strtolower(trim($title))), '-');
The same steps with the pipe read in the order they happen:
$slug = $title
|> trim(...)
|> strtolower(...)
|> (fn ($s) => preg_replace('/[^a-z0-9]+/', '-', $s))
|> (fn ($s) => trim($s, '-'));
I added it to the codebase by hand. I reach for it where a value passes through a chain of steps, which is where nested calls are hardest to read. Each step takes one argument, so a step that needs more becomes a closure, as above. If most of the steps look like that, plain assignments one line at a time are often clearer.
Smaller changes, also by hand
clone()with new property values. PHP 8.5 lets you pass an associative array of property values toclone(), so a method that returns a modified copy does it in one expression:return clone($this, ['currency' => $currency]);.#[\NoDiscard]on methods whose return value is the point of calling them, such as those copy-returning methods. Calling one and dropping the result is almost always a bug.#[\SensitiveParameter]on every parameter that carries a secret, which keeps its value out of stack traces. This one has been available since PHP 8.2, so it needed no upgrade at all, only someone to go through the signatures.- The URI extension for URL checks. PHP 8.5 ships a URI extension that is always available, so checking a URL can rest on a parser that comes with the language.
Switching production
The day of the switch should be the least interesting day of the project.
I wrote a runbook for the platform's rollout, so the steps and their order were settled in advance rather than worked out on the day. I made the deploy's service restart independent of the PHP version, so the deploy does not need to know which version it is restarting. And after the switch, I reviewed the production logs. That is where anything the tests did not reach would show up, so read them deliberately in the days after, rather than waiting for an alert.
If you are on 8.2 now
- Go to 8.5, not 8.3. 8.3 buys a year. 8.5 gets you 8.4's features as well, for the price of one migration.
- Clear the way in Composer. Delete what nothing uses, update what is left,
and fix what
composer auditreports. - Run CI on both versions until production has switched.
- Clear the deprecations, then make them fail the build.
- Let Rector do the mechanical part, in batches small enough to review.
- Adopt the new features by hand, where they make the code simpler.
- Write the runbook before the day, and read the production logs after it.
Whenever you start, the language change will be the easy part. Start with the dependencies and the tests, because that is where the time goes.
Sources
- Supported versions, php.net: security support for PHP 8.2 until 31 December 2026, and for 8.3 until 31 December 2027.
- PHP 8.4 release announcement, php.net: property hooks, asymmetric visibility and lazy objects.
- PHP 8.5 release announcement,
php.net: released 20 November 2025, with the pipe operator,
clone()with property values,#[\NoDiscard], the always-available URI extension, andarray_first()andarray_last(). - The SensitiveParameter attribute, PHP manual: available from PHP 8.2.0.
Upgrades like this are part of my architecture and modernization work.