From 9f67d588c8a39a07ce0d78db56d9ef6a7d4b07f2 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 8 Dec 2012 09:18:33 +0100 Subject: [PATCH] moved some code to the proper location --- lib/Twig/ExpressionParser.php | 22 +++++++++++----------- 1 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/Twig/ExpressionParser.php b/lib/Twig/ExpressionParser.php index dc49c49..bc8a8fd 100644 --- a/lib/Twig/ExpressionParser.php +++ b/lib/Twig/ExpressionParser.php @@ -365,6 +365,17 @@ class Twig_ExpressionParser } else { throw new Twig_Error_Syntax('Expected name or number', $lineno, $this->parser->getFilename()); } + + if ($node instanceof Twig_Node_Expression_Name && null !== $alias = $this->parser->getImportedSymbol('template', $node->getAttribute('name'))) { + if (!$arg instanceof Twig_Node_Expression_Constant) { + throw new Twig_Error_Syntax(sprintf('Dynamic macro names are not supported (called on "%s")', $node->getAttribute('name')), $token->getLine(), $this->parser->getFilename()); + } + + $node = new Twig_Node_Expression_MethodCall($node, 'get'.$arg->getAttribute('value'), $arguments, $lineno); + $node->setAttribute('safe', true); + + return $node; + } } else { $type = Twig_TemplateInterface::ARRAY_CALL; @@ -392,17 +403,6 @@ class Twig_ExpressionParser $stream->expect(Twig_Token::PUNCTUATION_TYPE, ']'); } - if ($node instanceof Twig_Node_Expression_Name && null !== $alias = $this->parser->getImportedSymbol('template', $node->getAttribute('name'))) { - if (!$arg instanceof Twig_Node_Expression_Constant) { - throw new Twig_Error_Syntax(sprintf('Dynamic macro names are not supported (called on "%s")', $node->getAttribute('name')), $token->getLine(), $this->parser->getFilename()); - } - - $node = new Twig_Node_Expression_MethodCall($node, 'get'.$arg->getAttribute('value'), $arguments, $lineno); - $node->setAttribute('safe', true); - - return $node; - } - return new Twig_Node_Expression_GetAttr($node, $arg, $arguments, $type, $lineno); } -- 1.7.2.5