optimized context access on PHP 7.4

This commit is contained in:
Fabien Potencier
2019-04-26 18:12:31 +02:00
parent d7eaeead8b
commit 5b5f5659a2
2 changed files with 9 additions and 2 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
* 1.40.2 (2019-XX-XX)
* n/a
* optimized context access on PHP 7.4
* 1.40.1 (2019-04-29)
+8 -1
View File
@@ -36,13 +36,20 @@ class NameExpression extends AbstractExpression
if ($this->getAttribute('is_defined_test')) {
if ($this->isSpecial()) {
$compiler->repr(true);
} elseif (\PHP_VERSION_ID >= 700400) {
$compiler
->raw('array_key_exists(')
->string($name)
->raw(', $context)')
;
} else {
$compiler
->raw('(isset($context[')
->string($name)
->raw(']) || array_key_exists(')
->string($name)
->raw(', $context))');
->raw(', $context))')
;
}
} elseif ($this->isSpecial()) {
$compiler->raw($this->specialVars[$name]);