4 Commits

Author SHA1 Message Date
17c15b0860 fixed controller arguments fixing 2026-04-09 07:33:44 +05:00
b7eda7a944 controller arguments fixed 2026-04-08 15:03:49 +05:00
1123b75d9e fix magix static::class 2026-03-17 17:43:36 +05:00
6d1f1b79ba magic methods fixed 2026-03-09 09:10:11 +05:00
2 changed files with 25 additions and 6 deletions

View File

@@ -256,7 +256,13 @@ final class core
$request->options = $route->options; $request->options = $route->options;
// Processing the method of the controller and exit (success) // Processing the method of the controller and exit (success)
$action = fn(): string => (string) $route->controller->{$route->method}(...($route->parameters + $route->variables + $request->parameters)); $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);
}
};
foreach ($route->middlewares as $middleware) { foreach ($route->middlewares as $middleware) {
// Iterating over the route middlewares // Iterating over the route middlewares

View File

@@ -8,7 +8,8 @@ namespace mirzaev\minimal\traits;
use mirzaev\minimal\http\enumerations\status; use mirzaev\minimal\http\enumerations\status;
// Built-in libraries // Built-in libraries
use exception; use Exception as exception,
DomainException as exception_domain;
/** /**
* Trait of magical methods * Trait of magical methods
@@ -28,6 +29,8 @@ trait magic
/** /**
* Write property * Write property
* *
* @throws exception_domain Not found the proprty
*
* @param string $name Name of the property * @param string $name Name of the property
* @param mixed $value Value of the property * @param mixed $value Value of the property
* *
@@ -35,14 +38,24 @@ trait magic
*/ */
public function __set(string $name, mixed $value = null): void public function __set(string $name, mixed $value = null): void
{ {
match ($name) { if (property_exists(static::static, $name)) {
default => throw new exception('Failed to find property: ' . static::class . "::\$$name", status::not_found->value) // Exist the property
};
// Writing the property
$this->{$name} = $value;
} else {
// Not exist the property
// Exit (fail)
throw new exception_domain('Not found the property: ' . static::class . "::\$$name", status::not_found->value);
}
} }
/** /**
* Read property * Read property
* *
* @throws exception_domain Not found the property
*
* @param string $name Name of the property * @param string $name Name of the property
* *
* @return mixed Value of the property * @return mixed Value of the property
@@ -50,7 +63,7 @@ trait magic
public function __get(string $name): mixed public function __get(string $name): mixed
{ {
return match ($name) { return match ($name) {
default => throw new exception('Failed to find property: ' . static::class . "::\$$name", status::not_found->value) default => throw new exception_domain('Not found the property: ' . static::class . "::\$$name", status::not_found->value)
}; };
} }