diff --git a/src/App.php b/src/App.php index 983e52f..febf6f1 100644 --- a/src/App.php +++ b/src/App.php @@ -89,7 +89,7 @@ public function process(ServerRequestInterface $request, ResponseInterface $resp } foreach (array_reverse($route->getMiddlewares()) as $middleware) { - $controller->addMiddleware($this->container[$middleware]); + $controller->addMiddleware($this->container->get($middleware)); } return $controller->callMiddlewareStack($request, $response); diff --git a/src/ClosureController.php b/src/ClosureController.php index 2241c7f..8260730 100644 --- a/src/ClosureController.php +++ b/src/ClosureController.php @@ -24,7 +24,7 @@ public function __construct(\Closure $controller) public function __invoke( ServerRequestInterface $request, ResponseInterface $response, - \Closure $next = null + callable $next = null ): ResponseInterface { return ($this->controller)($request,$response); } diff --git a/src/Controller.php b/src/Controller.php index d675f86..c7c5c28 100644 --- a/src/Controller.php +++ b/src/Controller.php @@ -24,7 +24,7 @@ public function __construct(ControllerInterface $controller) public function __invoke( ServerRequestInterface $request, ResponseInterface $response, - \Closure $next = null + callable $next = null ): ResponseInterface { return ($this->controller)($request,$response); } diff --git a/src/Interfaces/MiddlewareInterface.php b/src/Interfaces/MiddlewareInterface.php index 57caaa2..6dfef7c 100644 --- a/src/Interfaces/MiddlewareInterface.php +++ b/src/Interfaces/MiddlewareInterface.php @@ -11,6 +11,6 @@ interface MiddlewareInterface public function __invoke( ServerRequestInterface $request, ResponseInterface $response, - \Closure $next = null + callable $next = null ): ResponseInterface; } \ No newline at end of file diff --git a/src/Middleware.php b/src/Middleware.php index fb389ee..4ca6c09 100644 --- a/src/Middleware.php +++ b/src/Middleware.php @@ -14,7 +14,7 @@ trait Middleware */ protected $top; - protected function addMiddleware(callable $callable) + public function addMiddleware(callable $callable) { if (is_null($this->top)) { $this->initStack();