Skip to content

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

@yulinzhihou

Description

@yulinzhihou

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions