From f3fd30c662e91127144812fe31945404b8d64a31 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Mon, 30 Mar 2026 12:50:55 +0800 Subject: [PATCH] =?UTF-8?q?feat(php):=20=E6=B7=BB=E5=8A=A0=E5=AF=B9?= =?UTF-8?q?=E8=81=94=E5=90=88=E7=B1=BB=E5=9E=8B=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在编译器基类中处理UnionType情况,将其转换为mixed类型 - 添加nullable类型属性的测试用例 - 实现对union类型参数的正确解析和处理逻辑 --- src/Php/CompilerBase.php | 3 +++ tests/aot/prop-004.phpt | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 tests/aot/prop-004.phpt diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index db71194b..d966edf5 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -1004,6 +1004,9 @@ class CompilerBase extends \PhpAot\Core\Translator if ($param->type instanceof NullableType) { $type = $param->type->type; $nullable = true; + } elseif ($param->type instanceof UnionType) { + $type = 'mixed'; + $nullable = false; } else { $type = $param->type === null ? '' : $param->type; $nullable = false; diff --git a/tests/aot/prop-004.phpt b/tests/aot/prop-004.phpt new file mode 100644 index 00000000..68e03a0f --- /dev/null +++ b/tests/aot/prop-004.phpt @@ -0,0 +1,18 @@ +--TEST-- +Property with nullable type +--FILE-- +value); +} +?> +--EXPECT-- +string(8) "Continue" \ No newline at end of file