diff --git a/include/errors.inc b/include/errors.inc index b21a75d780..90f2e3b2e3 100644 --- a/include/errors.inc +++ b/include/errors.inc @@ -473,6 +473,16 @@ function is_known_term(string $term): ?string { 'yield from' => 'language.generators.syntax.php#control-structures.yield.from', 'yield' => 'language.generators.syntax.php#control-structures.yield', + '__line__' => 'language.constants.magic.php', + '__file__' => 'language.constants.magic.php', + '__dir__' => 'language.constants.magic.php', + '__function__' => 'language.constants.magic.php', + '__class__' => 'language.constants.magic.php', + '__trait__' => 'language.constants.magic.php', + '__method__' => 'language.constants.magic.php', + '__property__' => 'language.constants.magic.php', + '__namespace__' => 'language.constants.magic.php', + '__COMPILER_HALT_OFFSET__' => 'function.halt-compiler.php', 'DEFAULT_INCLUDE_PATH' => 'reserved.constants.php', 'E_ALL' => 'errorfunc.constants.php', diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 1be2fec354..a923c7d13f 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1815,7 +1815,7 @@ parameters: - message: '#^Variable \$LANG might not be defined\.$#' identifier: variable.undefined - count: 1 + count: 2 path: public/manual-lookup.php - diff --git a/public/error.php b/public/error.php index 34b0e0a51f..ee421bc8ea 100644 --- a/public/error.php +++ b/public/error.php @@ -493,6 +493,16 @@ "language.oop5.reflection" => "book.reflection", // BC "::" => "language.oop5.paamayim-nekudotayim", + "__line__" => "language.constants.magic", + "__file__" => "language.constants.magic", + "__dir__" => "language.constants.magic", + "__function__" => "language.constants.magic", + "__class__" => "language.constants.magic", + "__trait__" => "language.constants.magic", + "__method__" => "language.constants.magic", + "__property__" => "language.constants.magic", + "__namespace__" => "language.constants.magic", + "__construct" => "language.oop5.decon", "__destruct" => "language.oop5.decon", "__call" => "language.oop5.overloading", diff --git a/public/manual-lookup.php b/public/manual-lookup.php index e2a2146fc1..39b0b25782 100644 --- a/public/manual-lookup.php +++ b/public/manual-lookup.php @@ -27,6 +27,12 @@ if ($function) { $function = strtolower($function); + // Check known terms and variables (operators like @, magic constants, etc.) + $path = is_known_variable(str_replace('_', '-', $function)) ?? is_known_term($function); + if ($path !== null) { + mirror_redirect("/manual/$LANG/$path"); + } + // Try to find appropriate manual page if ($file = find_manual_page($LANG, $function)) { mirror_redirect($file);