diff --git a/src/Annotate/AbstractRequestMethod.php b/src/Annotate/AbstractRequestMethod.php index c58c49f..31c3526 100644 --- a/src/Annotate/AbstractRequestMethod.php +++ b/src/Annotate/AbstractRequestMethod.php @@ -3,35 +3,9 @@ declare(strict_types=1); namespace Kiri\Router\Annotate; -use Kiri\Router\Base\Middleware as MiddlewareManager; -use ReflectionException; abstract class AbstractRequestMethod { - /** - * @param object $class - * @param string $method - * @return void - * @throws ReflectionException - * @throws \Exception - */ - public function registerMiddleware(object $class, string $method): void - { - $reflectionMethod = \Kiri::getDi()->getMethod($class::class, $method); - $middleware = $reflectionMethod->getAttributes(Middleware::class); - - $middlewareManager = \Kiri::getDi()->get(MiddlewareManager::class); - foreach ($middleware as $value) { - if (!class_exists($value->getName())) { - continue; - } - /** @var Middleware $instance */ - $instance = $value->newInstance(); - - $middlewareManager->set($class::class, $method, $instance->middleware); - } - } - } diff --git a/src/Annotate/AutoController.php b/src/Annotate/AutoController.php index 6b133a4..6e9c51b 100644 --- a/src/Annotate/AutoController.php +++ b/src/Annotate/AutoController.php @@ -4,12 +4,14 @@ declare(strict_types=1); namespace Kiri\Router\Annotate; +use ReflectionException; + #[\Attribute(\Attribute::TARGET_CLASS)] class AutoController { /** - * @throws \ReflectionException + * @throws ReflectionException */ public function dispatch(object $object): void { diff --git a/src/Annotate/Delete.php b/src/Annotate/Delete.php index a7a97ff..236e9e6 100644 --- a/src/Annotate/Delete.php +++ b/src/Annotate/Delete.php @@ -14,10 +14,10 @@ class Delete extends AbstractRequestMethod implements InjectRouteInterface { - - /** - * @param string $path - */ + /** + * @param string $path + * @param string $version + */ public function __construct(readonly public string $path, readonly public string $version = 'v1') { } diff --git a/src/Annotate/Head.php b/src/Annotate/Head.php index a8299a7..a7a0e69 100644 --- a/src/Annotate/Head.php +++ b/src/Annotate/Head.php @@ -14,11 +14,10 @@ class Head extends AbstractRequestMethod implements InjectRouteInterface { - - - /** - * @param string $path - */ + /** + * @param string $path + * @param string $version + */ public function __construct(readonly public string $path, readonly public string $version = 'v1') { } diff --git a/src/Annotate/Options.php b/src/Annotate/Options.php index b19f774..19e7b19 100644 --- a/src/Annotate/Options.php +++ b/src/Annotate/Options.php @@ -14,11 +14,10 @@ class Options extends AbstractRequestMethod implements InjectRouteInterface { - - - /** - * @param string $path - */ + /** + * @param string $path + * @param string $version + */ public function __construct(readonly public string $path, readonly public string $version = 'v1') { } diff --git a/src/Annotate/Put.php b/src/Annotate/Put.php index 691aedf..227129e 100644 --- a/src/Annotate/Put.php +++ b/src/Annotate/Put.php @@ -14,11 +14,10 @@ class Put extends AbstractRequestMethod implements InjectRouteInterface { - - - /** - * @param string $path - */ + /** + * @param string $path + * @param string $version + */ public function __construct(readonly public string $path, readonly public string $version = 'v1') { } diff --git a/src/Annotate/Route.php b/src/Annotate/Route.php index 4e4b940..c4d55ba 100644 --- a/src/Annotate/Route.php +++ b/src/Annotate/Route.php @@ -12,10 +12,11 @@ class Route extends AbstractRequestMethod implements InjectRouteInterface { - /** - * @param string $path - * @param RequestMethod $method - */ + /** + * @param string $path + * @param RequestMethod $method + * @param string $version + */ public function __construct(readonly public string $path, readonly public RequestMethod $method, readonly public string $version = 'v1') { }