mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-14 03:16:34 +00:00
fix parsing of postfix expressions
This commit is contained in:
committed by
Fabien Potencier
parent
13f80898a2
commit
7284fa9829
@@ -69,13 +69,13 @@ class Twig_ExpressionParser
|
||||
$expr = $this->parseExpression($operator['precedence']);
|
||||
$class = $operator['class'];
|
||||
|
||||
return new $class($expr, $token->getLine());
|
||||
return $this->parsePostfixExpression(new $class($expr, $token->getLine()));
|
||||
} elseif ($token->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
|
||||
$this->parser->getStream()->next();
|
||||
$expr = $this->parseExpression();
|
||||
$this->parser->getStream()->expect(Twig_Token::PUNCTUATION_TYPE, ')');
|
||||
|
||||
return $expr;
|
||||
return $this->parsePostfixExpression($expr);
|
||||
}
|
||||
|
||||
return $this->parsePrimaryExpression();
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
--TEST--
|
||||
Twig parses postfix expressions
|
||||
--TEMPLATE--
|
||||
|
||||
{% macro foo() %}foo{% endmacro %}
|
||||
|
||||
{{ 'a' }}
|
||||
{{ 'a'|upper }}
|
||||
{{ ('a')|upper }}
|
||||
{{ -1|upper }}
|
||||
{{ _self.foo() }}
|
||||
{{ (_self).foo() }}
|
||||
--DATA--
|
||||
return array();
|
||||
--EXPECT--
|
||||
a
|
||||
A
|
||||
A
|
||||
-1
|
||||
foo
|
||||
foo
|
||||
Reference in New Issue
Block a user