mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-11-30 04:29:15 +01:00
Make check in numeric literal separator emulator more precise
a) Don't check for !== false, preg_match() return 0 if there is no match. This effectively means that the check was always true. b) Check for hex characters only if there's an 0x prefix. 1_1 is very likely a numeric separator, but a_b might well be part of an identifier. Fixes #639.
This commit is contained in:
parent
64f4d5b619
commit
a2443aaefa
@ -21,7 +21,8 @@ final class NumericLiteralSeparatorEmulator implements TokenEmulatorInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
return preg_match('~[0-9a-f]_[0-9a-f]~i', $code) !== false;
|
||||
return preg_match('~[0-9]_[0-9]~', $code)
|
||||
|| preg_match('~0x[0-9a-f]+_[0-9a-f]~i', $code);
|
||||
}
|
||||
|
||||
public function emulate(string $code, array $tokens): array
|
||||
|
Loading…
Reference in New Issue
Block a user