What's new in PHP 8.5 Written on 2025-11-20
PHP 8.5 was released on November 20, 2025. It includes the pipe operator, clone with, a new URI parser, and more.
PHP 8.5 introduces the new pipe operator that makes chaining output from one function to another a lot easier. Instead of deeply nested function calls like this:
$input = ' Some kind of string. ' ; $output = strtolower ( str_replace ([ '.' , '/' , '…' ], '' , str_replace ( ' ' , '-' , trim ( $input ) ) ) );
You can now write this:
$output = $input |> trim (...) |> ( fn ( string $string ) => str_replace ( ' ' , '-' , $string )) |> ( fn ( string $string ) => str_replace ([ '.' , '/' , '…' ], '' , $string )) |> strtolower (...);
I've done a deep-dive into this new operator, and you can read about it here.
There's now a way to assign new values to cloned objects while cloning them:
final class Book { public function __construct ( public string $title , public string $description , ) {} public function withTitle ( string $title ): self { return clone ( $this , [ 'title' => $title , ]); } }
I think this is a great feature. The only thing I find unfortunate is that it doesn't work when cloning readonly properties from the outside (which I think is a common use case). To do so, you have to specifically reset the propery's write access to public(set) . I explained the problem here.
... continue reading