diff --git a/lib/PhpParser/Lexer/Emulative.php b/lib/PhpParser/Lexer/Emulative.php index 054cc734..8993144d 100644 --- a/lib/PhpParser/Lexer/Emulative.php +++ b/lib/PhpParser/Lexer/Emulative.php @@ -85,6 +85,10 @@ class Emulative extends Lexer { return; } + if ($errorHandler === null) { + $errorHandler = new ErrorHandler\Throwing(); + } + $this->patches = []; foreach ($emulators as $emulator) { $code = $emulator->preprocessCode($code, $this->patches); diff --git a/test/PhpParser/LexerTest.php b/test/PhpParser/LexerTest.php index 2d6b8c92..4538280c 100644 --- a/test/PhpParser/LexerTest.php +++ b/test/PhpParser/LexerTest.php @@ -47,6 +47,14 @@ class LexerTest extends \PHPUnit\Framework\TestCase { ]; } + public function testDefaultErrorHandler() { + $this->expectException(Error::class); + $this->expectExceptionMessage('Unterminated comment on line 1'); + $lexer = $this->getLexer(); + $lexer->startLexing("getNextToken(); + } + /** * @dataProvider provideTestLex */