From e40db9d1fbb91428661ae2f4449f20ef7aab719a Mon Sep 17 00:00:00 2001 From: whwyy Date: Wed, 24 Jun 2026 20:49:06 +0800 Subject: [PATCH] eee --- src/Router.php | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/Router.php b/src/Router.php index c97e638..60af75a 100644 --- a/src/Router.php +++ b/src/Router.php @@ -312,14 +312,24 @@ class Router ); $scanner->setConfig($scanConfig); - // 获取 Master 扫描产生的完整清单,遍历所有已注册类重建注解路由 $manifestEntries = $scanner->getManifestClasses(); + if (empty($manifestEntries)) { + \Kiri::getLogger()->warning('Annotation route rebuild: manifest is empty, annotation routes will NOT be registered'); + return; + } + + $routeCount = 0; + $classCount = 0; + $errorCount = 0; + $dispatchCount = 0; + foreach ($manifestEntries as $path => $entry) { $classes = is_array($entry) && isset($entry['classes']) ? $entry['classes'] : []; foreach ($classes as $class) { if (!class_exists($class)) { continue; } + $classCount++; try { $reflect = $container->getReflectionClass($class); if (!$reflect->isInstantiable() || $reflect->isTrait() || $reflect->isEnum() || $reflect->isInterface()) { @@ -338,17 +348,25 @@ class Router $instance = $attribute->newInstance(); if ($instance instanceof Kiri\Di\Interface\InjectMethodInterface) { $instance->dispatch($class, $method->getName()); + $dispatchCount++; } } catch (\Throwable $e) { - \Kiri::getLogger()->error("AnnotationRoute rebuild [{$class}::{$method->getName()}]: " . $e->getMessage()); + $errorCount++; + \Kiri::getLogger()->error("Annotation rebuild error [{$class}::{$method->getName()} @ {$attrName}]: {$e->getMessage()}"); } } } } catch (\Throwable $e) { - \Kiri::getLogger()->error("AnnotationRoute class [{$class}]: " . $e->getMessage()); + $errorCount++; + \Kiri::getLogger()->error("Annotation rebuild class [{$class}]: {$e->getMessage()}"); } } } + + $router = $container->get(DataGrip::class)->get(static::$type); + $routeCount = count($router->dump()); + + \Kiri::getLogger()->info("Annotation route rebuild: {$classCount} classes processed, {$dispatchCount} annotation routes dispatched, {$routeCount} total routes, {$errorCount} errors"); }