4 * This file is part of Twig.
9 * For the full copyright and license information, please view the LICENSE
10 * file that was distributed with this source code.
16 * This parser implements a "Precedence climbing" algorithm.
18 * @see http://www.engr.mun.ca/~theo/Misc/exp_parsing.htm
19 * @see http://en.wikipedia.org/wiki/Operator-precedence_parser
21 * @author Fabien Potencier <fabien@symfony.com>
25 class Twig_ExpressionParser
27 const OPERATOR_LEFT = 1;
28 const OPERATOR_RIGHT = 2;
31 protected $unaryOperators;
32 protected $binaryOperators;
36 public function __construct(Twig_Parser $parser, $env = null)
38 $this->parser = $parser;
40 if ($env instanceof Twig_Environment) {
42 $this->unaryOperators = $env->getUnaryOperators();
43 $this->binaryOperators = $env->getBinaryOperators();
45 @trigger_error('Passing the operators as constructor arguments to '.__METHOD__.' is deprecated since version 1.27. Pass the environment instead.', E_USER_DEPRECATED);
47 $this->env = $parser->getEnvironment();
48 $this->unaryOperators = func_get_arg(1);
49 $this->binaryOperators = func_get_arg(2);
53 public function parseExpression($precedence = 0)
55 $expr = $this->getPrimary();
56 $token = $this->parser->getCurrentToken();
57 while ($this->isBinary($token) && $this->binaryOperators[$token->getValue()]['precedence'] >= $precedence) {
58 $op = $this->binaryOperators[$token->getValue()];
59 $this->parser->getStream()->next();
61 if ('is not' === $token->getValue()) {
62 $expr = $this->parseNotTestExpression($expr);
63 } elseif ('is' === $token->getValue()) {
64 $expr = $this->parseTestExpression($expr);
65 } elseif (isset($op['callable'])) {
66 $expr = call_user_func($op['callable'], $this->parser, $expr);
68 $expr1 = $this->parseExpression(self::OPERATOR_LEFT === $op['associativity'] ? $op['precedence'] + 1 : $op['precedence']);
69 $class = $op['class'];
70 $expr = new $class($expr, $expr1, $token->getLine());
73 $token = $this->parser->getCurrentToken();
76 if (0 === $precedence) {
77 return $this->parseConditionalExpression($expr);
83 protected function getPrimary()
85 $token = $this->parser->getCurrentToken();
87 if ($this->isUnary($token)) {
88 $operator = $this->unaryOperators[$token->getValue()];
89 $this->parser->getStream()->next();
90 $expr = $this->parseExpression($operator['precedence']);
91 $class = $operator['class'];
93 return $this->parsePostfixExpression(new $class($expr, $token->getLine()));
94 } elseif ($token->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
95 $this->parser->getStream()->next();
96 $expr = $this->parseExpression();
97 $this->parser->getStream()->expect(Twig_Token::PUNCTUATION_TYPE, ')', 'An opened parenthesis is not properly closed');
99 return $this->parsePostfixExpression($expr);
102 return $this->parsePrimaryExpression();
105 protected function parseConditionalExpression($expr)
107 while ($this->parser->getStream()->nextIf(Twig_Token::PUNCTUATION_TYPE, '?')) {
108 if (!$this->parser->getStream()->nextIf(Twig_Token::PUNCTUATION_TYPE, ':')) {
109 $expr2 = $this->parseExpression();
110 if ($this->parser->getStream()->nextIf(Twig_Token::PUNCTUATION_TYPE, ':')) {
111 $expr3 = $this->parseExpression();
113 $expr3 = new Twig_Node_Expression_Constant('', $this->parser->getCurrentToken()->getLine());
117 $expr3 = $this->parseExpression();
120 $expr = new Twig_Node_Expression_Conditional($expr, $expr2, $expr3, $this->parser->getCurrentToken()->getLine());
126 protected function isUnary(Twig_Token $token)
128 return $token->test(Twig_Token::OPERATOR_TYPE) && isset($this->unaryOperators[$token->getValue()]);
131 protected function isBinary(Twig_Token $token)
133 return $token->test(Twig_Token::OPERATOR_TYPE) && isset($this->binaryOperators[$token->getValue()]);
136 public function parsePrimaryExpression()
138 $token = $this->parser->getCurrentToken();
139 switch ($token->getType()) {
140 case Twig_Token::NAME_TYPE:
141 $this->parser->getStream()->next();
142 switch ($token->getValue()) {
145 $node = new Twig_Node_Expression_Constant(true, $token->getLine());
150 $node = new Twig_Node_Expression_Constant(false, $token->getLine());
157 $node = new Twig_Node_Expression_Constant(null, $token->getLine());
161 if ('(' === $this->parser->getCurrentToken()->getValue()) {
162 $node = $this->getFunctionNode($token->getValue(), $token->getLine());
164 $node = new Twig_Node_Expression_Name($token->getValue(), $token->getLine());
169 case Twig_Token::NUMBER_TYPE:
170 $this->parser->getStream()->next();
171 $node = new Twig_Node_Expression_Constant($token->getValue(), $token->getLine());
174 case Twig_Token::STRING_TYPE:
175 case Twig_Token::INTERPOLATION_START_TYPE:
176 $node = $this->parseStringExpression();
179 case Twig_Token::OPERATOR_TYPE:
180 if (preg_match(Twig_Lexer::REGEX_NAME, $token->getValue(), $matches) && $matches[0] == $token->getValue()) {
181 // in this context, string operators are variable names
182 $this->parser->getStream()->next();
183 $node = new Twig_Node_Expression_Name($token->getValue(), $token->getLine());
185 } elseif (isset($this->unaryOperators[$token->getValue()])) {
186 $class = $this->unaryOperators[$token->getValue()]['class'];
188 $ref = new ReflectionClass($class);
189 $negClass = 'Twig_Node_Expression_Unary_Neg';
190 $posClass = 'Twig_Node_Expression_Unary_Pos';
191 if (!(in_array($ref->getName(), array($negClass, $posClass)) || $ref->isSubclassOf($negClass) || $ref->isSubclassOf($posClass))) {
192 throw new Twig_Error_Syntax(sprintf('Unexpected unary operator "%s".', $token->getValue()), $token->getLine(), $this->parser->getStream()->getSourceContext());
195 $this->parser->getStream()->next();
196 $expr = $this->parsePrimaryExpression();
198 $node = new $class($expr, $token->getLine());
203 if ($token->test(Twig_Token::PUNCTUATION_TYPE, '[')) {
204 $node = $this->parseArrayExpression();
205 } elseif ($token->test(Twig_Token::PUNCTUATION_TYPE, '{')) {
206 $node = $this->parseHashExpression();
207 } elseif ($token->test(Twig_Token::OPERATOR_TYPE, '=') && ($this->parser->getStream()->look(-1)->getValue() === '==' || $this->parser->getStream()->look(-1)->getValue() === '!=')) {
208 throw new Twig_Error_Syntax(sprintf('Unexpected operator of value "%s". Did you try to use "===" or "!==" for strict comparison? Use "is same as(value)" instead.', $token->getValue()), $token->getLine(), $this->parser->getStream()->getSourceContext());
210 throw new Twig_Error_Syntax(sprintf('Unexpected token "%s" of value "%s".', Twig_Token::typeToEnglish($token->getType()), $token->getValue()), $token->getLine(), $this->parser->getStream()->getSourceContext());
214 return $this->parsePostfixExpression($node);
217 public function parseStringExpression()
219 $stream = $this->parser->getStream();
222 // a string cannot be followed by another string in a single expression
223 $nextCanBeString = true;
225 if ($nextCanBeString && $token = $stream->nextIf(Twig_Token::STRING_TYPE)) {
226 $nodes[] = new Twig_Node_Expression_Constant($token->getValue(), $token->getLine());
227 $nextCanBeString = false;
228 } elseif ($stream->nextIf(Twig_Token::INTERPOLATION_START_TYPE)) {
229 $nodes[] = $this->parseExpression();
230 $stream->expect(Twig_Token::INTERPOLATION_END_TYPE);
231 $nextCanBeString = true;
237 $expr = array_shift($nodes);
238 foreach ($nodes as $node) {
239 $expr = new Twig_Node_Expression_Binary_Concat($expr, $node, $node->getTemplateLine());
245 public function parseArrayExpression()
247 $stream = $this->parser->getStream();
248 $stream->expect(Twig_Token::PUNCTUATION_TYPE, '[', 'An array element was expected');
250 $node = new Twig_Node_Expression_Array(array(), $stream->getCurrent()->getLine());
252 while (!$stream->test(Twig_Token::PUNCTUATION_TYPE, ']')) {
254 $stream->expect(Twig_Token::PUNCTUATION_TYPE, ',', 'An array element must be followed by a comma');
257 if ($stream->test(Twig_Token::PUNCTUATION_TYPE, ']')) {
263 $node->addElement($this->parseExpression());
265 $stream->expect(Twig_Token::PUNCTUATION_TYPE, ']', 'An opened array is not properly closed');
270 public function parseHashExpression()
272 $stream = $this->parser->getStream();
273 $stream->expect(Twig_Token::PUNCTUATION_TYPE, '{', 'A hash element was expected');
275 $node = new Twig_Node_Expression_Array(array(), $stream->getCurrent()->getLine());
277 while (!$stream->test(Twig_Token::PUNCTUATION_TYPE, '}')) {
279 $stream->expect(Twig_Token::PUNCTUATION_TYPE, ',', 'A hash value must be followed by a comma');
282 if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '}')) {
288 // a hash key can be:
292 // * a name, which is equivalent to a string -- a
293 // * an expression, which must be enclosed in parentheses -- (1 + 2)
294 if (($token = $stream->nextIf(Twig_Token::STRING_TYPE)) || ($token = $stream->nextIf(Twig_Token::NAME_TYPE)) || $token = $stream->nextIf(Twig_Token::NUMBER_TYPE)) {
295 $key = new Twig_Node_Expression_Constant($token->getValue(), $token->getLine());
296 } elseif ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
297 $key = $this->parseExpression();
299 $current = $stream->getCurrent();
301 throw new Twig_Error_Syntax(sprintf('A hash key must be a quoted string, a number, a name, or an expression enclosed in parentheses (unexpected token "%s" of value "%s".', Twig_Token::typeToEnglish($current->getType()), $current->getValue()), $current->getLine(), $stream->getSourceContext());
304 $stream->expect(Twig_Token::PUNCTUATION_TYPE, ':', 'A hash key must be followed by a colon (:)');
305 $value = $this->parseExpression();
307 $node->addElement($value, $key);
309 $stream->expect(Twig_Token::PUNCTUATION_TYPE, '}', 'An opened hash is not properly closed');
314 public function parsePostfixExpression($node)
317 $token = $this->parser->getCurrentToken();
318 if ($token->getType() == Twig_Token::PUNCTUATION_TYPE) {
319 if ('.' == $token->getValue() || '[' == $token->getValue()) {
320 $node = $this->parseSubscriptExpression($node);
321 } elseif ('|' == $token->getValue()) {
322 $node = $this->parseFilterExpression($node);
334 public function getFunctionNode($name, $line)
338 $this->parseArguments();
339 if (!count($this->parser->getBlockStack())) {
340 throw new Twig_Error_Syntax('Calling "parent" outside a block is forbidden.', $line, $this->parser->getStream()->getSourceContext());
343 if (!$this->parser->getParent() && !$this->parser->hasTraits()) {
344 throw new Twig_Error_Syntax('Calling "parent" on a template that does not extend nor "use" another template is forbidden.', $line, $this->parser->getStream()->getSourceContext());
347 return new Twig_Node_Expression_Parent($this->parser->peekBlockStack(), $line);
349 $args = $this->parseArguments();
350 if (count($args) < 1) {
351 throw new Twig_Error_Syntax('The "block" function takes one argument (the block name).', $line, $this->parser->getStream()->getSourceContext());
354 return new Twig_Node_Expression_BlockReference($args->getNode(0), count($args) > 1 ? $args->getNode(1) : null, $line);
356 $args = $this->parseArguments();
357 if (count($args) < 2) {
358 throw new Twig_Error_Syntax('The "attribute" function takes at least two arguments (the variable and the attributes).', $line, $this->parser->getStream()->getSourceContext());
361 return new Twig_Node_Expression_GetAttr($args->getNode(0), $args->getNode(1), count($args) > 2 ? $args->getNode(2) : null, Twig_Template::ANY_CALL, $line);
363 if (null !== $alias = $this->parser->getImportedSymbol('function', $name)) {
364 $arguments = new Twig_Node_Expression_Array(array(), $line);
365 foreach ($this->parseArguments() as $n) {
366 $arguments->addElement($n);
369 $node = new Twig_Node_Expression_MethodCall($alias['node'], $alias['name'], $arguments, $line);
370 $node->setAttribute('safe', true);
375 $args = $this->parseArguments(true);
376 $class = $this->getFunctionNodeClass($name, $line);
378 return new $class($name, $args, $line);
382 public function parseSubscriptExpression($node)
384 $stream = $this->parser->getStream();
385 $token = $stream->next();
386 $lineno = $token->getLine();
387 $arguments = new Twig_Node_Expression_Array(array(), $lineno);
388 $type = Twig_Template::ANY_CALL;
389 if ($token->getValue() == '.') {
390 $token = $stream->next();
392 $token->getType() == Twig_Token::NAME_TYPE
394 $token->getType() == Twig_Token::NUMBER_TYPE
396 ($token->getType() == Twig_Token::OPERATOR_TYPE && preg_match(Twig_Lexer::REGEX_NAME, $token->getValue()))
398 $arg = new Twig_Node_Expression_Constant($token->getValue(), $lineno);
400 if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
401 $type = Twig_Template::METHOD_CALL;
402 foreach ($this->parseArguments() as $n) {
403 $arguments->addElement($n);
407 throw new Twig_Error_Syntax('Expected name or number.', $lineno, $stream->getSourceContext());
410 if ($node instanceof Twig_Node_Expression_Name && null !== $this->parser->getImportedSymbol('template', $node->getAttribute('name'))) {
411 if (!$arg instanceof Twig_Node_Expression_Constant) {
412 throw new Twig_Error_Syntax(sprintf('Dynamic macro names are not supported (called on "%s").', $node->getAttribute('name')), $token->getLine(), $stream->getSourceContext());
415 $name = $arg->getAttribute('value');
417 if ($this->parser->isReservedMacroName($name)) {
418 throw new Twig_Error_Syntax(sprintf('"%s" cannot be called as macro as it is a reserved keyword.', $name), $token->getLine(), $stream->getSourceContext());
421 $node = new Twig_Node_Expression_MethodCall($node, 'get'.$name, $arguments, $lineno);
422 $node->setAttribute('safe', true);
427 $type = Twig_Template::ARRAY_CALL;
431 if ($stream->test(Twig_Token::PUNCTUATION_TYPE, ':')) {
433 $arg = new Twig_Node_Expression_Constant(0, $token->getLine());
435 $arg = $this->parseExpression();
438 if ($stream->nextIf(Twig_Token::PUNCTUATION_TYPE, ':')) {
443 if ($stream->test(Twig_Token::PUNCTUATION_TYPE, ']')) {
444 $length = new Twig_Node_Expression_Constant(null, $token->getLine());
446 $length = $this->parseExpression();
449 $class = $this->getFilterNodeClass('slice', $token->getLine());
450 $arguments = new Twig_Node(array($arg, $length));
451 $filter = new $class($node, new Twig_Node_Expression_Constant('slice', $token->getLine()), $arguments, $token->getLine());
453 $stream->expect(Twig_Token::PUNCTUATION_TYPE, ']');
458 $stream->expect(Twig_Token::PUNCTUATION_TYPE, ']');
461 return new Twig_Node_Expression_GetAttr($node, $arg, $arguments, $type, $lineno);
464 public function parseFilterExpression($node)
466 $this->parser->getStream()->next();
468 return $this->parseFilterExpressionRaw($node);
471 public function parseFilterExpressionRaw($node, $tag = null)
474 $token = $this->parser->getStream()->expect(Twig_Token::NAME_TYPE);
476 $name = new Twig_Node_Expression_Constant($token->getValue(), $token->getLine());
477 if (!$this->parser->getStream()->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
478 $arguments = new Twig_Node();
480 $arguments = $this->parseArguments(true);
483 $class = $this->getFilterNodeClass($name->getAttribute('value'), $token->getLine());
485 $node = new $class($node, $name, $arguments, $token->getLine(), $tag);
487 if (!$this->parser->getStream()->test(Twig_Token::PUNCTUATION_TYPE, '|')) {
491 $this->parser->getStream()->next();
500 * @param bool $namedArguments Whether to allow named arguments or not
501 * @param bool $definition Whether we are parsing arguments for a function definition
505 * @throws Twig_Error_Syntax
507 public function parseArguments($namedArguments = false, $definition = false)
510 $stream = $this->parser->getStream();
512 $stream->expect(Twig_Token::PUNCTUATION_TYPE, '(', 'A list of arguments must begin with an opening parenthesis');
513 while (!$stream->test(Twig_Token::PUNCTUATION_TYPE, ')')) {
515 $stream->expect(Twig_Token::PUNCTUATION_TYPE, ',', 'Arguments must be separated by a comma');
519 $token = $stream->expect(Twig_Token::NAME_TYPE, null, 'An argument must be a name');
520 $value = new Twig_Node_Expression_Name($token->getValue(), $this->parser->getCurrentToken()->getLine());
522 $value = $this->parseExpression();
526 if ($namedArguments && $token = $stream->nextIf(Twig_Token::OPERATOR_TYPE, '=')) {
527 if (!$value instanceof Twig_Node_Expression_Name) {
528 throw new Twig_Error_Syntax(sprintf('A parameter name must be a string, "%s" given.', get_class($value)), $token->getLine(), $stream->getSourceContext());
530 $name = $value->getAttribute('name');
533 $value = $this->parsePrimaryExpression();
535 if (!$this->checkConstantExpression($value)) {
536 throw new Twig_Error_Syntax(sprintf('A default value for an argument must be a constant (a boolean, a string, a number, or an array).'), $token->getLine(), $stream->getSourceContext());
539 $value = $this->parseExpression();
544 if (null === $name) {
545 $name = $value->getAttribute('name');
546 $value = new Twig_Node_Expression_Constant(null, $this->parser->getCurrentToken()->getLine());
548 $args[$name] = $value;
550 if (null === $name) {
553 $args[$name] = $value;
557 $stream->expect(Twig_Token::PUNCTUATION_TYPE, ')', 'A list of arguments must be closed by a parenthesis');
559 return new Twig_Node($args);
562 public function parseAssignmentExpression()
564 $stream = $this->parser->getStream();
567 $token = $stream->expect(Twig_Token::NAME_TYPE, null, 'Only variables can be assigned to');
568 $value = $token->getValue();
569 if (in_array(strtolower($value), array('true', 'false', 'none', 'null'))) {
570 throw new Twig_Error_Syntax(sprintf('You cannot assign a value to "%s".', $value), $token->getLine(), $stream->getSourceContext());
572 $targets[] = new Twig_Node_Expression_AssignName($value, $token->getLine());
574 if (!$stream->nextIf(Twig_Token::PUNCTUATION_TYPE, ',')) {
579 return new Twig_Node($targets);
582 public function parseMultitargetExpression()
586 $targets[] = $this->parseExpression();
587 if (!$this->parser->getStream()->nextIf(Twig_Token::PUNCTUATION_TYPE, ',')) {
592 return new Twig_Node($targets);
595 private function parseNotTestExpression(Twig_NodeInterface $node)
597 return new Twig_Node_Expression_Unary_Not($this->parseTestExpression($node), $this->parser->getCurrentToken()->getLine());
600 private function parseTestExpression(Twig_NodeInterface $node)
602 $stream = $this->parser->getStream();
603 list($name, $test) = $this->getTest($node->getTemplateLine());
605 $class = $this->getTestNodeClass($test);
607 if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
608 $arguments = $this->parser->getExpressionParser()->parseArguments(true);
611 return new $class($node, $name, $arguments, $this->parser->getCurrentToken()->getLine());
614 private function getTest($line)
616 $stream = $this->parser->getStream();
617 $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
619 if ($test = $this->env->getTest($name)) {
620 return array($name, $test);
623 if ($stream->test(Twig_Token::NAME_TYPE)) {
625 $name = $name.' '.$this->parser->getCurrentToken()->getValue();
627 if ($test = $this->env->getTest($name)) {
630 return array($name, $test);
634 $e = new Twig_Error_Syntax(sprintf('Unknown "%s" test.', $name), $line, $stream->getSourceContext());
635 $e->addSuggestions($name, array_keys($this->env->getTests()));
640 private function getTestNodeClass($test)
642 if ($test instanceof Twig_SimpleTest && $test->isDeprecated()) {
643 $stream = $this->parser->getStream();
644 $message = sprintf('Twig Test "%s" is deprecated', $test->getName());
645 if (!is_bool($test->getDeprecatedVersion())) {
646 $message .= sprintf(' since version %s', $test->getDeprecatedVersion());
648 if ($test->getAlternative()) {
649 $message .= sprintf('. Use "%s" instead', $test->getAlternative());
651 $src = $stream->getSourceContext();
652 $message .= sprintf(' in %s at line %d.', $src->getPath() ? $src->getPath() : $src->getName(), $stream->getCurrent()->getLine());
654 @trigger_error($message, E_USER_DEPRECATED);
657 if ($test instanceof Twig_SimpleTest) {
658 return $test->getNodeClass();
661 return $test instanceof Twig_Test_Node ? $test->getClass() : 'Twig_Node_Expression_Test';
664 protected function getFunctionNodeClass($name, $line)
666 if (false === $function = $this->env->getFunction($name)) {
667 $e = new Twig_Error_Syntax(sprintf('Unknown "%s" function.', $name), $line, $this->parser->getStream()->getSourceContext());
668 $e->addSuggestions($name, array_keys($this->env->getFunctions()));
673 if ($function instanceof Twig_SimpleFunction && $function->isDeprecated()) {
674 $message = sprintf('Twig Function "%s" is deprecated', $function->getName());
675 if (!is_bool($function->getDeprecatedVersion())) {
676 $message .= sprintf(' since version %s', $function->getDeprecatedVersion());
678 if ($function->getAlternative()) {
679 $message .= sprintf('. Use "%s" instead', $function->getAlternative());
681 $src = $this->parser->getStream()->getSourceContext();
682 $message .= sprintf(' in %s at line %d.', $src->getPath() ? $src->getPath() : $src->getName(), $line);
684 @trigger_error($message, E_USER_DEPRECATED);
687 if ($function instanceof Twig_SimpleFunction) {
688 return $function->getNodeClass();
691 return $function instanceof Twig_Function_Node ? $function->getClass() : 'Twig_Node_Expression_Function';
694 protected function getFilterNodeClass($name, $line)
696 if (false === $filter = $this->env->getFilter($name)) {
697 $e = new Twig_Error_Syntax(sprintf('Unknown "%s" filter.', $name), $line, $this->parser->getStream()->getSourceContext());
698 $e->addSuggestions($name, array_keys($this->env->getFilters()));
703 if ($filter instanceof Twig_SimpleFilter && $filter->isDeprecated()) {
704 $message = sprintf('Twig Filter "%s" is deprecated', $filter->getName());
705 if (!is_bool($filter->getDeprecatedVersion())) {
706 $message .= sprintf(' since version %s', $filter->getDeprecatedVersion());
708 if ($filter->getAlternative()) {
709 $message .= sprintf('. Use "%s" instead', $filter->getAlternative());
711 $src = $this->parser->getStream()->getSourceContext();
712 $message .= sprintf(' in %s at line %d.', $src->getPath() ? $src->getPath() : $src->getName(), $line);
714 @trigger_error($message, E_USER_DEPRECATED);
717 if ($filter instanceof Twig_SimpleFilter) {
718 return $filter->getNodeClass();
721 return $filter instanceof Twig_Filter_Node ? $filter->getClass() : 'Twig_Node_Expression_Filter';
724 // checks that the node only contains "constant" elements
725 protected function checkConstantExpression(Twig_NodeInterface $node)
727 if (!($node instanceof Twig_Node_Expression_Constant || $node instanceof Twig_Node_Expression_Array
728 || $node instanceof Twig_Node_Expression_Unary_Neg || $node instanceof Twig_Node_Expression_Unary_Pos
733 foreach ($node as $n) {
734 if (!$this->checkConstantExpression($n)) {
743 class_alias('Twig_ExpressionParser', 'Twig\ExpressionParser', false);