From fab6490a853389bb03d37ffb4ddec93322b65441 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Fri, 27 Feb 2026 17:03:35 +0800 Subject: [PATCH] =?UTF-8?q?fix(php):=20=E4=BF=AE=E5=A4=8D=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E5=99=A8=E5=91=BD=E5=90=8D=E7=A9=BA=E9=97=B4=E8=BD=AC?= =?UTF-8?q?=E4=B9=89=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在静态变量前缀中使用 escapeNamespace 方法转义命名空间 - 使用 escapeClass 方法转义类名以防止特殊字符问题 - 使用 escapeName 方法转义最终名称确保安全 - 防止因特殊字符导致的编译错误和命名冲突 --- 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 8110f5da..190e1a1e 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -614,10 +614,10 @@ class CompilerBase extends \PhpAot\Core\Translator { $prefix = self::STATIC_VAR; if ($this->namespace) { - $prefix .= $this->namespace . '_'; + $prefix .= $this->escapeNamespace($this->namespace) . '_'; } if ($this->class) { - $prefix .= $this->class . '_'; + $prefix .= $this->escapeClass($this->class) . '_'; if ($this->method) { $prefix .= $this->method . '_'; } @@ -626,7 +626,7 @@ class CompilerBase extends \PhpAot\Core\Translator $prefix .= $this->function . '_'; } } - return $prefix . $name; + return $this->escapeName($prefix . $name); } protected function getNamespacedClassName(string $class): string