mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-13 19:06:40 +00:00
fixed macro compilation when a variable name is a PHP reserved keyword (closes #881)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
* 1.11.0 (2012-XX-XX)
|
||||
|
||||
* fixed macro compilation when a variable name is a PHP reserved keyword
|
||||
* changed the date filter behavior to always apply the default timezone, except if false is passed as the timezone
|
||||
* fixed bitwise operator precedences
|
||||
* added the template_from_string function
|
||||
|
||||
@@ -31,7 +31,7 @@ class Twig_Node_Macro extends Twig_Node
|
||||
{
|
||||
$arguments = array();
|
||||
foreach ($this->getNode('arguments') as $argument) {
|
||||
$arguments[] = '$'.$argument->getAttribute('name').' = null';
|
||||
$arguments[] = '$_'.$argument->getAttribute('name').' = null';
|
||||
}
|
||||
|
||||
$compiler
|
||||
@@ -52,7 +52,7 @@ class Twig_Node_Macro extends Twig_Node
|
||||
$compiler
|
||||
->write('')
|
||||
->string($argument->getAttribute('name'))
|
||||
->raw(' => $'.$argument->getAttribute('name'))
|
||||
->raw(' => $_'.$argument->getAttribute('name'))
|
||||
->raw(",\n")
|
||||
;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
--TEST--
|
||||
macro
|
||||
--TEMPLATE--
|
||||
{% from _self import test %}
|
||||
|
||||
{% macro test(this) -%}
|
||||
{{ this }}
|
||||
{%- endmacro %}
|
||||
|
||||
{{ test(this) }}
|
||||
--DATA--
|
||||
return array('this' => 'foo');
|
||||
--EXPECT--
|
||||
foo
|
||||
@@ -43,10 +43,10 @@ class Twig_Tests_Node_MacroTest extends Twig_Test_NodeTestCase
|
||||
return array(
|
||||
array($node, <<<EOF
|
||||
// line 1
|
||||
public function getfoo(\$foo = null)
|
||||
public function getfoo(\$_foo = null)
|
||||
{
|
||||
\$context = \$this->env->mergeGlobals(array(
|
||||
"foo" => \$foo,
|
||||
"foo" => \$_foo,
|
||||
));
|
||||
|
||||
\$blocks = array();
|
||||
|
||||
Reference in New Issue
Block a user