From 08cbfa1d719f4caf76016fd63862fb9d50565082 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Tue, 7 Apr 2026 17:24:06 +0800 Subject: [PATCH] =?UTF-8?q?refactor(php):=20=E6=9B=B4=E6=96=B0=20shell=5Fe?= =?UTF-8?q?xec=20=E8=A7=A3=E6=9E=90=E6=96=B9=E6=B3=95=E7=9A=84=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 parseShellExec 方法的参数类型从 mixed 更改为 Node\Expr\ShellExec - 重构 shell_exec 表达式的解析逻辑 - 使用 identifierToStr 方法处理表达式部分 - 改进代码的类型安全性和可读性 --- src/Php/CompilerBase.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index 4734b2ce..8d7444e3 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -4234,9 +4234,13 @@ class CompilerBase extends \PhpAot\Core\Translator return $code; } - protected function parseShellExec(mixed $expr): string + protected function parseShellExec(Node\Expr\ShellExec $expr): string { - return 'php::call("shell_exec", {' . $this->parseInterpolatedString($expr) . '})'; + $list = []; + foreach($expr->parts as $part) { + $list[] = $this->identifierToStr($part); + } + return 'php::shell_exec(php::concat({' . implode(', ', $list) . '}))'; } protected function parseGoto(Node\Stmt\Goto_ $v): string