Use isset before array_key_exists

This commit is contained in:
Jérémy Derussé
2018-06-20 13:04:54 +02:00
parent 3b71efb7b4
commit 230d34128d
+6 -1
View File
@@ -32,7 +32,12 @@ class Twig_Node_Expression_Name extends Twig_Node_Expression
if ($this->isSpecial()) {
$compiler->repr(true);
} else {
$compiler->raw('array_key_exists(')->repr($name)->raw(', $context)');
$compiler
->raw('(isset($context[')
->string($name)
->raw(']) || array_key_exists(')
->string($name)
->raw(', $context))');
}
} elseif ($this->isSpecial()) {
$compiler->raw($this->specialVars[$name]);