PHP 8.5: the pipe operator, URI extension, clone with and other changes
PHP 8.5 (released 20 November 2025) added the |> pipe operator, a standards-compliant URI extension, clone() with property overrides, #[\NoDiscard] and array_first()/array_last().
PHP 8.5.0 was released on 20 November 2025. It receives active support until 31 December 2027 and security fixes until 31 December 2029. The official release page has the full list.
The pipe operator
|> passes the value on the left as the single argument of the callable on the right, so transformations read top to bottom instead of inside out:
// before
$slug = strtolower(str_replace(' ', '-', trim($title)));
// PHP 8.5
$slug = $title
|> trim(...)
|> (fn (string $s) => str_replace(' ', '-', $s))
|> strtolower(...);
Each step must take exactly one required parameter. In PHP 8.6, partial function application removes the need for the arrow function: |> str_replace(' ', '-', ?).
URI extension
A built-in, always-available extension parses and modifies URLs to RFC 3986 (Uri\Rfc3986\Uri) or the WHATWG URL standard browsers use (Uri\WhatWg\Url). It fixes the long-standing inconsistencies of parse_url():
use Uri\Rfc3986\Uri;
$uri = new Uri('https://example.com/blog?page=2');
echo $uri->getHost(); // example.com
echo $uri->withPath('/docs')->toString(); // https://example.com/docs?page=2
clone with
clone() accepts an array of properties to change, which makes “wither” methods on readonly classes one line:
final readonly class Money
{
public function __construct(public int $amount, public string $currency) {}
public function withAmount(int $amount): static
{
return clone($this, ['amount' => $amount]);
}
}
Also new
#[\NoDiscard]warns when a function’s return value is ignored; cast to(void)to discard on purpose.array_first()andarray_last()return the first or last value, ornullfor an empty array.- Closures and first-class callables in constant expressions, so they can appear in attribute arguments and default values.
- Persistent cURL share handles (
curl_share_init_persistent()) let connections and DNS lookups be reused across requests.
Deprecations and breaking changes
- The backtick operator as an alias of
shell_exec()is deprecated. - Non-canonical casts
(boolean),(integer),(double)and(binary)are deprecated. nullas an array offset or inarray_key_exists()is deprecated.casestatements ending in;instead of:are deprecated.__sleep()and__wakeup()are soft-deprecated in favour of__serialize()and__unserialize().- The
disable_classesini setting was removed. - Casting
NAN, or a float that does not fit in an int, now warns; so does destructuring a non-array value other thannull.
Upgrading from an older version? The upgrade checklist lists every step between your version and 8.5 or 8.6.
Sources
- PHP 8.5 release announcement, php.net