diff --git a/CHANGELOG.md b/CHANGELOG.md index 530bd871..5d6fa37b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ Version 4.7.0-dev * [PHP 8.0] Added support for match expressions. These are represented using a new `Expr\Match_` containing `MatchArm`s. +### Fixed + +* Fixed missing error for unterminated comment with trailing newline (#688). + Version 4.6.0 (2020-07-02) -------------------------- diff --git a/lib/PhpParser/Lexer.php b/lib/PhpParser/Lexer.php index da36f2f0..c87811f5 100644 --- a/lib/PhpParser/Lexer.php +++ b/lib/PhpParser/Lexer.php @@ -152,7 +152,8 @@ class Lexer $this->handleInvalidCharacterRange($filePos, $filePos + 1, $line, $errorHandler); } - if ($token[0] === \T_COMMENT && preg_match('/(\r\n|\n|\r)$/D', $token[1], $matches)) { + if ($token[0] === \T_COMMENT && substr($token[1], 0, 2) !== '/*' + && preg_match('/(\r\n|\n|\r)$/D', $token[1], $matches)) { $trailingNewline = $matches[0]; $token[1] = substr($token[1], 0, -strlen($trailingNewline)); $this->tokens[$i] = $token; diff --git a/test/PhpParser/LexerTest.php b/test/PhpParser/LexerTest.php index 2e487d58..79aea443 100644 --- a/test/PhpParser/LexerTest.php +++ b/test/PhpParser/LexerTest.php @@ -35,6 +35,7 @@ class LexerTest extends \PHPUnit\Framework\TestCase public function provideTestError() { return [ ["