在使用依赖自动注入运行时候报错

xtn

问题描述

在使用依赖自动注入运行时候报错,还没写代码,是搭建环境

程序代码

//return new Webman\Container;
$builder = new \DI\ContainerBuilder();
$builder->addDefinitions(config('dependence', []));
$builder->useAutowiring(true);
$builder->useAnnotations(true);
return $builder->build();

如果return new Webman\Container;则不会报错

报错信息

ErrorException: Method ReflectionParameter::getClass() is deprecated in D:\webman_workspace\乐轩CMS\lx-cms-backend\vendor\php-di\php-di\src\Definition\Source\AnnotationBasedAutowiring.php:235
Stack trace:
#0 D:\webman_workspace\乐轩CMS\lx-cms-backend\vendor\php-di\php-di\src\Definition\Source\AnnotationBasedAutowiring.php(235): {closure}()
#1 D:\webman_workspace\乐轩CMS\lx-cms-backend\vendor\php-di\php-di\src\Definition\Source\AnnotationBasedAutowiring.php(198): DI\Definition\Source\AnnotationBasedAutowiring->getMethodParameter()
#2 D:\webman_workspace\乐轩CMS\lx-cms-backend\vendor\php-di\php-di\src\Definition\Source\AnnotationBasedAutowiring.php(156): DI\Definition\Source\AnnotationBasedAutowiring->getMethodInjection()
#3 D:\webman_workspace\乐轩CMS\lx-cms-backend\vendor\php-di\php-di\src\Definition\Source\AnnotationBasedAutowiring.php(73): DI\Definition\Source\AnnotationBasedAutowiring->readMethods()
#4 D:\webman_workspace\乐轩CMS\lx-cms-backend\vendor\php-di\php-di\src\Definition\Source\AnnotationBasedAutowiring.php(85): DI\Definition\Source\AnnotationBasedAutowiring->autowire()
#5 D:\webman_workspace\乐轩CMS\lx-cms-backend\vendor\php-di\php-di\src\Definition\Source\SourceChain.php(54): DI\Definition\Source\AnnotationBasedAutowiring->getDefinition()
#6 D:\webman_workspace\乐轩CMS\lx-cms-backend\vendor\php-di\php-di\src\Container.php(154): DI\Definition\Source\SourceChain->getDefinition()
#7 D:\webman_workspace\乐轩CMS\lx-cms-backend\vendor\php-di\php-di\src\Container.php(187): DI\Container->getDefinition()
#8 D:\webman_workspace\乐轩CMS\lx-cms-backend\vendor\workerman\webman-framework\src\support\Container.php(46): DI\Container->make()
#9 D:\webman_workspace\乐轩CMS\lx-cms-backend\support\helpers.php(469): support\Container::__callStatic()
#10 D:\webman_workspace\乐轩CMS\lx-cms-backend\vendor\workerman\workerman\Worker.php(2494): {closure}()
#11 D:\webman_workspace\乐轩CMS\lx-cms-backend\vendor\workerman\workerman\Worker.php(1484): Workerman\Worker->run()
#12 D:\webman_workspace\乐轩CMS\lx-cms-backend\vendor\workerman\workerman\Worker.php(1402): Workerman\Worker::forkWorkersForWindows()
#13 D:\webman_workspace\乐轩CMS\lx-cms-backend\vendor\workerman\workerman\Worker.php(560): Workerman\Worker::forkWorkers()
#14 D:\webman_workspace\乐轩CMS\lx-cms-backend\runtime\windows\start_monitor.php(23): Workerman\Worker::runAll()
#15 {main}
process D:\webman_workspace\乐轩CMS\lx-cms-backend\runtime\windows\start_monitor.php terminated and try to restart

截图报错信息里报错文件相关代码

操作系统及workerman/webman等框架组件具体版本

"php": ">=7.2",
"workerman/webman-framework": "^1.5.0",
"monolog/monolog": "^2.0",
"psr/container": "1.1.1",
"webman/blade": "^1.5",
"illuminate/database": "^10.24",
"illuminate/pagination": "^10.24",
"illuminate/events": "^10.24",
"symfony/var-dumper": "^6.3",
"illuminate/redis": "^10.24",
"symfony/cache": "^6.3",
"topthink/think-validate": "^2.0",
"intervention/image": "^2.7",
"webman/captcha": "^1.0",
"vlucas/phpdotenv": "^5.5",
"webman/event": "^1.0",
"php-di/php-di": "6",
"doctrine/annotations": "1.14"

668 1 0
1个回答

nitron

getClass() is deprecated

simple and clean

  • xtn 2023-09-27

    更新到最新版改了下方法 已经可以

年代过于久远,无法发表回答
×
🔝