Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8822114

Browse filesBrowse files
author
Amrouche Hamza
committed
[ExpressionLanguage] throw an SyntaxError instead of letting a undefined index notice
1 parent 6eedbb5 commit 8822114
Copy full SHA for 8822114

File tree

2 files changed

+14
-0
lines changed
Filter options

2 files changed

+14
-0
lines changed

‎src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ 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+
$language = new ExpressionLanguage();
94+
$parsedExpression = $language->parse('node.', array('node'));
95+
}
96+
8797
public function shortCircuitProviderEvaluate()
8898
{
8999
$object = $this->getMockBuilder('stdClass')->setMethods(array('foo'))->getMock();

‎src/Symfony/Component/ExpressionLanguage/TokenStream.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/ExpressionLanguage/TokenStream.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ public function next()
5656

5757
++$this->position;
5858

59+
if (!isset($this->tokens[$this->position])) {
60+
throw new SyntaxError('Unexpected end of expression', $this->current->cursor, $this->expression);
61+
}
62+
5963
$this->current = $this->tokens[$this->position];
6064
}
6165

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.