Skip to content

Commit 804cf65

Browse files
committed
Merge branch '1.x' into 2.x
* 1.x: optimized context access on PHP 7.4
2 parents d03684c + 7395b7a commit 804cf65

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

CHANGELOG

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@
224224

225225
* 1.40.2 (2019-XX-XX)
226226

227-
* n/a
227+
* optimized context access on PHP 7.4
228228

229229
* 1.40.1 (2019-04-29)
230230

src/Node/Expression/NameExpression.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,20 @@ public function compile(Compiler $compiler)
3636
if ($this->getAttribute('is_defined_test')) {
3737
if ($this->isSpecial()) {
3838
$compiler->repr(true);
39+
} elseif (\PHP_VERSION_ID >= 700400) {
40+
$compiler
41+
->raw('array_key_exists(')
42+
->string($name)
43+
->raw(', $context)')
44+
;
3945
} else {
4046
$compiler
4147
->raw('(isset($context[')
4248
->string($name)
4349
->raw(']) || array_key_exists(')
4450
->string($name)
45-
->raw(', $context))');
51+
->raw(', $context))')
52+
;
4653
}
4754
} elseif ($this->isSpecial()) {
4855
$compiler->raw($this->specialVars[$name]);

0 commit comments

Comments
 (0)