From f12ceb1713a16b11b81e3db25ea300a3377eb789 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Fri, 13 Mar 2026 10:33:06 +0800 Subject: [PATCH] =?UTF-8?q?fix(php):=20=E4=BF=AE=E5=A4=8D=20isset=20?= =?UTF-8?q?=E5=A4=9A=E5=8F=98=E9=87=8F=E6=A3=80=E6=9F=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 实现多变量 isset 检查的正确逻辑 - 添加遍历变量列表并逐个解析的功能 - 使用逻辑与操作符连接多个 isset 检查结果 - 添加 isset-002 测试用例验证多变量检查行为 --- src/Php/CompilerBase.php | 6 +++++- tests/aot/isset-002.phpt | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 tests/aot/isset-002.phpt diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index 8477d176..28627aa7 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -3197,7 +3197,11 @@ class CompilerBase extends \PhpAot\Core\Translator { $vars = $expr->vars; if (count($vars) > 1) { - $this->fatalError($expr, 'Cannot check multiple variables with isset'); + $list = []; + foreach ($vars as $var) { + $list[] = $this->parseVarCheckExpr($var, 'isset'); + } + return '(' . implode(' && ', $list) . ')'; } return $this->parseVarCheckExpr($vars[0], 'isset'); } diff --git a/tests/aot/isset-002.phpt b/tests/aot/isset-002.phpt new file mode 100644 index 00000000..795367f1 --- /dev/null +++ b/tests/aot/isset-002.phpt @@ -0,0 +1,17 @@ +--TEST-- +isset 002 +--FILE-- + +--EXPECT-- +bool(true) +bool(false) +bool(true) +bool(false)