Skip to content

Commit

Permalink
Check for tokens with non-integer ID
Browse files Browse the repository at this point in the history
Fixes #974.
  • Loading branch information
nikic committed Jan 10, 2024
1 parent d619c8b commit ff095c3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/PhpParser/compatibility_tokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ function defineCompatibilityTokens(): void {
foreach ($compatTokens as $token) {
if (\defined($token)) {
$tokenId = \constant($token);
if (!\is_int($tokenId)) {
throw new \Error(sprintf(
'Token %s has ID of type %s, should be int. ' .
'You may be using a library with broken token emulation',
$token, \gettype($tokenId)
));
}
$clashingToken = $usedTokenIds[$tokenId] ?? null;
if ($clashingToken !== null) {
throw new \Error(sprintf(
Expand Down

0 comments on commit ff095c3

Please sign in to comment.