Hyperf 注解失败

提示

  1. [ERROR] Argument 1 passed to Hyperf\Di\Definition\Reference::__construct() must be of the type string, null given, called in /var/www/vendor/hyperf/di/src/Definition/DefinitionSource.php on line 197[37] in /var/www/vendor/hyperf/di/src/Definition/Reference.php
  2. [ERROR] #0 /var/www/vendor/hyperf/di/src/Definition/DefinitionSource.php(197): Hyperf\Di\Definition\Reference->__construct(NULL)
  3. #1 /var/www/vendor/hyperf/di/src/Definition/DefinitionSource.php(86): Hyperf\Di\Definition\DefinitionSource->autowire('App\\Controller\\...')
  4. #2 /var/www/vendor/hyperf/di/src/Container.php(184): Hyperf\Di\Definition\DefinitionSource->getDefinition('App\\Controller\\...')
  5. #3 /var/www/vendor/hyperf/di/src/Container.php(84): Hyperf\Di\Container->getDefinition('App\\Controller\\...')
  6. #4 /var/www/vendor/hyperf/di/src/Container.php(125): Hyperf\Di\Container->make('App\\Controller\\...')
  7. #5 /var/www/vendor/hyperf/http-server/src/CoreMiddleware.php(151): Hyperf\Di\Container->get('App\\Controller\\...')
  8. #6 /var/www/vendor/hyperf/http-server/src/CoreMiddleware.php(109): Hyperf\HttpServer\CoreMiddleware->handleFound(Object(Hyperf\HttpServer\Router\Dispatched), Object(Hyperf\HttpMessage\Server\Request))
  9. #7 /var/www/vendor/hyperf/dispatcher/src/AbstractRequestHandler.php(64): Hyperf\HttpServer\CoreMiddleware->process(Object(Hyperf\HttpMessage\Server\Request), Object(Hyperf\Dispatcher\HttpRequestHandler))
  10. #8 /var/www/vendor/hyperf/dispatcher/src/HttpRequestHandler.php(26): Hyperf\Dispatcher\AbstractRequestHandler->handleRequest(Object(Hyperf\HttpMessage\Server\Request))
  11. #9 /var/www/vendor/meibuyu/micro/src/Middleware/TokenExistMiddleware.php(24): Hyperf\Dispatcher\HttpRequestHandler->handle(Object(Hyperf\HttpMessage\Server\Request))
  12. #10 /var/www/vendor/hyperf/dispatcher/src/AbstractRequestHandler.php(64): Meibuyu\Micro\Middleware\TokenExistMiddleware->process(Object(Hyperf\HttpMessage\Server\Request), Object(Hyperf\Dispatcher\HttpRequestHandler))
  13. #11 /var/www/vendor/hyperf/dispatcher/src/HttpRequestHandler.php(26): Hyperf\Dispatcher\AbstractRequestHandler->handleRequest(Object(Hyperf\HttpMessage\Server\Request))
  14. #12 /var/www/vendor/hyperf/tracer/src/Middleware/TraceMiddleware.php(46): Hyperf\Dispatcher\HttpRequestHandler->handle(Object(Hyperf\HttpMessage\Server\Request))
  15. #13 /var/www/vendor/hyperf/dispatcher/src/AbstractRequestHandler.php(64): Hyperf\Tracer\Middleware\TraceMiddleware->process(Object(Hyperf\HttpMessage\Server\Request), Object(Hyperf\Dispatcher\HttpRequestHandler))
  16. #14 /var/www/vendor/hyperf/dispatcher/src/HttpRequestHandler.php(26): Hyperf\Dispatcher\AbstractRequestHandler->handleRequest(Object(Hyperf\HttpMessage\Server\Request))
  17. #15 /var/www/vendor/hyperf/dispatcher/src/HttpDispatcher.php(42): Hyperf\Dispatcher\HttpRequestHandler->handle(Object(Hyperf\HttpMessage\Server\Request))
  18. #16 /var/www/vendor/hyperf/http-server/src/Server.php(113): Hyperf\Dispatcher\HttpDispatcher->dispatch(Object(Hyperf\HttpMessage\Server\Request), Array, Object(Hyperf\HttpServer\CoreMiddleware))

问题原因:inject 写法错误,比如将正确的 @var InventoryCheckOperateLogRepository 写成了 @var InventoryCheckOperateLogRepository;,末尾多了个 ;

解决方法:将错误写法末尾的 ; 去掉