webman
webman copied to clipboard
路由映射到控制器方法参数的时候,使用了联合类型,会提示报错 Error: Call to undefined method ReflectionUnionType::getName()
PHP版本:8.3.15
路由 config/route.php
Route::get("/$name/read/{id}", [$controller, 'read'])
控制器
public function read(Request $request, int|string $id) : Response
{
…………………………
}
这里 $id 对应了路由里面的 {id} ,访问的时候会出现
Error: Call to undefined method ReflectionUnionType::getName() in ./vendor/workerman/webman-framework/src/App.php:429
Stack trace:
如果我只用 int 或者 string 修饰 $id ,则不会出现报错。
目前不支持控制器参数设置为支持联合类型