From 38a0af6b86a824f7ea9efdcfb1fceaf5915124d6 Mon Sep 17 00:00:00 2001 From: Arsen Mirzaev Tatyano-Muradovich Date: Sun, 12 Apr 2026 18:02:02 +0500 Subject: [PATCH] a litle bit reflection in the router, sorry --- mirzaev/minimal/system/core.php | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/mirzaev/minimal/system/core.php b/mirzaev/minimal/system/core.php index 8ed0bce..4fb2bd5 100755 --- a/mirzaev/minimal/system/core.php +++ b/mirzaev/minimal/system/core.php @@ -22,7 +22,10 @@ use Closure as closure, InvalidArgumentException as exception_argument, UnexpectedValueException as exception_value, LogicException as exception_logic, - ReflectionClass as reflection; + Error as error, + ArgumentCountError as error_argument_count, + ReflectionClass as reflection, + ReflectionMethod as reflection_method; /** * Core @@ -255,12 +258,21 @@ final class core // Writing the request options from the route options $request->options = $route->options; + // Initializing the controller method arguments + $arguments = $route->parameters + $route->variables + $request->parameters; + // Processing the method of the controller and exit (success) - $action = function() use ($route, $request): string { - try { - return (string) $route->controller->{$route->method}(...($route->parameters + $route->variables + $request->parameters)); - } catch (exception $exception) { - return (string) $route->controller->{$route->method}($route->parameters + $route->variables + $request->parameters); + $action = function () use ($route, $request, $arguments): string { + if (array_keys($arguments) === array_column((new reflection_method($route->controller, $route->method))->getParameters(), 'name')) { + // Arguments match the controller method arguments + + // Exit (success) + return (string) $route->controller->{$route->method}(...$arguments); + } else { + // Arguments not match the controller method arguments + + // Exit (success) + return (string) $route->controller->{$route->method}($arguments); } };