fixed macros when using an argument named like a PHP super globa

This commit is contained in:
Fabien Potencier
2014-10-11 22:38:36 +02:00
parent d12f7afbbe
commit b5f074207d
3 changed files with 6 additions and 5 deletions
+1
View File
@@ -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
+2 -2
View File
@@ -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")
;
}
+3 -3
View File
@@ -46,11 +46,11 @@ class Twig_Tests_Node_MacroTest extends Twig_Test_NodeTestCase
return array(
array($node, <<<EOF
// line 1
public function getfoo(\$_foo = null, \$_bar = "Foo")
public function getfoo(\$__foo__ = null, \$__bar__ = "Foo")
{
\$context = \$this->env->mergeGlobals(array(
"foo" => \$_foo,
"bar" => \$_bar,
"foo" => \$__foo__,
"bar" => \$__bar__,
));
\$blocks = array();