From 948f9c330812b808797ef2ce0c46efe034d8e756 Mon Sep 17 00:00:00 2001 From: sunxyw Date: Mon, 13 Feb 2023 04:06:59 +0800 Subject: [PATCH 1/2] add invalid definition solutions --- src/ZM/Exception/Solution/SolutionRepository.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ZM/Exception/Solution/SolutionRepository.php b/src/ZM/Exception/Solution/SolutionRepository.php index 7350b4a6..b8f4d4ca 100644 --- a/src/ZM/Exception/Solution/SolutionRepository.php +++ b/src/ZM/Exception/Solution/SolutionRepository.php @@ -6,6 +6,7 @@ declare(strict_types=1); namespace ZM\Exception\Solution; +use DI\Definition\Exception\InvalidDefinition; use NunoMaduro\Collision\Contracts\SolutionsRepository; class SolutionRepository implements SolutionsRepository @@ -17,6 +18,14 @@ class SolutionRepository implements SolutionsRepository { return match ($throwable::class) { default => [], + InvalidDefinition::class => [ + new Solution('无法解析依赖注入', '请检查依赖注入的类是否存在,或者定义是否正确。', []), + new Solution( + '依赖注入用例错误', + '请检查注入的类是否在对应的事件中可用,详情可以查看文档。', + ['https://framework.zhamao.xin/components/container/dependencies.html'] + ), + ], }; } } From 114f7123412ce5b09fb5e0e926fa5ee2d35d2bf1 Mon Sep 17 00:00:00 2001 From: sunxyw Date: Mon, 13 Feb 2023 04:07:41 +0800 Subject: [PATCH 2/2] add route method parameters note --- src/Module/Example/Hello123.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Module/Example/Hello123.php b/src/Module/Example/Hello123.php index 04af321c..135d0b9e 100644 --- a/src/Module/Example/Hello123.php +++ b/src/Module/Example/Hello123.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Module\Example; +use Choir\Http\ServerRequest; use Choir\WebSocket\FrameInterface; use OneBot\Driver\Coroutine\Adaptive; use OneBot\Driver\Event\WebSocket\WebSocketMessageEvent; @@ -23,8 +24,10 @@ class Hello123 #[Route('/route', request_method: ['GET'])] #[Route('/route/{id}', request_method: ['GET'])] #[Middleware(TimerMiddleware::class)] - public function route(array $params) + public function route(array $params, ServerRequest $request, \HttpRequestEvent $event) { + // 目前因内部实现限制,路由方法的参数必须按照这个顺序定义,可以省略,但是不能乱序 + // 如果希望获取其他依赖,可以在现有参数后面继续添加 return 'Hello Zhamao!This is the first 3.0 page!' . ($params['id'] ?? ''); }