Skip to content

Commit

Permalink
fixed macros when using an argument named like a PHP super globa
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Oct 11, 2014
1 parent d12f7af commit b5f0742
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/Twig/Node/Macro.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function compile(Twig_Compiler $compiler)
$pos = 0;
foreach ($this->getNode('arguments') as $name => $default) {
$compiler
->raw('$_'.$name.' = ')
->raw('$__'.$name.'__ = ')
->subcompile($default)
;

Expand All @@ -64,7 +64,7 @@ public function compile(Twig_Compiler $compiler)
$compiler
->write('')
->string($name)
->raw(' => $_'.$name)
->raw(' => $__'.$name.'__')
->raw(",\n")
;
}
Expand Down
6 changes: 3 additions & 3 deletions test/Twig/Tests/Node/MacroTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ public function getTests()
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();
Expand Down

0 comments on commit b5f0742

Please sign in to comment.