Skip to content

Commit 3b28719

Browse files
author
Amrouche Hamza
committed
[ExpressionLanguage] throw an SyntaxError instead of letting a undefined index notice
1 parent 32de3de commit 3b28719

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Tests/ExpressionLanguageTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ public function testShortCircuitOperatorsCompile($expression, array $names, $exp
8484
$this->assertSame($expected, $result);
8585
}
8686

87+
/**
88+
* @expectedException \Symfony\Component\ExpressionLanguage\SyntaxError
89+
* @expectedExceptionMessage Unexpected end of expression around position 6 for expression `node.`.
90+
*/
91+
public function testParseThrowsInsteadOfNotice()
92+
{
93+
(new ExpressionLanguage())->parse('node.', array('node'));
94+
}
95+
8796
public function shortCircuitProviderEvaluate()
8897
{
8998
$object = $this->getMockBuilder('stdClass')->setMethods(array('foo'))->getMock();

TokenStream.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ public function __toString()
5050
*/
5151
public function next()
5252
{
53+
++$this->position;
54+
5355
if (!isset($this->tokens[$this->position])) {
5456
throw new SyntaxError('Unexpected end of expression', $this->current->cursor, $this->expression);
5557
}
5658

57-
++$this->position;
58-
5959
$this->current = $this->tokens[$this->position];
6060
}
6161

0 commit comments

Comments
 (0)