From: Fabien Potencier Date: Sat, 11 Oct 2014 20:38:36 +0000 (+0200) Subject: fixed macros when using an argument named like a PHP super globa X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=b5f074207dbf5e32e5c2a6df888aac2f5d4d77dc;p=web%2Fkonrad%2Ftwig.git fixed macros when using an argument named like a PHP super globa --- diff --git a/CHANGELOG b/CHANGELOG index 713598b..9d136c1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ * 1.16.2 (2014-XX-XX) + * fixed macros when using an argument named like a PHP super global (like GET or POST) * fixed date_modify when working with DateTimeImmutable * optimized for loops * fixed multi-byte characters handling in the split filter diff --git a/lib/Twig/Node/Macro.php b/lib/Twig/Node/Macro.php index 47c2915..ab7e8d2 100644 --- a/lib/Twig/Node/Macro.php +++ b/lib/Twig/Node/Macro.php @@ -37,7 +37,7 @@ class Twig_Node_Macro extends Twig_Node $pos = 0; foreach ($this->getNode('arguments') as $name => $default) { $compiler - ->raw('$_'.$name.' = ') + ->raw('$__'.$name.'__ = ') ->subcompile($default) ; @@ -64,7 +64,7 @@ class Twig_Node_Macro extends Twig_Node $compiler ->write('') ->string($name) - ->raw(' => $_'.$name) + ->raw(' => $__'.$name.'__') ->raw(",\n") ; } diff --git a/test/Twig/Tests/Node/MacroTest.php b/test/Twig/Tests/Node/MacroTest.php index 4d2f641..2a77ac7 100644 --- a/test/Twig/Tests/Node/MacroTest.php +++ b/test/Twig/Tests/Node/MacroTest.php @@ -46,11 +46,11 @@ class Twig_Tests_Node_MacroTest extends Twig_Test_NodeTestCase return array( array($node, <<env->mergeGlobals(array( - "foo" => \$_foo, - "bar" => \$_bar, + "foo" => \$__foo__, + "bar" => \$__bar__, )); \$blocks = array();