Author: Sara Golemon (sgolemon)
Date: 2021-05-20T15:04:25Z
Commit:
https://github.com/php/web-php/commit/bfb30b5a2d1dba6ae498283ec8b67902154d1afd
Raw diff:
https://github.com/php/web-php/commit/bfb30b5a2d1dba6ae498283ec8b67902154d1afd.diff
Handle ?:, ??, and ??= in index.php
Changed paths:
M error.php
M index.php
Diff:
diff --git a/error.php b/error.php
index 394c83267..ec996f520 100644
--- a/error.php
+++ b/error.php
@@ -319,9 +319,10 @@
"splat" => "functions.arguments",
"arrow" => "functions.arrow",
"fn" => "functions.arrow",
- "?:" => "language.operators.comparison",
- "??" => "language.operators.comparison",
- "??=" => "language.operators.assignment",
+ // ?:, ??, ??=
+ // These shortcuts can not be captured here since they
+ // don't actually produce a 404 error.
+ // Instead, we have a small check in index.php directly.
"dowhile" => "control-structures.do.while",
diff --git a/index.php b/index.php
index ad1977842..84dd7e3d3 100644
--- a/index.php
+++ b/index.php
@@ -1,4 +1,17 @@
<?php // vim: et
+(function($uri) {
+ // Special redirect cases not able to be captured in error.php
+ $shortcuts = [
+ '/?:' =>
'/language.operators.comparison#language.operators.comparison.ternary',
+ '/??' =>
'/language.operators.comparison#language.operators.comparison.coalesce',
+ '/??=' =>
'/language.operators.assignment#language.operators.assignment.other',
+ ];
+ if (isset($shortcuts[$uri])) {
+ header("Location: {$shortcuts[$uri]}");
+ exit;
+ }
+})($_SERVER['REQUEST_URI'] ?? '');
+
// Get the modification date of this PHP file
$timestamps = array(@getlastmod());
--
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php