🚀 PHP 8.5: What’s New and Changed – A Developer’s Guide

PHP 8.5, scheduled for release on November 20, 2025, continues the language’s focus on developer ergonomics, code clarity, and performance. This major update introduces several game-changing features, alongside quality-of-life improvements and necessary deprecations that pave the way for PHP 9.0.


✨ Major New Features

The Pipe Operator (|>)

The most anticipated feature, the pipe operator, allows for elegant function chaining without deep nesting or intermediary variables. It passes the result of the expression on its left as the first argument to the callable on its right.

Example (Concept):

// Before (Nested Calls):
$result = trim(strtoupper(" Hello World "));

// After (Pipe Operator):
$result = " Hello World "
    |> trim(...)
    |> strtoupper(...);
                

clone with Property Updates

You can now update properties directly during the cloning process by passing an associative array to the clone function. This simplifies the creation of “with-er” methods, especially for readonly classes and immutable Value Objects.

Example:

final readonly class User {
    public function __construct(
        public int $id,
        public string $name
    ) {}

    public function withName(string $name): self {
        // New PHP 8.5 syntax
        return clone($this, ['name' => $name]);
    }
}
                

#[NoDiscard] Attribute

This new attribute helps catch common bugs by emitting a warning if a function’s return value (which is likely important) is ignored or not used.

Example:

#[NoDiscard("The result must be checked for success/failure.")]
function performCrucialAction(): bool {
    // ...
    return $success;
}

performCrucialAction(); // Warning: Return value is expected to be consumed
$result = performCrucialAction(); // OK
                

URI Extension

PHP now includes a built-in, standards-compliant URI extension for parsing, normalizing, and handling URLs according to RFC 3986 and the WHATWG URL standards. This provides a more robust and predictable API than legacy functions like parse_url().


🛠️ Quality-of-Life Improvements

  • Array Helper Functions: The new array_first() and array_last() functions provide a cleaner way to retrieve the first or last value of an array, complementing array_key_first() and array_key_last().
  • Closures in Constant Expressions: Static closures and first-class callables can now be used in constant expressions, including attribute parameters and default values.
  • Fatal Error Stack Traces: Fatal errors (e.g., maximum execution time exceeded) now include a **full stack trace**, significantly improving debugging efficiency.
  • Error Handler Introspection: New functions get_error_handler() and get_exception_handler() allow you to retrieve the currently set handlers for better framework development and debugging.
  • Persistent cURL Share Handles: This allows reusing DNS, connection, and SSL handshake information across multiple PHP requests, improving performance for repeated HTTP calls to the same hosts.

⚠️ Deprecations and Backward Incompatible Changes

As with any major update, PHP 8.5 introduces several deprecations, signaling future removals in PHP 9.0.

Deprecated Feature Replacement / Change Impact Note
The backtick operator (“) as an alias for shell_exec() Use shell_exec() directly. Common in older codebases.
Non-canonical type casts ((integer), (boolean), etc.) Use the short, canonical forms: (int), (bool), (float), (string). Focus on code consistency.
__sleep() and __wakeup() magic methods Use __serialize() and __unserialize() instead. Modern serialization methods are preferred.
Using a semicolon (;) to terminate a case statement Must use a colon (:). Enforces correct control structure syntax.

Incompatible Changes to Note:

  • The disable_classes INI setting has been removed.
  • Casting NAN (Not-a-Number) to other types now emits a warning.

PHP 8.5 is a release that solidifies the modern PHP ecosystem, offering developers new expressive tools like the Pipe Operator and much-needed utility functions, all while continuing to refine the core language for safety and performance.

This video provides an overview of the key changes and new features you can expect in PHP 8.5.

What’s New in PHP 8.5? (Release Date + Must-Know Features)