From d402b6b2769f7cf0f4f4be939472f472a4f9fe01 Mon Sep 17 00:00:00 2001 From: Juan Cristobal <65052633+juancristobalgd1@users.noreply.github.com> Date: Sun, 4 Aug 2024 18:27:04 +0200 Subject: [PATCH] Update Controller.php --- src/Controller.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Controller.php b/src/Controller.php index dfb0a70..4a5d84c 100644 --- a/src/Controller.php +++ b/src/Controller.php @@ -73,9 +73,8 @@ private function registerDefaultMiddleware() { $middlewares = BaseMiddleware::$httpMiddlewares; foreach ($middlewares as $middleware) { - if (is_subclass_of($middleware, BaseMiddleware::class)) { + if (is_subclass_of($middleware, BaseMiddleware::class)) $this->middlewares[] = new $middleware; - } } } @@ -185,10 +184,9 @@ public function request(): ?Request */ public function __call(string $name, array $params) { - if (method_exists($this, $name)) { + if (method_exists($this, $name)) return $this->$name(...$params); - } - + throw new BadMethodCallException(sprintf('Method [%s] does not exist', $name)); } }