diff --git a/Handler/OnRequest.php b/Handler/OnRequest.php index 5f77083..9c658a6 100644 --- a/Handler/OnRequest.php +++ b/Handler/OnRequest.php @@ -54,34 +54,6 @@ class OnRequest implements OnRequestInterface public ResponseEmitterInterface $responseEmitter; - /** - * @var Kiri\Router\Request - */ - #[Container(RequestInterface::class)] - public RequestInterface $request; - - - /** - * @var ResponseInterface - */ - #[Container(ResponseInterface::class)] - public ResponseInterface $response; - - - /** - * @var DataGrip - */ - #[Container(DataGrip::class)] - public DataGrip $dataGrip; - - - /** - * @var ContainerInterface - */ - #[Container(ContainerInterface::class)] - public ContainerInterface $container; - - /** * @var ConstrictResponse */ @@ -90,20 +62,24 @@ class OnRequest implements OnRequestInterface /** - * @return void + * @param ResponseInterface $response + * @param RequestInterface $request + * @param ContainerInterface $container + * @param DataGrip $dataGrip * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface * @throws ReflectionException */ - public function init(): void + public function __construct(public ResponseInterface $response, public RequestInterface $request, public ContainerInterface $container, + public DataGrip $dataGrip) { - $exception = $this->request->exception; + $this->responseEmitter = $this->response->emmit; + $exception = $this->request->exception; if (!in_array(ExceptionHandlerInterface::class, class_implements($exception))) { $exception = ExceptionHandlerDispatcher::class; } - $this->exception = $this->container->get($exception); - $this->router = $this->dataGrip->get(ROUTER_TYPE_HTTP); - $this->responseEmitter = $this->response->emmit; + $this->exception = $this->container->get($exception); + $this->router = $this->dataGrip->get(ROUTER_TYPE_HTTP); }