Skip to content

hyperf 路由中间件 注解使用方式有问题 #60

@edward-lzr

Description

@edward-lzr
/**
 * @Apidoc\RouteMiddleware({AdminMiddleware::class})
 */

用/**/ @ 上面这么写没问题

#[
    Apidoc\RouteMiddleware([AdminMiddleware::class]),
]

用#[] 这样写就报错了。

php ./bin/hyperf.php server:watch
PHP Deprecated:  Creation of dynamic property hg\apidoc\annotation\RouteMiddleware::$0 is deprecated in /data/project/api/server-api/vendor/hg/apidoc/src/utils/AbstractAnnotation.php on line 21

Deprecated: Creation of dynamic property hg\apidoc\annotation\RouteMiddleware::$0 is deprecated in /data/project/api/server-api/vendor/hg/apidoc/src/utils/AbstractAnnotation.php on line 21
[ERROR] Array to string conversion[81] in /data/project/api/server-api/vendor/hyperf/http-server/src/MiddlewareManager.php
[ERROR] #0 [internal function]: Hyperf\ExceptionHandler\Listener\ErrorExceptionHandler::Hyperf\ExceptionHandler\Listener\{closure}()
#1 /data/project/api/server-api/vendor/hyperf/http-server/src/MiddlewareManager.php(81): array_unique()
#2 /data/project/api/server-api/vendor/hyperf/http-server/src/Server.php(109): Hyperf\HttpServer\MiddlewareManager::sortMiddlewares()
#3 [internal function]: Hyperf\HttpServer\Server->onRequest()
#4 {main}

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