Skip to content

Commit 544e9aa

Browse files
Use constant now that we do not have to deal with different versions
1 parent 4e4dd98 commit 544e9aa

File tree

1 file changed

+71
-85
lines changed

1 file changed

+71
-85
lines changed

src/Report/Html/Renderer/File.php

Lines changed: 71 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,76 @@ final class File extends Renderer
109109
/**
110110
* @psalm-var array<int,true>
111111
*/
112-
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+
];
113182
private static array $formattedSourceCache = [];
114183
private int $htmlSpecialCharsFlags = ENT_COMPAT | ENT_HTML401 | ENT_SUBSTITUTE;
115184

@@ -1030,89 +1099,6 @@ private function isInlineHtml(int $token): bool
10301099

10311100
private function isKeyword(int $token): bool
10321101
{
1033-
return isset(self::keywordTokens()[$token]);
1034-
}
1035-
1036-
/**
1037-
* @psalm-return array<int,true>
1038-
*/
1039-
private static function keywordTokens(): array
1040-
{
1041-
if (self::$keywordTokens !== []) {
1042-
return self::$keywordTokens;
1043-
}
1044-
1045-
self::$keywordTokens = [
1046-
T_ABSTRACT => true,
1047-
T_ARRAY => true,
1048-
T_AS => true,
1049-
T_BREAK => true,
1050-
T_CALLABLE => true,
1051-
T_CASE => true,
1052-
T_CATCH => true,
1053-
T_CLASS => true,
1054-
T_CLONE => true,
1055-
T_CONST => true,
1056-
T_CONTINUE => true,
1057-
T_DECLARE => true,
1058-
T_DEFAULT => true,
1059-
T_DO => true,
1060-
T_ECHO => true,
1061-
T_ELSE => true,
1062-
T_ELSEIF => true,
1063-
T_EMPTY => true,
1064-
T_ENDDECLARE => true,
1065-
T_ENDFOR => true,
1066-
T_ENDFOREACH => true,
1067-
T_ENDIF => true,
1068-
T_ENDSWITCH => true,
1069-
T_ENDWHILE => true,
1070-
T_ENUM => true,
1071-
T_EVAL => true,
1072-
T_EXIT => true,
1073-
T_EXTENDS => true,
1074-
T_FINAL => true,
1075-
T_FINALLY => true,
1076-
T_FN => 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_MATCH => true,
1093-
T_NAMESPACE => true,
1094-
T_NEW => true,
1095-
T_PRINT => true,
1096-
T_PRIVATE => true,
1097-
T_PROTECTED => true,
1098-
T_PUBLIC => true,
1099-
T_READONLY => true,
1100-
T_REQUIRE => true,
1101-
T_REQUIRE_ONCE => true,
1102-
T_RETURN => true,
1103-
T_STATIC => true,
1104-
T_SWITCH => true,
1105-
T_THROW => true,
1106-
T_TRAIT => true,
1107-
T_TRY => true,
1108-
T_UNSET => true,
1109-
T_USE => true,
1110-
T_VAR => true,
1111-
T_WHILE => true,
1112-
T_YIELD => true,
1113-
T_YIELD_FROM => true,
1114-
];
1115-
1116-
return self::$keywordTokens;
1102+
return isset(self::KEYWORD_TOKENS[$token]);
11171103
}
11181104
}

0 commit comments

Comments
 (0)