PHP 8.5 Upgrade: What Changes for Symfony and Older Codebases

#php 8.5 upgrade

Founder & Lead Developer

Expert in software development and legacy code optimization

LinkedIn

PHP 8.5 was released on 20 November 2025, so it has now been in production use for a full year. For most teams the PHP 8.5 upgrade has stopped being an early-adopter question. Extensions and libraries have caught up, the first round of point releases has shaken out the obvious bugs, and the version will get active support until the end of 2027 and security fixes until the end of 2029 (the dates are on php.net/supported-versions).

The more pressing reason to look at it now is the other end of the calendar. PHP 8.2 stops receiving security fixes on 31 December 2026, five weeks from today. PHP 8.1 already lost support at the end of 2025. If your application runs on either, you are choosing your next target version right now, whether you planned to or not.

Below: the 8.5 features worth using, the deprecations that tend to bite older code, where Symfony fits, and the order we would do the work in.

Where PHP 8.5 sits in the support calendar

A quick map of the versions you are likely to meet in a real project:

VersionActive support endsSecurity support ends
PHP 8.1ended31 Dec 2025 (ended)
PHP 8.2ended31 Dec 2026
PHP 8.3ended31 Dec 2027
PHP 8.431 Dec 202631 Dec 2028
PHP 8.531 Dec 202731 Dec 2029

If you are on 8.2 today, jumping to 8.3 buys you one year. Going to 8.4 buys two. Going to 8.5 buys three, and the extra distance is usually smaller than people expect, because most of the painful changes in the 8.x line arrived in 8.1 and 8.2. We wrote about the business side of the 8.2 deadline in PHP 8.2 end of life: what to do now. This post is the technical companion for the team doing the work.

The PHP 8.5 features worth adopting

New syntax is not a reason to upgrade on its own, but a few additions in 8.5 make everyday code easier to read. These are the ones we expect to see in reviews.

The pipe operator

The |> operator passes the value on its left as the single argument to the callable on its right. Nested function calls that used to read inside out can now read top to bottom:

$slug = $title
    |> trim(...)
    |> strtolower(...)
    |> (fn (string $s) => str_replace(' ', '-', $s));

Arrow functions need the parentheses shown above. Each step takes exactly one argument, so the operator suits small transformation chains better than general control flow. Use it where it removes a temporary variable or a pyramid of brackets, and leave it alone elsewhere.

Clone with

clone() now accepts an array of properties to change on the copy. That matters most for readonly value objects, where "withers" used to need reflection tricks or a full constructor call:

public function withStatus(Status $status): static
{
    return clone($this, ['status' => $status]);
}

If your domain layer has a lot of immutable DTOs, this removes a fair amount of boilerplate.

The URI extension

PHP 8.5 ships a built-in URI extension with two classes: Uri\Rfc3986\Uri and Uri\WhatWg\Url, following the RFC 3986 and WHATWG URL standards respectively. Anyone who has debugged the edge cases of parse_url() will appreciate having a parser that follows a written standard. For code that validates redirect targets or webhook URLs, fewer parser quirks also means fewer security surprises.

#[\NoDiscard]

Mark a function or method with #[\NoDiscard] and PHP emits a warning when the caller ignores its return value. A (void) cast tells PHP the result is ignored on purpose. This is useful for methods on immutable objects, where calling $date->modify() and throwing away the result is a classic bug.

array_first() and array_last()

Two small helpers that return the first and last value of an array, or null for an empty one. They replace reset(), end() and array_key_first() dances that are easy to get subtly wrong.

There is more in the release, including closures and first-class callables in constant expressions and fatal errors that now come with a backtrace. The official migration guide on php.net lists everything.

The deprecations that hit legacy code

Deprecations do not break anything on the day you upgrade. They produce notices, and those notices turn into errors in a later major version. In a codebase with a strict error handler (many Symfony apps convert deprecations to exceptions in tests) they can still fail a CI run immediately.

The ones we see most often in older PHP code:

  • The backtick operator as an alias for shell_exec() is deprecated. Old deployment scripts and admin tools are the usual places to find it.
  • Non-canonical cast names such as (integer), (boolean), (double) and (binary) are deprecated in favour of (int), (bool), (float) and (string). Code written in the PHP 5 era is full of them.
  • Ending a case statement with a semicolon instead of a colon is deprecated.
  • Using null as an array offset is deprecated. This one hides in code paths where a lookup key is sometimes missing, which makes it more than a cosmetic fix.
  • Functions that have done nothing since resources became objects, such as curl_close(), finfo_close(), xml_parser_free() and imagedestroy(), are now deprecated. You can delete those calls.
  • ReflectionProperty::setAccessible() and ReflectionMethod::setAccessible() have had no effect since 8.1 and are now deprecated. Older test helpers and hydrators call them a lot.

Most of these are mechanical to fix. The point of listing them is that a codebase that skipped several PHP versions will have hundreds of occurrences, and you want a tool to find them rather than a developer reading files.

PHP 8.5 and Symfony

Symfony 7.4 and Symfony 8.0 both shipped in November 2025, alongside PHP 8.5. Symfony 8.0 requires PHP 8.4 or newer, and Symfony 7.4 (the current LTS) requires PHP 8.2. Both run on 8.5.

That gives teams a useful choice. If you are on Symfony 6.4 or 7.x, you can move to PHP 8.5 first and keep the framework where it is, as long as your Symfony version and your other dependencies are tested against 8.5. Then you plan the framework upgrade separately. Doing the two at once makes it much harder to tell which change caused a regression. Our Symfony 8 upgrade overview covers the framework side.

For older Symfony versions (5.4 and below) the order is reversed. The framework itself will not support 8.5, so the PHP upgrade has to wait until the framework is on a supported line.

Doctrine, API Platform and the common bundles generally publish 8.5 support in their release notes. Check them before you start rather than when composer refuses to resolve.

Tooling that does most of the work

Three tools carry most PHP upgrades we do:

  1. Rector applies the mechanical rewrites. Its PHP version sets include the 8.5 changes, and on older code it can cover the long tail of renamed functions and removed syntax as well. We covered the workflow in detail in Rector for legacy PHP.
  2. PHPStan, configured with phpVersion set to 8.5, catches the type and signature problems that Rector does not touch. If your project is not on a meaningful PHPStan level yet, raise it gradually instead of fixing everything at once.
  3. PHPCompatibility (a PHP_CodeSniffer standard) gives a second opinion on version compatibility. Check that the release you install knows about 8.5 before you trust a clean report.

Run the test suite with deprecations shown. If it passes while printing hundreds of notices, the work is not finished.

A CI matrix for the transition

During the upgrade, run CI against both the current and the target PHP version. A minimal GitHub Actions setup looks like this:

strategy:
  matrix:
    php: ['8.2', '8.5']
steps:
  - uses: shivammathur/setup-php@v2
    with:
      php-version: ${{ matrix.php }}
  - run: composer install --no-interaction
  - run: vendor/bin/phpunit

This lets developers keep shipping features on the old version while the upgrade branch proves itself on the new one. Once production is on 8.5, drop the old entry and set config.platform.php in composer.json to match, so nobody pulls in a dependency that needs a newer version than you run.

Planning the PHP 8.5 upgrade from PHP 8.1 or 8.2

Here is the order we use when a client is one or two versions behind:

  1. Inventory the runtime: PHP version on every server, CLI and FPM, plus installed extensions. They often differ.
  2. Update Composer dependencies to versions that support 8.5, while still on the old PHP version. Ship that.
  3. Add 8.5 to the CI matrix. Run Rector with the relevant PHP sets, then PHPStan, and fix what they report.
  4. Clear deprecation notices in the test run until the 8.5 job is clean.
  5. Deploy to a staging environment on 8.5 and run it with real traffic patterns for a few days. Watch the logs for deprecations from code paths the tests do not cover.
  6. Switch production, keeping the old runtime image ready for a fast rollback.

If you are coming from 7.4, the path is longer, but the structure is the same. Our guide on upgrading from PHP 7.4 to 8.3 covers the bigger jumps, and everything in it carries over to 8.5.

Should you go straight to 8.5?

For most applications on 8.2, yes. The jump from 8.2 to 8.5 is mostly deprecation cleanup, the tooling handles it well, and you get until the end of 2029 before the next forced move. Stopping at 8.3 means doing this exercise again in about a year.

The exceptions are applications that depend on an extension or a commercial library with no 8.5 support yet. In that case go to 8.4, which is fully supported until the end of 2026 and has security fixes until the end of 2028, and revisit later.

If you want a second pair of eyes on the upgrade plan, or you would rather hand the work to someone who has done it many times, that is what our legacy code optimization and code quality consulting work covers. Write to hello@wolf-tech.io or have a look around wolf-tech.io. We are happy to look at your composer.json and tell you roughly what you are in for.