Talk to an engineer

PHP 8.5: release date, new features and what breaks

PHP 8.5 was released on November 20, 2025. The pipe operator, the URI extension, clone with, #[\NoDiscard] and array_first(), every deprecation with the fix, and a step-by-step upgrade plan.

SeaPHP engineering · November 30, 2026

PHP 8.5 was released on November 20, 2025. It is a developer-experience release: the pipe operator changes how data transformations read, a built-in URI extension finally replaces parse_url(), and clone learns to change properties on the way. Its deprecations are short and mostly mechanical, which makes it one of the easier upgrades of the PHP 8 series.

This guide covers each feature with a before and after, every deprecation with the fix, the support dates, and how to upgrade. PHP 8.6 has since been released; see PHP 8.6: new features for what came next.

PHP 8.5 release date and support

Date
Released November 20, 2025
Active support (bug fixes) until December 31, 2027
Security support until December 31, 2029

The pipe operator

|> passes the value on its left as the only argument to the callable on its right. Chains of nested calls, which read inside out, become a sequence that reads top to bottom.

// Before
$slug = strtolower(str_replace(' ', '-', trim($title)));

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

Two things to know. Each step must be a callable that takes exactly one required argument, which is why trim(...) uses first-class callable syntax. And arrow functions in a pipe must be wrapped in parentheses. PHP 8.6's partial function application removes most of those arrow functions (str_replace(' ', '-', ?)), so the two features are designed to be used together.

The URI extension

parse_url() follows no standard, and its quirks have caused real security bugs when an application and a browser disagree about which host a URL points to. PHP 8.5 adds an always-available URI extension with two standards-based parsers:

  • Uri\Rfc3986\Uri follows RFC 3986, the generic URI standard.
  • Uri\WhatWg\Url follows the WHATWG URL standard, which is what browsers implement.
use Uri\Rfc3986\Uri;

$uri = new Uri('https://php.net/releases/8.5/en.php');

echo $uri->getHost();   // php.net
echo $uri->getPath();   // /releases/8.5/en.php

$next = $uri->withPath('/releases/8.6/en.php');

Use the WHATWG parser for anything that came from a browser or will be sent to one, such as redirect targets and links in user content. That closes the gap between what your validation checks and what the browser actually requests.

Clone with

clone can now take an array of properties to change on the copy. This makes "with-er" methods on immutable objects one line, including for readonly properties, which could not be changed after cloning before.

final readonly class Money
{
    public function __construct(
        public int $amount,
        public string $currency,
    ) {}

    public function withAmount(int $amount): static
    {
        return clone($this, ['amount' => $amount]);
    }
}

The changes respect visibility: a readonly property can only be set from inside its class.

#[\NoDiscard]

Mark a function whose return value must be used, and PHP warns when a caller ignores it. It is ideal for functions that return a new value instead of changing their argument, or that report failure through the return value.

#[\NoDiscard('the result is a new collection; the original is unchanged')]
function with_item(array $items, mixed $item): array
{
    return [...$items, $item];
}

with_item($cart, $product);          // Warning: return value is not used

(void) with_item($cart, $product);   // Explicitly discarded, no warning

Add it to library methods where an ignored result is almost certainly a bug.

array_first() and array_last()

Two functions that should have existed for twenty years. They return the first or last value of an array, or null for an empty array, without moving the internal pointer the way reset() and end() do.

$latest = array_last($events);
$first  = array_first($queue) ?? throw new EmptyQueue();

Fatal errors with a backtrace

Fatal errors, such as exceeding the maximum execution time, now include a backtrace like exceptions do. On production systems this turns a one-line log entry into something you can act on. It is controlled by the fatal_error_backtraces setting and is on by default.

Smaller additions

  • Closures and first-class callables in constant expressions, so they can be used in attribute arguments and default values.
  • Persistent cURL share handles (curl_share_init_persistent()), which share DNS and connection caches across requests in the same worker.
  • Attributes on constants, #[\Override] on properties, and #[\Deprecated] on traits and constants.
  • Asymmetric visibility for static properties, and final through constructor property promotion.
  • get_error_handler() and get_exception_handler().
  • Partitioned cookies (CHIPS) through the partitioned option of setcookie().
  • New DOM methods: getElementsByClassName() and insertAdjacentHTML().

Deprecations and breaking changes, with fixes

Change What to do
The backtick operator (`ls`) is deprecated Replace with shell_exec(), or better, with proc_open() and escaped arguments
Cast names (boolean), (integer), (double), (binary) are deprecated Use (bool), (int), (float), (string)
case ending with a semicolon instead of a colon is deprecated Replace case 1; with case 1:
null as an array offset or in array_key_exists() is deprecated Use an empty string '' explicitly, or check for null first
__sleep() and __wakeup() are soft-deprecated Move to __serialize() and __unserialize() when you next touch the class
The disable_classes ini setting is removed Remove it from php.ini; enforce restrictions at the container or OS level
Casting NAN, or a float too large for an int, to another type warns Check is_nan() and ranges before casting
Destructuring a non-array (other than null) warns Check the type before [$a, $b] = $value
array and callable cannot be class alias names Rename the alias

Rector has rules for the cast names, the backtick operator and the case semicolons, so most of these are fixed in one automated pass.

How to upgrade to PHP 8.5

  1. Start from a clean PHP 8.4. Clear 8.4's deprecations first, especially implicitly nullable parameter types, which are common and which 8.4 flags everywhere.
  2. Check dependencies with composer why-not php 8.5.0, and update or replace what blocks it.
  3. Run Rector and static analysis configured for PHP 8.5 to fix the mechanical deprecations.
  4. Run the test suite on 8.5 with E_DEPRECATED logged, and fix what remains.
  5. Canary in production: send a share of traffic to 8.5, compare error rates and latency, then switch the rest.

If you are further behind, on PHP 8.1 or 7.4, the jump is bigger and should be done one version at a time. Our PHP 7.4 to 8 field guide covers the hardest step, and we run these upgrades for teams that would rather keep shipping features.

Find out what your PHP estate needs

Tell us which versions you run and where. An engineer replies within one business day.