6 Commits

Author SHA1 Message Date
ec370baa45 fixed virtual property error 2026-04-17 11:08:04 +05:00
aca9694723 get hook fixed dolboyoub 2026-04-17 11:03:30 +05:00
23d7fc72a9 smartphone detection 2026-04-17 10:58:13 +05:00
38a0af6b86 a litle bit reflection in the router, sorry 2026-04-12 18:02:02 +05:00
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
3 changed files with 69 additions and 3 deletions

View File

@@ -22,7 +22,8 @@
"issues": "https://git.svoboda.works/mirzaev/minimal/issues"
},
"require": {
"php": "~8.4"
"php": "~8.4",
"mobiledetect/mobiledetectlib": "^4.8"
},
"suggest": {
"mirzaev/baza": "Baza database",

View File

@@ -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,8 +258,23 @@ 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 = fn(): string => (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);
}
};
foreach ($route->middlewares as $middleware) {
// Iterating over the route middlewares

View File

@@ -11,6 +11,9 @@ use mirzaev\minimal\http\enumerations\method,
mirzaev\minimal\http\enumerations\content,
mirzaev\minimal\http\response;
// The smartphones detection library
use Detection\MobileDetect as mobile;
// Built-in libraries
use DomainException as exception_domain,
InvalidArgumentException as exception_argument,
@@ -297,6 +300,50 @@ final class request
get => $this->options ?? [];
}
/**
* Smartphone
*
* @see https://docs.mobiledetect.net/home/usage-composer Documentation
*
* @var bool $smartphone The request was sent from a smartphone?
*/
public bool $smartphone {
// Read
get {
if (!isset($this->smartphone)) {
// The property is not initialized
// Writing into the property
$this->smartphone = new mobile()->isMobile();
}
// Exit (success)
return $this->smartphone;
}
}
/**
* Tablet
*
* @see https://docs.mobiledetect.net/home/usage-composer Documentation
*
* @var bool $tablet The request was sent from a tablet?
*/
public bool $tablet {
// Read
get {
if (!isset($this->tablet)) {
// The property is not initialized
// Writing into the property
$this->tablet = new mobile()->isTablet();
}
// Exit (success)
return $this->tablet;
}
}
/**
* Constructor
*