From 5129bab90006196cedcb5dd2144a4999e474c396 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Fri, 29 May 2026 16:20:24 +0800 Subject: [PATCH] =?UTF-8?q?test(aot):=20=E6=B7=BB=E5=8A=A0=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E8=B0=83=E7=94=A8=E5=91=BD=E5=90=8D=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 实现了动态实例化与命名参数的测试用例 - 验证动态方法调用与参数展开的功能 - 测试控制器类的构造函数命名参数传递 - 验证动态方法调用返回结果的正确性 - 添加了多场景动态调用的预期输出验证 --- tests/aot/dynamic_call/new-named-args.phpt | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tests/aot/dynamic_call/new-named-args.phpt diff --git a/tests/aot/dynamic_call/new-named-args.phpt b/tests/aot/dynamic_call/new-named-args.phpt new file mode 100644 index 00000000..d0967cac --- /dev/null +++ b/tests/aot/dynamic_call/new-named-args.phpt @@ -0,0 +1,45 @@ +--TEST-- +Dynamic instantiation with named arguments and dynamic method call +--FILE-- +prefix = $prefix; + } + + public function greet(string $name, int $times): string { + $result = ''; + for ($i = 0; $i < $times; $i++) { + $result .= "{$this->prefix} {$name}!\n"; + } + return $result; + } + + public function farewell(string $name): string { + return "{$this->prefix} Goodbye {$name}!"; + } +} + +function main(): void { + $handler = [HelloController::class, 'greet']; + $params = ['World', 2]; + + [$class, $method] = $handler; + // Dynamic instantiation with named args + dynamic method call with unpacking + $result = (new $class(prefix: 'Hi'))->$method(name: $params[0], times: $params[1]); + echo $result; + + // Another dynamic method call: farewell + $handler[1] = 'farewell'; + [$class, $method] = $handler; + echo (new $class(prefix: 'Ohayo'))->$method(name: 'AOT'); +} +?> +--EXPECT-- +Hi World! +Hi World! +Ohayo Goodbye AOT!