[PHP-WEBMASTER] [web-php] php-85-focus: Move Pipe Operator after URI Extension and use more realistic `array_last()` example (#32)

Author: Theodore Brown (theodorejb)
Committer: GitHub (web-flow)
Pusher: saundefined
Date: 2025-11-06T10:33:27+03:00

Commit: Move Pipe Operator after URI Extension and use more realistic `array_… · php/web-php@0f13eb7 · GitHub
Raw diff: https://github.com/php/web-php/commit/0f13eb7f9f033e8575e1f017746f8729500d0a74.diff

Move Pipe Operator after URI Extension and use more realistic `array_last()` example (#32)

* Move Pipe Operator after URI Extension

This is per feedback - without PFA the pipe operator is somewhat clunky, so it may be better to feature it first next year with partial function application.

* Use more realistic example for array_last

Changed paths:
  M releases/8.5/release.inc

Diff:

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

     <section class="php8-section center">
         <div class="php8-compare">
- <h2 class="php8-h2" id="pipe_operator">
- <?= message('pipe_operator_title', $lang) ?>
- <a class="php8-rfc" href="PHP: rfc:pipe-operator-v3;
+ <h2 class="php8-h2" id="uri_extension">
+ <?= message('uri_extension_title', $lang) ?>
+ <a class="php8-rfc" href="PHP: rfc:url_parsing_api;
             </h2>
             <div class="php8-compare__main">
                 <div class="php8-compare__block example-contents">
@@ -46,17 +46,10 @@ common_header(message('common_header', $lang));
                     <div class="php8-code phpcode">
                         <?php highlight_php_trimmed(
                                 <<<'PHP'
-$input = ' My test value. ';
-
-$output = strtolower(
- str_replace('.', '',
- str_replace(' ', '-',
- trim($input)
- )
- )
-);
+$components = parse_url('PHP: PHP 8.4 Release Announcement’);

-var_dump($output); // string(13) "my-test-value"
+var_dump($components['host']);
+// string(7) "php.net"
PHP

                         ); ?>
@@ -68,29 +61,26 @@ PHP
                     <div class="php8-code phpcode">
                         <?php highlight_php_trimmed(
                                 <<<'PHP'
-$input = ' My test value. ';
+use Uri\Rfc3986\Uri;

-$output = $input
- |> trim(...)
- |> (fn($str) => str_replace(' ', '-', $str))
- |> (fn($str) => str_replace('.', '', $str))
- |> strtolower(...);
+$uri = new Uri('PHP: Manual Quick Reference’);

-var_dump($output); // string(13) "my-test-value"
+var_dump($uri->getHost());
+// string(7) "php.net"
PHP
                         ); ?>
                     </div>
                 </div>
             </div>
             <div class="php8-compare__content">
- <?= message('pipe_operator_description', $lang) ?>
+ <?= message('uri_extension_description', $lang) ?>
             </div>
         </div>

         <div class="php8-compare">
- <h2 class="php8-h2" id="uri_extension">
- <?= message('uri_extension_title', $lang) ?>
- <a class="php8-rfc" href="PHP: rfc:url_parsing_api;
+ <h2 class="php8-h2" id="pipe_operator">
+ <?= message('pipe_operator_title', $lang) ?>
+ <a class="php8-rfc" href="PHP: rfc:pipe-operator-v3;
             </h2>
             <div class="php8-compare__main">
                 <div class="php8-compare__block example-contents">
@@ -98,10 +88,17 @@ PHP
                     <div class="php8-code phpcode">
                         <?php highlight_php_trimmed(
                                 <<<'PHP'
-$components = parse_url('PHP: PHP 8.4 Release Announcement’);
+$input = ' My test value. ';

-var_dump($components['host']);
-// string(7) "php.net"
+$output = strtolower(
+ str_replace('.', '',
+ str_replace(' ', '-',
+ trim($input)
+ )
+ )
+);
+
+var_dump($output); // string(13) "my-test-value"
PHP

                         ); ?>
@@ -113,19 +110,22 @@ PHP
                     <div class="php8-code phpcode">
                         <?php highlight_php_trimmed(
                                 <<<'PHP'
-use Uri\Rfc3986\Uri;
+$input = ' My test value. ';

-$uri = new Uri('PHP: Manual Quick Reference’);
+$output = $input
+ |> 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
                         ); ?>
                     </div>
                 </div>
             </div>
             <div class="php8-compare__content">
- <?= message('uri_extension_description', $lang) ?>
+ <?= message('pipe_operator_description', $lang) ?>
             </div>
         </div>

@@ -254,18 +254,9 @@ PHP
                     <div class="php8-code phpcode">
                         <?php highlight_php_trimmed(
                                 <<<'PHP'
-$releases = [
- '8.5' => '2025-11-20',
- '8.4' => '2024-11-21',
- '8.3' => '2023-11-23',
- '8.2' => '2022-12-08',
-];
-
-$firstKey = array_key_first($releases);
-$newestDate = $releases[$firstKey];
-
-var_dump($newestDate);
-// string(10) "2025-11-20"
+$lastEvent = $events ===
+ ? null
+ : $events[array_key_last($events)];
PHP

                         ); ?>
@@ -277,17 +268,7 @@ PHP
                     <div class="php8-code phpcode">
                         <?php highlight_php_trimmed(
                                 <<<'PHP'
-$releases = [
- '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"
+$lastEvent = array_last($events);
PHP
                         ); ?>
                     </div>