bug #10605 [ExpressionLanguage] Strict in_array check in Parser.php (parnas)
This PR was submitted for the master branch but it was merged into the 2.4 branch instead (closes #10605). Discussion ---------- [ExpressionLanguage] Strict in_array check in Parser.php | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Otherwise it doesn't throw an exception for the cases when passed parameters array includes zero key (and that will result in the PHP Notice down the road). Commits -------154c4a5
[ExpressionLanguage] Test for the non-strict in_array check in parsePrimaryExpression in Parser.phpe465135
Strict in_array check in Parser.php
This commit is contained in:
commit
e210082b2c
@ -190,7 +190,7 @@ class Parser
|
|||||||
|
|
||||||
$node = new Node\FunctionNode($token->value, $this->parseArguments());
|
$node = new Node\FunctionNode($token->value, $this->parseArguments());
|
||||||
} else {
|
} else {
|
||||||
if (!in_array($token->value, $this->names)) {
|
if (!in_array($token->value, $this->names, true)) {
|
||||||
throw new SyntaxError(sprintf('Variable "%s" is not valid', $token->value), $token->cursor);
|
throw new SyntaxError(sprintf('Variable "%s" is not valid', $token->value), $token->cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,17 @@ class ParserTest extends \PHPUnit_Framework_TestCase
|
|||||||
$parser->parse($lexer->tokenize('foo'));
|
$parser->parse($lexer->tokenize('foo'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Symfony\Component\ExpressionLanguage\SyntaxError
|
||||||
|
* @expectedExceptionMessage Variable "foo" is not valid around position 1.
|
||||||
|
*/
|
||||||
|
public function testParseWithZeroInNames()
|
||||||
|
{
|
||||||
|
$lexer = new Lexer();
|
||||||
|
$parser = new Parser(array());
|
||||||
|
$parser->parse($lexer->tokenize('foo'), array(0));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider getParseData
|
* @dataProvider getParseData
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user