mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-30 20:16:45 +00:00
Fix a warning
This commit is contained in:
+1
-1
@@ -321,7 +321,7 @@ class Lexer
|
||||
$this->moveCursor('...');
|
||||
}
|
||||
// arrow function
|
||||
elseif ('=' === $this->code[$this->cursor] && '>' === $this->code[$this->cursor + 1]) {
|
||||
elseif ('=' === $this->code[$this->cursor] && ($this->cursor + 1 < $this->end) && '>' === $this->code[$this->cursor + 1]) {
|
||||
$this->pushToken(Token::ARROW_TYPE, '=>');
|
||||
$this->moveCursor('=>');
|
||||
}
|
||||
|
||||
@@ -378,4 +378,27 @@ bar
|
||||
// can be executed without throwing any exceptions
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTemplateForErrorsAtTheEndOfTheStream
|
||||
*/
|
||||
public function testErrorsAtTheEndOfTheStream(string $template)
|
||||
{
|
||||
$lexer = new Lexer(new Environment($this->createMock(LoaderInterface::class)));
|
||||
set_error_handler(function () {
|
||||
$this->fail('Lexer should not emit warnings.');
|
||||
});
|
||||
try {
|
||||
$lexer->tokenize(new Source($template, 'index'));
|
||||
$this->addToAssertionCount(1);
|
||||
} finally {
|
||||
restore_error_handler();
|
||||
}
|
||||
}
|
||||
|
||||
public function getTemplateForErrorsAtTheEndOfTheStream()
|
||||
{
|
||||
yield ['{{ ='];
|
||||
yield ['{{ ..'];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user