Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

路由映射到控制器方法参数的时候,使用了联合类型,会提示报错 Error: Call to undefined method ReflectionUnionType::getName() #431

Open
yulinzhihou opened this issue Jan 14, 2025 · 1 comment

Comments

@yulinzhihou
Copy link

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 ,则不会出现报错。

@walkor
Copy link
Owner

walkor commented Jan 15, 2025

目前不支持控制器参数设置为支持联合类型

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants