From 83a81e8df8a5bb0b528dae5e6b7788d95e84a175 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Tue, 9 Jun 2026 14:56:33 +0800 Subject: [PATCH] =?UTF-8?q?refactor(php):=20=E7=AE=80=E5=8C=96=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E7=B1=BB=E5=9E=8B=E8=A7=A3=E6=9E=90=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除手动类型映射逻辑,统一使用 parseTypeDecl 方法处理 - 添加 propClass 变量存储属性类信息 - 将解析后的类型直接赋值给属性定义对象 - 确保所有属性类型都通过标准方法进行解析和转换 --- src/Php/Preprocessor.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Php/Preprocessor.php b/src/Php/Preprocessor.php index aa7f5d7a..b3f55ec1 100644 --- a/src/Php/Preprocessor.php +++ b/src/Php/Preprocessor.php @@ -269,14 +269,10 @@ class Preprocessor extends CompilerBase if ($this->classDef->hasProperty($name)) { $this->fatalError($param, "Duplicate property `{$name}`"); } - // 将类型标准化为内部类型格式(如 array -> php::Array) - if ($type instanceof NodeAbstract) { - $dummyClass = ''; - $propType = $this->parseTypeDecl($type, self::DECL_TYPE_OF_PROPERTY, $dummyClass); - } else { - $propType = $this->zendTypeMap[strtolower($type)] ?? self::TYPE_VAR; - } + $propClass = ''; + $propType = $this->parseTypeDecl($type, self::DECL_TYPE_OF_PROPERTY, $propClass); $propertyDef = new PropertyDef($name, $param->flags, $propType, $default, $nullable); + $propertyDef->class = $propClass; $this->classDef->properties[$name] = $propertyDef; } if ($param->variadic) {