diff --git a/src/Php/Preprocessor.php b/src/Php/Preprocessor.php index 7da54de0..aa7f5d7a 100644 --- a/src/Php/Preprocessor.php +++ b/src/Php/Preprocessor.php @@ -269,7 +269,14 @@ class Preprocessor extends CompilerBase if ($this->classDef->hasProperty($name)) { $this->fatalError($param, "Duplicate property `{$name}`"); } - $propertyDef = new PropertyDef($name, $param->flags, $type, $default, $nullable); + // 将类型标准化为内部类型格式(如 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; + } + $propertyDef = new PropertyDef($name, $param->flags, $propType, $default, $nullable); $this->classDef->properties[$name] = $propertyDef; } if ($param->variadic) { diff --git a/tests/aot/type_hits/007.phpt b/tests/aot/type_hits/007.phpt new file mode 100644 index 00000000..c0e29bd5 --- /dev/null +++ b/tests/aot/type_hits/007.phpt @@ -0,0 +1,33 @@ +--TEST-- +type hits +--FILE-- +collectLabels($this->stmts); + } +} + +function main() +{ + $obj = new Foo(['Hello World']); + $obj->buildCfg(); +} +?> +--EXPECT-- +array(1) { + [0]=> + string(11) "Hello World" +} \ No newline at end of file