diff options
-rw-r--r-- | lib/private/AppFramework/Middleware/MiddlewareDispatcher.php | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/private/AppFramework/Middleware/MiddlewareDispatcher.php b/lib/private/AppFramework/Middleware/MiddlewareDispatcher.php index 60d2ae8b5c9..30efe815888 100644 --- a/lib/private/AppFramework/Middleware/MiddlewareDispatcher.php +++ b/lib/private/AppFramework/Middleware/MiddlewareDispatcher.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -30,7 +31,7 @@ namespace OC\AppFramework\Middleware; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\Response; -use OCP\AppFramework\MiddleWare; +use OCP\AppFramework\Middleware; /** * This class is used to store and run all the middleware in correct order @@ -53,7 +54,7 @@ class MiddlewareDispatcher { * Constructor */ public function __construct(){ - $this->middlewares = array(); + $this->middlewares = []; $this->middlewareCounter = 0; } @@ -71,7 +72,7 @@ class MiddlewareDispatcher { * returns an array with all middleware elements * @return array the middlewares */ - public function getMiddlewares(){ + public function getMiddlewares(): array { return $this->middlewares; } @@ -87,7 +88,7 @@ class MiddlewareDispatcher { public function beforeController(Controller $controller, $methodName){ // we need to count so that we know which middlewares we have to ask in // case there is an exception - $middlewareCount = count($this->middlewares); + $middlewareCount = \count($this->middlewares); for($i = 0; $i < $middlewareCount; $i++){ $this->middlewareCounter++; $middleware = $this->middlewares[$i]; @@ -111,7 +112,7 @@ class MiddlewareDispatcher { * exception * @throws \Exception the passed in exception if it can't handle it */ - public function afterException(Controller $controller, $methodName, \Exception $exception){ + public function afterException(Controller $controller, string $methodName, \Exception $exception): Response { for($i=$this->middlewareCounter-1; $i>=0; $i--){ $middleware = $this->middlewares[$i]; try { @@ -134,8 +135,8 @@ class MiddlewareDispatcher { * @param Response $response the generated response from the controller * @return Response a Response object */ - public function afterController(Controller $controller, $methodName, Response $response){ - for($i=count($this->middlewares)-1; $i>=0; $i--){ + public function afterController(Controller $controller, string $methodName, Response $response): Response { + for($i= \count($this->middlewares)-1; $i>=0; $i--){ $middleware = $this->middlewares[$i]; $response = $middleware->afterController($controller, $methodName, $response); } @@ -153,8 +154,8 @@ class MiddlewareDispatcher { * @param string $output the generated output from a response * @return string the output that should be printed */ - public function beforeOutput(Controller $controller, $methodName, $output){ - for($i=count($this->middlewares)-1; $i>=0; $i--){ + public function beforeOutput(Controller $controller, string $methodName, string $output): string { + for($i= \count($this->middlewares)-1; $i>=0; $i--){ $middleware = $this->middlewares[$i]; $output = $middleware->beforeOutput($controller, $methodName, $output); } |