Skip to content

Commit 7ba6000

Browse files
committed
bug symfony#25323 [ExpressionLanguage] throw an SyntaxError instead of an undefined index notice (Simperfit)
This PR was merged into the 2.7 branch. Discussion ---------- [ExpressionLanguage] throw an SyntaxError instead of an undefined index notice | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget to update UPGRADE-*.md files --> | Tests pass? | yes | Fixed tickets | symfony#25214 | License | MIT | Doc PR | none I think this is a bug when the components throws a notice instead of an exception. it's too early and too dark to see something outside so here is my couch : ![img_2915-2](https://user-images.githubusercontent.com/3451634/33592448-6b514050-d98b-11e7-8086-bc6e6b6e6e82.jpg) Commits ------- 78abc89 [ExpressionLanguage] throw an SyntaxError instead of letting a undefined index notice
2 parents 32b3db5 + 78abc89 commit 7ba6000

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/Symfony/Component/ExpressionLanguage/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();

src/Symfony/Component/ExpressionLanguage/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)