public function Twig_ExpressionParser::parseArrayExpression in Translation template extractor 6.3
Same name and namespace in other branches
- 7.3 vendor/Twig/ExpressionParser.php \Twig_ExpressionParser::parseArrayExpression()
1 call to Twig_ExpressionParser::parseArrayExpression()
File
- vendor/
Twig/ ExpressionParser.php, line 210
Class
- Twig_ExpressionParser
- Parses expressions.
Code
public function parseArrayExpression() {
$stream = $this->parser
->getStream();
$stream
->expect(Twig_Token::PUNCTUATION_TYPE, '[', 'An array element was expected');
$node = new Twig_Node_Expression_Array(array(), $stream
->getCurrent()
->getLine());
$first = true;
while (!$stream
->test(Twig_Token::PUNCTUATION_TYPE, ']')) {
if (!$first) {
$stream
->expect(Twig_Token::PUNCTUATION_TYPE, ',', 'An array element must be followed by a comma');
// trailing ,?
if ($stream
->test(Twig_Token::PUNCTUATION_TYPE, ']')) {
break;
}
}
$first = false;
$node
->addElement($this
->parseExpression());
}
$stream
->expect(Twig_Token::PUNCTUATION_TYPE, ']', 'An opened array is not properly closed');
return $node;
}