if (!empty($elements))
{
$this->parser->getStream()->expect(Twig_Token::OPERATOR_TYPE, ',');
+
+ // trailing ,?
+ if ($this->parser->getStream()->test(Twig_Token::OPERATOR_TYPE, ']'))
+ {
+ return new Twig_Node_Expression_Array($elements, $this->parser->getCurrentToken()->getLine());
+ }
}
// hash or array element?
{# elements can be any expression #}
{{ ['foo'|upper, bar|upper, bar == foo]|join(',') }}
+
+{# arrays can have a trailing , like in PHP #}
+{{
+ [
+ 1,
+ 2,
+ ]|join(',')
+}}
--DATA--
return array('bar' => 'bar', 'foo' => array('bar' => 'bar'))
--EXPECT--
FOO,BAR,
+
+
+1,2