PHP 8.5 Released: Top New Features
Released: November 20, 2025
The wait is over. PHP 8.5 has officially dropped, and it is shaping up to be one of the most developer-centric releases in recent years. While PHP 8.0 and 8.1 brought us massive architectural changes like the JIT compiler and Enums, PHP 8.5 focuses heavily on developer experience—reducing boilerplate, improving readability, and modernizing standard library interactions.
Whether you are a Laravel enthusiast, a Symfony expert, or a WordPress developer, here is everything you need to know about upgrading to PHP 8.5.
1. The Pipe Operator (|>)
The most anticipated feature of 8.5 is undoubtedly the Pipe Operator. Historically, nested function calls in PHP have been difficult to read, requiring you to read code “inside-out.”
The pipe operator allows you to chain callables in a clean, left-to-right flow.
Before PHP 8.5
PHP
$input = " Hello World ";
$result = strtolower(str_replace(' ', '-', trim($input)));
// Result: "hello-world"
// Hard to read the order of operations at a glance.
With PHP 8.5
PHP
$input = " Hello World ";
$result = $input
|> trim(...)
|> (fn($s) => str_replace(' ', '-', $s))
|> strtolower(...);
// Result: "hello-world"
// The data flows logically from top to bottom.
Note: The
...syntax creates a closure from the function, making it compatible with the pipe operator.
2. “Clone With” Syntax
Immutable objects are a best practice in modern PHP, but modifying them has always been clunky. Previously, you had to clone an object and then manually unset or modify properties, which often broke readonly constraints.
PHP 8.5 introduces a clone syntax that accepts an array of properties to overwrite during the cloning process.
PHP
readonly class User {
public function __construct(
public string $name,
public string $email
) {}
}
$user = new User('Jane', 'jane@example.com');
// PHP 8.5: Clone and modify in one atomic step
$updatedUser = clone $user with [
'email' => 'jane.new@example.com'
];
echo $updatedUser->email; // jane.new@example.com
3. Native Array First/Last Functions
For years, developers have relied on framework helpers like Laravel’s Arr::first() or messy pointer functions like reset() and end() to get the first or last item of an array. PHP 8.5 adds these natively to the standard library.
array_first(array $array): Returns the first value.array_last(array $array): Returns the last value.
PHP
$data = [10, 20, 30];
// Old way
$first = reset($data); // Affects internal pointer
// PHP 8.5 way
$first = array_first($data); // 10
$last = array_last($data); // 30
If the array is empty, these functions return null.
4. The #[NoDiscard] Attribute
This new attribute is a massive win for code safety. It tells the static analyzer and the runtime that the return value of a function must be used. This is critical for functions where the result is the only side effect (like immutable updates).
PHP
#[NoDiscard]
function calculateTax(float $amount): float {
return $amount * 0.2;
}
// This triggers a Warning in PHP 8.5
calculateTax(100.00);
// Correct usage
$tax = calculateTax(100.00);
5. New Uri Extension
PHP’s parse_url has notoriously been “quirky” and non-compliant with modern web standards. PHP 8.5 introduces a dedicated object-oriented extension for URI handling that complies with RFC 3986.
PHP
use Uri\Rfc3986\Uri;
$uri = new Uri('https://example.com/search?q=php');
echo $uri->getHost(); // example.com
echo $uri->getQuery(); // q=php
This will likely replace custom URI packages in many libraries over time.
6. Notable Deprecations
As with every release, PHP 8.5 cleans up technical debt. Here are the breaking changes you need to watch for:
- Backtick Operator Deprecated: usage of
`ls -la`is now deprecated. You should useshell_exec()explicitly. - Non-Canonical Casts: Casting using
(integer)or(boolean)is deprecated. You must use(int)and(bool). __sleepand__wakeupSoft Deprecation: It is highly recommended to switch to__serializeand__unserializefor magic object serialization.
Performance & Under-the-Hood
- Persistent cURL Share Handles: Significant performance boost for applications making repeated HTTP requests (e.g., microservices) by persisting DNS and SSL connections across requests.
- OpCache Optimization: New specific optimizations for empty array checks (
=== []) making them faster thancount() === 0.
Ready to Upgrade?
PHP 8.5 offers a compelling mix of syntactic sugar and robust type safety improvements. If you are relying heavily on immutable objects or functional programming patterns, this upgrade is a no-brainer.
Would you like me to generate a script to check your codebase for the new deprecated cast styles (e.g., (integer) vs (int))?
