Author: Sergey Panteleev (saundefined) Date: 2025-11-07T16:23:52+03:00 Commit: https://github.com/php/web-php/commit/f3a309040416062ee20a3d80af56c6ea23762aae Raw diff: https://github.com/php/web-php/commit/f3a309040416062ee20a3d80af56c6ea23762aae.diff
Apply suggestions from code review Co-authored-by: Tim Düsterhus <[email protected]> Changed paths: M releases/8.5/languages/en.php M releases/8.5/release.inc Diff: diff --git a/releases/8.5/languages/en.php b/releases/8.5/languages/en.php index 7f3011b05c..9c58cdec5f 100644 --- a/releases/8.5/languages/en.php +++ b/releases/8.5/languages/en.php @@ -1,10 +1,10 @@ <?php return [ - '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.', + 'common_header' => 'PHP 8.5 is a major update of the PHP language, with new features including the URI Extension, Pipe Operator, 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, with new features including the Pipe Operator, URI extension, and support for modifying properties while cloning.', + 'main_subtitle' => 'PHP 8.5 is a major update of the PHP language, with new features including the URI Extension, Pipe Operator, and support for modifying properties while cloning.', 'upgrade_now' => 'Upgrade to PHP 8.5', 'pipe_operator_title' => 'Pipe Operator', diff --git a/releases/8.5/release.inc b/releases/8.5/release.inc index 460b26399a..246c654a33 100644 --- a/releases/8.5/release.inc +++ b/releases/8.5/release.inc @@ -88,17 +88,17 @@ PHP <div class="php8-code phpcode"> <?php highlight_php_trimmed( <<<'PHP' -$input = ' My test value. '; +$title = ' PHP 8.5 Released '; -$output = strtolower( +$slug = strtolower( str_replace('.', '', str_replace(' ', '-', - trim($input) + trim($title) ) ) ); -var_dump($output); // string(13) "my-test-value" +var_dump($slug); // string(15) "php-85-released" PHP ); ?> @@ -110,15 +110,15 @@ PHP <div class="php8-code phpcode"> <?php highlight_php_trimmed( <<<'PHP' -$input = ' My test value. '; +$title = ' PHP 8.5 Released '; -$output = $input +$slug = $title |> trim(...) |> (fn($str) => str_replace(' ', '-', $str)) |> (fn($str) => str_replace('.', '', $str)) |> strtolower(...); -var_dump($output); // string(13) "my-test-value" +var_dump($slug); // string(15) "php-85-released" PHP ); ?> </div> @@ -254,9 +254,34 @@ PHP <div class="php8-code phpcode"> <?php highlight_php_trimmed( <<<'PHP' -$lastEvent = $events === [] - ? null - : $events[array_key_last($events)]; +final class Stopwatch +{ + private int $start; + public private(set) array $laps = []; + + public function __construct() + { + $this->start = hrtime(true); + } + + public function stopLap() + { + $fromStart = hrtime(true) - $this->start; + $lastLap = $this->laps !== [] + ? $this->laps[array_key_last($this->laps)] + : 0; + $lapDuration = $fromStart - $lastLap; + + $this->laps[] = $fromStart; + + return $lapDuration; + } +} + +$watch = new Stopwatch(); +for ($i = 1; $i < 5; $i++) { + printf("Lap #%d took %dns\n", $i, $watch->stopLap()); +} PHP ); ?> @@ -268,7 +293,32 @@ PHP <div class="php8-code phpcode"> <?php highlight_php_trimmed( <<<'PHP' -$lastEvent = array_last($events); +final class Stopwatch +{ + private int $start; + public private(set) array $laps = []; + + public function __construct() + { + $this->start = hrtime(true); + } + + public function stopLap() + { + $fromStart = hrtime(true) - $this->start; + $lastLap = array_last($this->laps) ?? 0; + $lapDuration = $fromStart - $lastLap; + + $this->laps[] = $fromStart; + + return $lapDuration; + } +} + +$watch = new Stopwatch(); +for ($i = 1; $i < 5; $i++) { + printf("Lap #%d took %dns\n", $i, $watch->stopLap()); +} PHP ); ?> </div>
