Refined developer experience with new utility functions, enhanced debugging, and modern syntax improvements
Major improvements with modern syntax, better APIs, and enhanced developer experience
New URI extension providing standards-compliant URL parsing with modern object-oriented API
$components = parse_url("https://php.net/releases/8.5/en.php");
var_dump($components['host']);
// string(7) "php.net"
use Uri\Rfc3986\Uri;
$uri = new Uri("https://php.net/releases/8.5/en.php");
var_dump($uri->getHost());
// string(7) "php.net"
Modify properties while cloning, perfect for readonly properties and immutable objects
final readonly class PhpVersion {
public function __construct(
public string $version = 'PHP 8.4',
) {}
public function withVersion(string $version) {
$newObject = clone $this;
$newObject->version = $version;
return $newObject;
}
}
var_dump(new PhpVersion()->withVersion('PHP 8.5'));
// Fatal error: Cannot modify readonly property
final readonly class PhpVersion {
public function __construct(
public string $version = 'PHP 8.4',
) {}
public function withVersion(string $version) {
return clone($this, ['version' => $version]);
}
}
$version = new PhpVersion();
var_dump(
$version->withVersion('PHP 8.5'),
$version->version,
);
Chain function calls naturally with the new pipe operator for cleaner, more readable code
$input = ' Some kind of string. ';
$output = strtolower(
str_replace(['.', '/', '…'], '',
str_replace(' ', '-',
trim($input)
)
)
);
$input = ' Some kind of string. ';
$output = $input
|> trim(...)
|> (fn (string $s) => str_replace(' ', '-', $s))
|> (fn (string $s) => str_replace(['.', '/', '…'], '', $s))
|> strtolower(...);
Mark functions whose return values should not be ignored
function getPhpVersion(): string {
return 'PHP 8.4';
}
getPhpVersion(); // No Errors
#[\NoDiscard]
function getPhpVersion(): string {
return 'PHP 8.4';
}
getPhpVersion();
// Warning: The return value should be used
// or intentionally ignored by casting as (void)
Convenient functions to retrieve the first and last elements of arrays
$php = [
'php-82' => ['state' => 'security', 'branch' => 'PHP-8.2'],
'php-83' => ['state' => 'active', 'branch' => 'PHP-8.3'],
'php-84' => ['state' => 'active', 'branch' => 'PHP-8.4'],
'php-85' => ['state' => 'upcoming', 'branch' => 'PHP-8.5'],
];
$upcomingRelease = null;
foreach ($php as $key => $version) {
if ($version['state'] === 'upcoming') {
$upcomingRelease = $version;
break;
}
}
var_dump($upcomingRelease);
$php = [
'php-82' => ['state' => 'security', 'branch' => 'PHP-8.2'],
'php-83' => ['state' => 'active', 'branch' => 'PHP-8.3'],
'php-84' => ['state' => 'active', 'branch' => 'PHP-8.4'],
'php-85' => ['state' => 'upcoming', 'branch' => 'PHP-8.5'],
];
$upcomingRelease = array_first(
array_filter(
$php,
static fn($version) => $version['state'] === 'upcoming'
)
);
var_dump($upcomingRelease);
Property promotion is now available for final class constructors
Constants now support attributes for better metadata
Better validation when overriding parent properties
Mark legacy code with deprecation attributes
Fine-grained control over read/write access for static properties
New functions for inspecting registered error handlers
PHP 8.5 development and support schedule
PHP 8.5.0 released with all new features and improvements.
Bug fixes and general maintenance will cease. Security fixes only.
PHP 8.5 reaches end of life. Please upgrade to a newer version.
Upgrading to PHP 8.5 from earlier versions
Download PHP 8.5 for your platform
Compile PHP 8.5 from source for maximum flexibility and customization.
Pre-built binaries for Windows, including thread-safe and non-thread-safe versions.
Official PHP 8.5 Docker images for containerized deployments.