From bb0c7b2943f4a56989dbad66a2d392a28dee5e91 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 21 Feb 2018 08:51:46 +0100 Subject: [PATCH] Make AppFramework/Http/Dispatcher strict Signed-off-by: Roeland Jago Douma --- lib/private/AppFramework/Http/Dispatcher.php | 24 +++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/private/AppFramework/Http/Dispatcher.php b/lib/private/AppFramework/Http/Dispatcher.php index ecf8462ebb..6219ba47a4 100644 --- a/lib/private/AppFramework/Http/Dispatcher.php +++ b/lib/private/AppFramework/Http/Dispatcher.php @@ -1,4 +1,5 @@ middlewareDispatcher->afterException( $controller, $methodName, $exception); - if (is_null($response)) { + if ($response === null) { throw $exception; } } @@ -126,11 +134,11 @@ class Dispatcher { * @param string $methodName the method on the controller that should be executed * @return Response */ - private function executeController($controller, $methodName) { - $arguments = array(); + private function executeController(Controller $controller, string $methodName): Response { + $arguments = []; // valid types that will be casted - $types = array('int', 'integer', 'bool', 'boolean', 'float'); + $types = ['int', 'integer', 'bool', 'boolean', 'float']; foreach($this->reflector->getParameters() as $param => $default) { @@ -151,14 +159,14 @@ class Dispatcher { ) { $value = false; - } elseif($value !== null && in_array($type, $types)) { + } elseif($value !== null && \in_array($type, $types, true)) { settype($value, $type); } $arguments[] = $value; } - $response = call_user_func_array(array($controller, $methodName), $arguments); + $response = \call_user_func_array([$controller, $methodName], $arguments); // format response if($response instanceof DataResponse || !($response instanceof Response)) {