Merge branch '1.x' into 2.x

* 1.x:
  optimized context access on PHP 7.4
This commit is contained in:
Fabien Potencier
2019-04-30 15:01:59 +02:00
2 changed files with 9 additions and 2 deletions
+1 -1
View File
@@ -224,7 +224,7 @@
* 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]);