From: Fabien Potencier Date: Sat, 3 Aug 2013 16:18:15 +0000 (+0200) Subject: added an exception when a macro re-uses the same argument name twice X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=b7a54b01017becf7f3b90beadc71536b58e2299a;p=web%2Fkonrad%2Ftwig.git added an exception when a macro re-uses the same argument name twice --- diff --git a/lib/Twig/ExpressionParser.php b/lib/Twig/ExpressionParser.php index 09d16dd..1687e11 100644 --- a/lib/Twig/ExpressionParser.php +++ b/lib/Twig/ExpressionParser.php @@ -482,7 +482,7 @@ class Twig_ExpressionParser $value = $this->parsePrimaryExpression(); if (!$this->checkConstantExpression($value)) { - 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(), $this->parser->getFilename()); + throw new Twig_Error_Syntax('A default value for an argument must be a constant (a boolean, a string, a number, or an array).', $token->getLine(), $this->parser->getFilename()); } } else { $value = $this->parseExpression(); @@ -497,6 +497,10 @@ class Twig_ExpressionParser if (null === $name) { $args[] = $value; } else { + if ($definition && isset($args[$name])) { + throw new Twig_Error_Syntax(sprintf('Arguments cannot contain the same argument name more than once ("%s" is defined twice).', $name), $token->getLine(), $this->parser->getFilename()); + } + $args[$name] = $value; } }