diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index a2797587..22fcde4f 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -3076,13 +3076,14 @@ class CompilerBase extends \PhpAot\Core\Translator if ($expr->if === null) { return $this->parseValueSelection($expr, $expr->cond, $expr->else, self::OP_NOT_EMPTY); } + $cond = $this->parseExpr($expr->cond); $if = $this->parseExpr($expr->if); $else = $this->parseExpr($expr->else); if ($this->detectTypeOfExpr($expr->if) !== $this->detectTypeOfExpr($expr->else)) { $if = 'php::Var(' . $if . ')'; $else = 'php::Var(' . $else . ')'; } - return '(' . $this->parseExpr($expr->cond) . ') ? (' . $if . ') : (' . $else . ')'; + return '(' . $cond . ') ? (' . $if . ') : (' . $else . ')'; } protected function parseMatch(Expr\Match_ $expr): string diff --git a/tests/aot/functions/preg_match.phpt b/tests/aot/functions/preg_match.phpt new file mode 100644 index 00000000..b8e73463 --- /dev/null +++ b/tests/aot/functions/preg_match.phpt @@ -0,0 +1,41 @@ +--TEST-- +compact +--FILE-- + +--EXPECT-- +array(4) { + [0]=> + array(2) { + [0]=> + string(9) "foobarbaz" + [1]=> + int(0) + } + [1]=> + array(2) { + [0]=> + string(3) "foo" + [1]=> + int(0) + } + [2]=> + array(2) { + [0]=> + string(3) "bar" + [1]=> + int(3) + } + [3]=> + array(2) { + [0]=> + string(3) "baz" + [1]=> + int(6) + } +} \ No newline at end of file diff --git a/tests/aot/ref/ref-new-var.phpt b/tests/aot/ref/ref-new-var.phpt new file mode 100644 index 00000000..485acc22 --- /dev/null +++ b/tests/aot/ref/ref-new-var.phpt @@ -0,0 +1,13 @@ +--TEST-- +object link operator +--FILE-- + +--EXPECT-- +string(4) "foo_" \ No newline at end of file