From 3fdde94d2f8a45f4222faf003ffb451c67280390 Mon Sep 17 00:00:00 2001 From: Theodore Brown Date: Tue, 21 Oct 2025 22:45:45 -0500 Subject: [PATCH] Revamp PHP 8.5 examples and content * Simplified header and footer text. * Moved Pipe Operator example to the top and simplified the code and description slightly. * Made the URI Extension description less wordy. * Replaced the *Clone With* example to have a realistic before/after class (rather than a fatal error in the before example). * Greatly simplified the `array_first()` example and moved it to after the `#[\NoDiscard]` attribute. * Replaced the *Closures and First Class Callables in Constant Expressions* example with a couple self-contained functions highlighting the new syntax (rather than a complex test which isn't even supported in PHPUnit). Also added a description. * Shortened and clarified the *Persistent cURL Share Handles* example and added a more helpful description. * Filled out the *Deprecations and backward compatibility breaks* section. * Replaced *New Classes, Interfaces, and Functions* section with a more relevant *Additional features and improvements* section (mentioning that fatal errors now include a backtrace, that `setcookie()` and `setrawcookie()` now support the "partitioned" key, and clarifying some of the other new functions/features). --- releases/8.5/languages/en.php | 32 +-- releases/8.5/release.inc | 394 ++++++++++++++++------------------ 2 files changed, 197 insertions(+), 229 deletions(-) diff --git a/releases/8.5/languages/en.php b/releases/8.5/languages/en.php index 3ac7f87c20..7f3011b05c 100644 --- a/releases/8.5/languages/en.php +++ b/releases/8.5/languages/en.php @@ -1,29 +1,31 @@ 'PHP 8.5 is a major update of the PHP language. It contains many new features, such as the new URI extension, support for modifying properties while cloning, the Pipe operator, performance improvements, bug fixes, and general cleanup.', + 'common_header' => 'PHP 8.5 is a major update of the PHP language, with new features including the Pipe Operator, URI extension, and support for modifying properties while cloning.', 'documentation' => 'Doc', 'main_title' => 'Released!', - 'main_subtitle' => 'PHP 8.5 is a major update of the PHP language.
It contains many new features, such as the new URI extension, support for modifying properties while cloning, the Pipe operator, performance improvements, bug fixes, and general cleanup.', - 'upgrade_now' => 'Upgrade to PHP 8.5 now!', + 'main_subtitle' => 'PHP 8.5 is a major update of the PHP language, with new features including the Pipe Operator, URI extension, and support for modifying properties while cloning.', + 'upgrade_now' => 'Upgrade to PHP 8.5', 'pipe_operator_title' => 'Pipe Operator', - 'pipe_operator_description' => '

The pipe operator allows chaining function calls together without dealing with intermediary variables. That can be especially helpful when replacing many "nested calls" with a chain that can be read forwards, rather than inside-out.

Learn more about the backstory of this feature in The PHP Foundation’s blog.

', - 'url_parsing_api_title' => 'New URI Extension', - 'url_parsing_api_description' => '

As an always-available part of PHP\'s standard library the new URI extension provides APIs to parse and modify URIs and URLs according to the RFC 3986 and the WHATWG URL standards.

The secure and standards-compliant URI parsing is powered by the uriparser (RFC 3986) and Lexbor (WHATWG URL) libraries.

Learn more about the backstory of this feature in The PHP Foundation’s blog.

', + 'pipe_operator_description' => '

The pipe operator allows chaining function calls together without dealing with intermediary variables. This enables replacing many "nested calls" with a chain that can be read forwards, rather than inside-out.

Learn more about the backstory of this feature in The PHP Foundation’s blog.

', + 'uri_extension_title' => 'URI Extension', + 'uri_extension_description' => '

The new always-available URI extension provides APIs to securely parse and modify URIs and URLs according to the RFC 3986 and the WHATWG URL standards.

Powered by the uriparser (RFC 3986) and Lexbor (WHATWG URL) libraries.

Learn more about the backstory of this feature in The PHP Foundation’s blog.

', 'clone_with_title' => 'Clone With', - 'clone_with_description' => 'It is now possible to update properties during object cloning by passing an associative array with the updated to the clone() function. This enables straight-forward support of the "with-er" pattern for readonly classes.', + 'clone_with_description' => 'It is now possible to update properties during object cloning by passing an associative array to the clone() function. This enables straightforward support of the "with-er" pattern for readonly classes.', 'no_discard_title' => '#[\NoDiscard] Attribute', - 'no_discard_description' => '

By adding the #[\NoDiscard] attribute to a function, PHP will check whether the returned value is consumed and emit a warning if it is not. This allows to improve the safety of APIs where the returned value is important, but where it is easy to forget using the return value by accident.

The associated (void) cast can be used to indicate that a value is intentionally unused.

', - 'fcc_in_const_expr_title' => 'Closures and First Class Callables in Constant Expressions', - 'curl_share_persistence_improvement_title' => 'Persistent cURL Share Handles', - 'array_first_last_title' => 'New array_first() and array_last() functions', + 'no_discard_description' => '

By adding the #[\NoDiscard] attribute to a function, PHP will check whether the returned value is consumed and emit a warning if it is not. This allows improving the safety of APIs where the returned value is important, but it\'s easy to forget using the return value by accident.

The associated (void) cast can be used to indicate that a value is intentionally unused.

', + 'array_first_last_title' => 'array_first() and array_last() functions', + 'fcc_in_const_expr_title' => 'Closures and First-Class Callables in Constant Expressions', + 'fcc_in_const_expr_description' => 'Static closures and first-class callables can now be used in constant expressions. This includes attribute parameters, default values of properties and parameters, and constants.', + 'persistent_curl_share_handles_title' => 'Persistent cURL Share Handles', + 'persistent_curl_share_handles_description' => 'Unlike curl_share_init(), handles created by curl_share_init_persistent() will not be destroyed at the end of the PHP request. If a persistent share handle with the same set of share options is found, it will be reused, avoiding the cost of initializing cURL handles each time.', - 'new_classes_title' => 'New Classes, Interfaces, and Functions', + 'new_classes_title' => 'Additional features and improvements', 'bc_title' => 'Deprecations and backward compatibility breaks', - 'footer_title' => 'Better performance, better syntax, improved type safety.', - 'footer_description' => '

For source downloads of PHP 8.5 please visit the downloads page. Windows binaries can be found on the PHP for Windows site. The list of changes is recorded in the ChangeLog.

-

The migration guide is available in the PHP Manual. Please consult it for a detailed list of new features and backward-incompatible changes.

', + 'footer_title' => 'Better syntax, improved performance and type safety.', + 'footer_description' => '

The full list of changes is recorded in the ChangeLog.

+

Please consult the Migration Guide for a detailed list of new features and backward-incompatible changes.

', ]; diff --git a/releases/8.5/release.inc b/releases/8.5/release.inc index 48a2f1abbc..46cb88c4d5 100644 --- a/releases/8.5/release.inc +++ b/releases/8.5/release.inc @@ -36,9 +36,9 @@ common_header(message('common_header', $lang));
-

- - RFC +

+ + RFC

@@ -46,41 +46,51 @@ common_header(message('common_header', $lang));
-
+
PHP 8.5
-
+
trim(...) + |> (fn($str) => str_replace(' ', '-', $str)) + |> (fn($str) => str_replace('.', '', $str)) + |> strtolower(...); -var_dump($uri->getHost()); -// string(7) "php.net" +var_dump($output); // string(13) "my-test-value" PHP ); ?>
- +
-

- - RFC +

+ + RFC

@@ -88,124 +98,102 @@ PHP
version = $version; - - return $newObject; - } -} - -$version = new PhpVersion(); - -var_dump($version->version); -// string(7) "PHP 8.4" +$components = parse_url('https://php.net/releases/8.4/en.php'); -var_dump($version->withVersion('PHP 8.5')->version); -// Fatal error: Uncaught Error: Cannot modify readonly property PhpVersion::$version +var_dump($components['host']); +// string(7) "php.net" PHP ); ?>
-
+
PHP 8.5
-
+
$version, - ]); - } -} - -$version = new PhpVersion(); - -var_dump($version->version); -// string(7) "PHP 8.4" +use Uri\Rfc3986\Uri; -var_dump($version->withVersion('PHP 8.5')->version); -// string(7) "PHP 8.5" +$uri = new Uri('https://php.net/releases/8.5/en.php'); -var_dump($version->version); -// string(7) "PHP 8.4" +var_dump($uri->getHost()); +// string(7) "php.net" PHP ); ?>
- +
-

- - RFC +

+ + RFC

PHP < 8.5
withAlpha(128); PHP ); ?>
-
+
PHP 8.5
-
+
trim(...) - |> (fn($string) => str_replace(' ', '-', $string)) - |> (fn($string) => str_replace(['.', '/', '…'], '', $string)) - |> strtolower(...); + public function withAlpha(int $alpha): self + { + return clone($this, ['alpha' => $alpha]); + } +} -var_dump($output); -// string(19) "some-kind-of-string" +$blue = new Color(79, 91, 147); +$transparentBlue = $blue->withAlpha(128); PHP ); ?>
- +
@@ -225,16 +213,16 @@ function getPhpVersion(): string return 'PHP 8.4'; } -getPhpVersion(); // No Errors +getPhpVersion(); // No warning PHP ); ?>
-
+
PHP 8.5
-
+
-

- - RFC - RFC +

+ + RFC

@@ -267,62 +254,40 @@ PHP
assertSame( - $result, - Calculator::subtract($minuend, $subtrahend) - ); - } +$releases = [ + '8.5' => '2025-11-20', + '8.4' => '2024-11-21', + '8.3' => '2023-11-23', + '8.2' => '2022-12-08', +]; - public static function subtractionProvider(): iterable - { - for ($i = -10; $i <= 10; $i++) { - yield [$i, $i, 0]; - yield [$i, 0, $i]; - yield [0, $i, -$i]; - } - } -} +$firstKey = array_key_first($releases); +$newestDate = $releases[$firstKey]; + +var_dump($newestDate); +// string(10) "2025-11-20" PHP ); ?>
-
+
PHP 8.5
-
+
'2025-11-20', + '8.4' => '2024-11-21', + '8.3' => '2023-11-23', + '8.2' => '2022-12-08', +]; + +$newestDate = array_first($releases); + +var_dump($newestDate); +// string(10) "2025-11-20" PHP ); ?>
@@ -331,10 +296,10 @@ PHP
-

- - RFC - RFC +

+ + RFC + RFC

@@ -342,54 +307,58 @@ PHP
-
+
PHP 8.5
-
+
- New CurlSharePersistentHandle class, curl_multi_get_handles(), curl_share_init_persistent() functions are available. +
-

- - RFC +

+ + RFC + RFC

@@ -397,53 +366,42 @@ PHP
['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'], -]; +$sh = curl_share_init(); +curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS); +curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_CONNECT); -$upcomingRelease = null; -foreach ($php as $key => $version) { - if ($version['state'] === 'upcoming') { - $upcomingRelease = $version; - break; - } -} +$ch1 = curl_init('https://php.net/'); +curl_setopt($ch1, CURLOPT_SHARE, $sh); -var_dump($upcomingRelease); +curl_exec($ch1); PHP - ); ?>
-
+
PHP 8.5
-
+
['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'], -]; +$sh = curl_share_init_persistent([ + CURL_LOCK_DATA_DNS, + CURL_LOCK_DATA_CONNECT +]); -$upcomingRelease = array_first( - array_filter( - $php, - static fn($version) => $version['state'] === 'upcoming' - ) -); +$ch1 = curl_init('https://php.net/'); +curl_setopt($ch1, CURLOPT_SHARE, $sh); -var_dump($upcomingRelease); +// This may now reuse the connection from an earlier SAPI request +curl_exec($ch1); PHP ); ?>
+
+ +
@@ -452,19 +410,18 @@ PHP

@@ -473,7 +430,16 @@ PHP