Skip to content

[ExpressionLanguage] throw an SyntaxError instead of an undefined index notice #25323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ public function testShortCircuitOperatorsCompile($expression, array $names, $exp
$this->assertSame($expected, $result);
}

/**
* @expectedException \Symfony\Component\ExpressionLanguage\SyntaxError
* @expectedExceptionMessage Unexpected end of expression around position 6 for expression `node.`.
*/
public function testParseThrowsInsteadOfNotice()
{
(new ExpressionLanguage())->parse('node.', array('node'));
}

public function shortCircuitProviderEvaluate()
{
$object = $this->getMockBuilder('stdClass')->setMethods(array('foo'))->getMock();
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/ExpressionLanguage/TokenStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ public function __toString()
*/
public function next()
{
++$this->position;

if (!isset($this->tokens[$this->position])) {
throw new SyntaxError('Unexpected end of expression', $this->current->cursor, $this->expression);
}

++$this->position;

$this->current = $this->tokens[$this->position];
}

Expand Down