*/
class Twig_Node_Expression_MethodCall extends Twig_Node_Expression
{
- public function __construct(Twig_Node_Expression $node, $method, Twig_Node_Expression_Array $arguments, $lineno)
+ public function __construct(Twig_Node_Expression_Name $node, $method, Twig_Node_Expression_Array $arguments, $lineno)
{
parent::__construct(array('node' => $node, 'arguments' => $arguments), array('method' => $method, 'safe' => false), $lineno);
}
public function compile(Twig_Compiler $compiler)
{
+ $this->getNode('node')->setAttribute('always_defined', true);
+
$compiler
->subcompile($this->getNode('node'))
->raw('->')
public function __construct($name, $lineno)
{
- parent::__construct(array(), array('name' => $name, 'is_defined_test' => false, 'ignore_strict_check' => false), $lineno);
+ parent::__construct(array(), array('name' => $name, 'is_defined_test' => false, 'ignore_strict_check' => false, 'always_defined' => false), $lineno);
}
public function compile(Twig_Compiler $compiler)
}
} elseif ($this->isSpecial()) {
$compiler->raw($this->specialVars[$name]);
+ } elseif ($this->getAttribute('always_defined')) {
+ $compiler
+ ->raw('$context[')
+ ->string($name)
+ ->raw(']')
+ ;
} else {
// remove the non-PHP 5.4 version when PHP 5.3 support is dropped
// as the non-optimized version is just a workaround for slow ternary operator