Skip to content

Commit 3a62e02

Browse files
Merge branch '10.0'
2 parents 5853f83 + 544e9aa commit 3a62e02

File tree

1 file changed

+71
-99
lines changed

1 file changed

+71
-99
lines changed

src/Report/Html/Renderer/File.php

Lines changed: 71 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@
8484
use function array_merge;
8585
use function array_pop;
8686
use function array_unique;
87-
use function constant;
8887
use function count;
89-
use function defined;
9088
use function explode;
9189
use function file_get_contents;
9290
use function htmlspecialchars;
@@ -111,7 +109,76 @@ final class File extends Renderer
111109
/**
112110
* @psalm-var array<int,true>
113111
*/
114-
private static array $keywordTokens = [];
112+
private const KEYWORD_TOKENS = [
113+
T_ABSTRACT => true,
114+
T_ARRAY => true,
115+
T_AS => true,
116+
T_BREAK => true,
117+
T_CALLABLE => true,
118+
T_CASE => true,
119+
T_CATCH => true,
120+
T_CLASS => true,
121+
T_CLONE => true,
122+
T_CONST => true,
123+
T_CONTINUE => true,
124+
T_DECLARE => true,
125+
T_DEFAULT => true,
126+
T_DO => true,
127+
T_ECHO => true,
128+
T_ELSE => true,
129+
T_ELSEIF => true,
130+
T_EMPTY => true,
131+
T_ENDDECLARE => true,
132+
T_ENDFOR => true,
133+
T_ENDFOREACH => true,
134+
T_ENDIF => true,
135+
T_ENDSWITCH => true,
136+
T_ENDWHILE => true,
137+
T_ENUM => true,
138+
T_EVAL => true,
139+
T_EXIT => true,
140+
T_EXTENDS => true,
141+
T_FINAL => true,
142+
T_FINALLY => true,
143+
T_FN => true,
144+
T_FOR => true,
145+
T_FOREACH => true,
146+
T_FUNCTION => true,
147+
T_GLOBAL => true,
148+
T_GOTO => true,
149+
T_HALT_COMPILER => true,
150+
T_IF => true,
151+
T_IMPLEMENTS => true,
152+
T_INCLUDE => true,
153+
T_INCLUDE_ONCE => true,
154+
T_INSTANCEOF => true,
155+
T_INSTEADOF => true,
156+
T_INTERFACE => true,
157+
T_ISSET => true,
158+
T_LIST => true,
159+
T_MATCH => true,
160+
T_NAMESPACE => true,
161+
T_NEW => true,
162+
T_PRINT => true,
163+
T_PRIVATE => true,
164+
T_PROTECTED => true,
165+
T_PUBLIC => true,
166+
T_READONLY => true,
167+
T_REQUIRE => true,
168+
T_REQUIRE_ONCE => true,
169+
T_RETURN => true,
170+
T_STATIC => true,
171+
T_SWITCH => true,
172+
T_THROW => true,
173+
T_TRAIT => true,
174+
T_TRY => true,
175+
T_UNSET => true,
176+
T_USE => true,
177+
T_VAR => true,
178+
T_WHILE => true,
179+
T_YIELD => true,
180+
T_YIELD_FROM => true,
181+
];
115182
private static array $formattedSourceCache = [];
116183
private int $htmlSpecialCharsFlags = ENT_COMPAT | ENT_HTML401 | ENT_SUBSTITUTE;
117184

@@ -1032,101 +1099,6 @@ private function isInlineHtml(int $token): bool
10321099

10331100
private function isKeyword(int $token): bool
10341101
{
1035-
return isset(self::keywordTokens()[$token]);
1036-
}
1037-
1038-
/**
1039-
* @psalm-return array<int,true>
1040-
*/
1041-
private static function keywordTokens(): array
1042-
{
1043-
if (self::$keywordTokens !== []) {
1044-
return self::$keywordTokens;
1045-
}
1046-
1047-
self::$keywordTokens = [
1048-
T_ABSTRACT => true,
1049-
T_ARRAY => true,
1050-
T_AS => true,
1051-
T_BREAK => true,
1052-
T_CALLABLE => true,
1053-
T_CASE => true,
1054-
T_CATCH => true,
1055-
T_CLASS => true,
1056-
T_CLONE => true,
1057-
T_CONST => true,
1058-
T_CONTINUE => true,
1059-
T_DECLARE => true,
1060-
T_DEFAULT => true,
1061-
T_DO => true,
1062-
T_ECHO => true,
1063-
T_ELSE => true,
1064-
T_ELSEIF => true,
1065-
T_EMPTY => true,
1066-
T_ENDDECLARE => true,
1067-
T_ENDFOR => true,
1068-
T_ENDFOREACH => true,
1069-
T_ENDIF => true,
1070-
T_ENDSWITCH => true,
1071-
T_ENDWHILE => true,
1072-
T_EVAL => true,
1073-
T_EXIT => true,
1074-
T_EXTENDS => true,
1075-
T_FINAL => true,
1076-
T_FINALLY => true,
1077-
T_FOR => true,
1078-
T_FOREACH => true,
1079-
T_FUNCTION => true,
1080-
T_GLOBAL => true,
1081-
T_GOTO => true,
1082-
T_HALT_COMPILER => true,
1083-
T_IF => true,
1084-
T_IMPLEMENTS => true,
1085-
T_INCLUDE => true,
1086-
T_INCLUDE_ONCE => true,
1087-
T_INSTANCEOF => true,
1088-
T_INSTEADOF => true,
1089-
T_INTERFACE => true,
1090-
T_ISSET => true,
1091-
T_LIST => true,
1092-
T_NAMESPACE => true,
1093-
T_NEW => true,
1094-
T_PRINT => true,
1095-
T_PRIVATE => true,
1096-
T_PROTECTED => true,
1097-
T_PUBLIC => true,
1098-
T_REQUIRE => true,
1099-
T_REQUIRE_ONCE => true,
1100-
T_RETURN => true,
1101-
T_STATIC => true,
1102-
T_SWITCH => true,
1103-
T_THROW => true,
1104-
T_TRAIT => true,
1105-
T_TRY => true,
1106-
T_UNSET => true,
1107-
T_USE => true,
1108-
T_VAR => true,
1109-
T_WHILE => true,
1110-
T_YIELD => true,
1111-
T_YIELD_FROM => true,
1112-
];
1113-
1114-
if (defined('T_FN')) {
1115-
self::$keywordTokens[constant('T_FN')] = true;
1116-
}
1117-
1118-
if (defined('T_MATCH')) {
1119-
self::$keywordTokens[constant('T_MATCH')] = true;
1120-
}
1121-
1122-
if (defined('T_ENUM')) {
1123-
self::$keywordTokens[constant('T_ENUM')] = true;
1124-
}
1125-
1126-
if (defined('T_READONLY')) {
1127-
self::$keywordTokens[constant('T_READONLY')] = true;
1128-
}
1129-
1130-
return self::$keywordTokens;
1102+
return isset(self::KEYWORD_TOKENS[$token]);
11311103
}
11321104
}

0 commit comments

Comments
 (0)