Skip to content

Commit

Permalink
Fix PHP 8 compatibility
Browse files Browse the repository at this point in the history
This is a fix to preserve current behavior, but this should be
changed towards doing the same as PHP 8 does.
  • Loading branch information
nikic committed Oct 19, 2019
1 parent 2f45e05 commit 0a80b2d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/PhpParser/Lexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,16 @@ private function errorMayHaveOccurred() : bool {
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();
}

Expand Down

0 comments on commit 0a80b2d

Please sign in to comment.