mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-31 04:27:00 +00:00
Merge branch '1.x' into 2.x
* 1.x: optimized context access on PHP 7.4
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user