Fix PHP 8 compatibility

This is a fix to preserve current behavior, but this should be
changed towards doing the same as PHP 8 does.
This commit is contained in:
Nikita Popov 2019-10-19 10:49:07 +02:00
parent 2f45e05042
commit 0a80b2d8ee

View File

@ -143,6 +143,16 @@ class Lexer
return true;
}
if (PHP_VERSION_ID >= 80000) {
// PHP 8 converts the "bad character" case into a parse error, rather than treating
// it as a lexing warning. To preserve previous behavior, we need to assume that an
// error occurred.
// TODO: We should handle this the same way as PHP 8: Only generate T_BAD_CHARACTER
// token here (for older PHP versions) and leave generationg of the actual parse error
// to the parser. This will also save the full token scan on PHP 8 here.
return true;
}
return null !== error_get_last();
}