$attr = new Twig_Node_Expression_Constant('bar', 0);
$args = new Twig_Node();
$node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_TemplateInterface::ANY_CALL, 0);
- $tests[] = array($node, '$this->getAttribute((isset($context[\'foo\']) ? $context[\'foo\'] : null), "bar", array(), "any", false)');
+ $tests[] = array($node, '$this->getAttribute($this->getContext($context, \'foo\'), "bar", array(), "any", false)');
$node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_TemplateInterface::ARRAY_CALL, 0);
- $tests[] = array($node, '$this->getAttribute((isset($context[\'foo\']) ? $context[\'foo\'] : null), "bar", array(), "array", false)');
+ $tests[] = array($node, '$this->getAttribute($this->getContext($context, \'foo\'), "bar", array(), "array", false)');
$args = new Twig_Node(array(
new Twig_Node_Expression_Constant('bar', 0),
));
$node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_TemplateInterface::METHOD_CALL, 0);
- $tests[] = array($node, '$this->getAttribute((isset($context[\'foo\']) ? $context[\'foo\'] : null), "bar", array((isset($context[\'foo\']) ? $context[\'foo\'] : null), "bar", ), "method", false)');
+ $tests[] = array($node, '$this->getAttribute($this->getContext($context, \'foo\'), "bar", array($this->getContext($context, \'foo\'), "bar", ), "method", false)');
return $tests;
}
return array(
array($node, '$this->getContext($context, \'foo\')', $env),
- array($node, '(isset($context[\'foo\']) ? $context[\'foo\'] : null)'),
+ array($node, '$this->getContext($context, \'foo\')'),
array($self, '$this'),
array($context, '$context'),
);
$tests[] = array($node, <<<EOF
\$context['_parent'] = (array) \$context;
-\$context['_seq'] = twig_ensure_traversable((isset(\$context['items']) ? \$context['items'] : null));
+\$context['_seq'] = twig_ensure_traversable(\$this->getContext(\$context, 'items'));
foreach (\$context['_seq'] as \$context['key'] => \$context['item']) {
- echo (isset(\$context['foo']) ? \$context['foo'] : null);
+ echo \$this->getContext(\$context, 'foo');
}
\$_parent = \$context['_parent'];
unset(\$context['_seq'], \$context['_iterated'], \$context['key'], \$context['item'], \$context['_parent'], \$context['loop']);
$tests[] = array($node, <<<EOF
\$context['_parent'] = (array) \$context;
-\$context['_seq'] = twig_ensure_traversable((isset(\$context['values']) ? \$context['values'] : null));
+\$context['_seq'] = twig_ensure_traversable(\$this->getContext(\$context, 'values'));
\$context['loop'] = array(
'parent' => \$context['_parent'],
'index0' => 0,
\$context['loop']['last'] = 1 === \$length;
}
foreach (\$context['_seq'] as \$context['k'] => \$context['v']) {
- echo (isset(\$context['foo']) ? \$context['foo'] : null);
+ echo \$this->getContext(\$context, 'foo');
++\$context['loop']['index0'];
++\$context['loop']['index'];
\$context['loop']['first'] = false;
$tests[] = array($node, <<<EOF
\$context['_parent'] = (array) \$context;
-\$context['_seq'] = twig_ensure_traversable((isset(\$context['values']) ? \$context['values'] : null));
+\$context['_seq'] = twig_ensure_traversable(\$this->getContext(\$context, 'values'));
\$context['_iterated'] = false;
\$context['loop'] = array(
'parent' => \$context['_parent'],
\$context['loop']['last'] = 1 === \$length;
}
foreach (\$context['_seq'] as \$context['k'] => \$context['v']) {
- echo (isset(\$context['foo']) ? \$context['foo'] : null);
+ echo \$this->getContext(\$context, 'foo');
\$context['_iterated'] = true;
++\$context['loop']['index0'];
++\$context['loop']['index'];
}
}
if (!\$context['_iterated']) {
- echo (isset(\$context['foo']) ? \$context['foo'] : null);
+ echo \$this->getContext(\$context, 'foo');
}
\$_parent = \$context['_parent'];
unset(\$context['_seq'], \$context['_iterated'], \$context['k'], \$context['v'], \$context['_parent'], \$context['loop']);
$tests[] = array($node, <<<EOF
if (true) {
- echo (isset(\$context['foo']) ? \$context['foo'] : null);
+ echo \$this->getContext(\$context, 'foo');
}
EOF
);
$tests[] = array($node, <<<EOF
if (true) {
- echo (isset(\$context['foo']) ? \$context['foo'] : null);
+ echo \$this->getContext(\$context, 'foo');
} elseif (false) {
- echo (isset(\$context['bar']) ? \$context['bar'] : null);
+ echo \$this->getContext(\$context, 'bar');
}
EOF
);
$tests[] = array($node, <<<EOF
if (true) {
- echo (isset(\$context['foo']) ? \$context['foo'] : null);
+ echo \$this->getContext(\$context, 'foo');
} else {
- echo (isset(\$context['bar']) ? \$context['bar'] : null);
+ echo \$this->getContext(\$context, 'bar');
}
EOF
);
$values = new Twig_Node(array(new Twig_Node_Expression_Constant('foo', 0), new Twig_Node_Expression_Name('bar', 0)), array(), 0);
$node = new Twig_Node_Set(false, $names, $values, 0);
$tests[] = array($node, <<<EOF
-list(\$context['foo'], \$context['bar']) = array("foo", (isset(\$context['bar']) ? \$context['bar'] : null));
+list(\$context['foo'], \$context['bar']) = array("foo", \$this->getContext(\$context, 'bar'));
EOF
);