mirror of
https://github.com/nikic/PHP-Parser.git
synced 2025-01-17 07:08:14 +01:00
Fix emulative lexer with default error handler
If no error handler is provided, explicitly create one, so we don't end up calling handleError() on null.
This commit is contained in:
parent
c23976a299
commit
fb2c3ac97c
@ -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);
|
||||
|
@ -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("<?php readonly /*");
|
||||
$lexer->getNextToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideTestLex
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user