From 517c0d8a836973ea7cf6dfc0b11bb561d8f05a65 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Thu, 2 Apr 2026 17:30:20 +0800 Subject: [PATCH] =?UTF-8?q?refactor(Php):=20=E4=BC=98=E5=8C=96=E9=93=BE?= =?UTF-8?q?=E5=BC=8F=E8=A1=A8=E8=BE=BE=E5=BC=8F=E8=A7=A3=E6=9E=90=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将函数获取操作提前到方法开始处,避免重复调用 - 统一使用预获取的函数名变量进行字符串拼接 - 移除重复的 getChainedFunc 方法调用 - 简化 isset 操作符的条件判断逻辑 - 优化代码结构以提高执行效率 --- src/Php/CompilerBase.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index c61e76b4..eb8db727 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -3648,13 +3648,14 @@ class CompilerBase extends \PhpAot\Core\Translator protected function parseChainedExpr(NodeAbstract $node, string $op, bool $getValue = false): string { + $fn = $this->getChainedFunc($op); $expr = $node; if ($this->isVarExpr($expr)) { if ($op === self::OP_ISSET) { $var = $this->parseIdentifier($expr); - return $this->hasVar($var) ? 'php::exists(' . $var . ')' : 'false'; + return $this->hasVar($var) ? $fn . '(' . $var . ')' : 'false'; } - return $this->getChainedFunc($op) . '(' . $this->parseExpr($expr) . ')'; + return $fn . '(' . $this->parseExpr($expr) . ')'; } $list = []; @@ -3681,7 +3682,6 @@ class CompilerBase extends \PhpAot\Core\Translator } $list = array_reverse($list); - $fn = $this->getChainedFunc($op); if ($getValue) { $result = $this->addTmpVar(self::TYPE_VAR);