From 397d8340f6ca31c614c87625dfaf2d19def32cda Mon Sep 17 00:00:00 2001 From: dconco Date: Sun, 25 Aug 2024 06:28:45 +0100 Subject: [PATCH 1/2] Added Authorization Guard --- ChangeLog.md | 24 +- Console/Console.php | 8 +- Router/Interface/RouteInterface.php | 8 + Router/Route.php | 50 +- composer.json | 2 +- src/Config/cors.php | 36 +- src/Config/{middleware.php => guards.php} | 2 +- src/ConsoleL/Command.php | 123 +- src/ConsoleL/Interface/CommandInterface.php | 5 +- src/Foundation/Application.php | 28 +- src/Foundation/Render.php | 39 +- .../template/api/ApiController.php.dist | 2 +- .../template/commands/Commands.md.dist | 8 +- .../template/guards/AuthGuard.php.dist | 20 + .../template/middleware/Middleware.php.dist | 9 - src/Globals/Chunks/trace.php | 8 +- src/Globals/Functions.php | 4 +- src/Http/Api.php | 1257 ++++++++--------- src/Http/{Interface => }/ApiController.php | 38 +- src/Http/Auth/AuthGuard.php | 48 + src/Http/Interface/ApiInterface.php | 39 +- src/Http/Interface/AuthGuardInterface.php | 17 + src/Http/Interface/RequestInterface.php | 32 +- src/Http/Request.php | 151 +- src/Interface/MiddlewareInterface.php | 11 - src/Middleware/Middleware.php | 0 src/Traits/Resources/ApiResources.php | 87 +- src/Traits/Resources/RouteResources.php | 89 +- 28 files changed, 1024 insertions(+), 1121 deletions(-) rename src/Config/{middleware.php => guards.php} (68%) create mode 100644 src/Foundation/template/guards/AuthGuard.php.dist delete mode 100644 src/Foundation/template/middleware/Middleware.php.dist rename src/Http/{Interface => }/ApiController.php (82%) create mode 100644 src/Http/Auth/AuthGuard.php create mode 100644 src/Http/Interface/AuthGuardInterface.php delete mode 100644 src/Interface/MiddlewareInterface.php delete mode 100644 src/Middleware/Middleware.php diff --git a/ChangeLog.md b/ChangeLog.md index a922467..68b48dd 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,21 +1,11 @@ # Change Logs -## [v1.2.6] +## [v1.2.9] -### [Tue, 20-08-2024] +### [Sat, 24-08-2024] -- Fixes bugs on `Request` -- Fixes bugs on `JWT` and `payload()` function. - -## [v1.2.7] - -### [Wed, 21-08-2024] - -- Update API `route` method to allow a particular request method and a particular controller method - -## [v1.2.8] - -### [Thu, 22-08-2024] - -- Updated `Render` getting value from array according to strict types -- Changed API controller namespace to `App\Controller\Api` +- Added Authorization Guard. +- Implemented AuthGuard to Routes +- Implemented AuthGuard to APIs +- Middleware is now deprecated and removed +- Added AuthGuard to Console \ No newline at end of file diff --git a/Console/Console.php b/Console/Console.php index dc669ed..964eb75 100644 --- a/Console/Console.php +++ b/Console/Console.php @@ -66,13 +66,13 @@ public function __construct(array $argv) self::$commands = ['api-controller', $arguments]; break; - case 'make:middleware': + case 'make:auth-guard': if (count($arguments) < 1) { exit( " argument is required! Type --help for list of commands\n" ); } - self::$commands = ['middleware', $arguments]; + self::$commands = ['auth-guard', $arguments]; break; case 'generate:secret-key': @@ -111,8 +111,8 @@ public function __destruct() case 'api-controller': self::makeApiController(self::$commands[1], self::$resolve); break; - case 'middleware': - self::makeMiddleware(self::$commands[1], self::$resolve); + case 'auth-guard': + self::makeAuthGuard(self::$commands[1], self::$resolve); break; case 'secret-key': self::generateSecretKey(self::$commands[1]); diff --git a/Router/Interface/RouteInterface.php b/Router/Interface/RouteInterface.php index 65ca931..757619c 100644 --- a/Router/Interface/RouteInterface.php +++ b/Router/Interface/RouteInterface.php @@ -113,6 +113,14 @@ public function use(string $controller): self; */ public function file(string $file): self; + /** + * Applies Authentication Guard to the current route. + * + * @param string ...$guards String parameters of registered guards. + * @return self + */ + public function withGuard(string ...$guards): self; + /** * --------------------------------------------------------------------------- * diff --git a/Router/Route.php b/Router/Route.php index 5e12a7a..e6bac55 100644 --- a/Router/Route.php +++ b/Router/Route.php @@ -62,13 +62,17 @@ class Route extends Controller implements RouteInterface */ public static string $root_dir; - private static array $routes; + private ?array $guards = null; - private static array $route; + private mixed $action = null; - private static mixed $action = null; + private ?string $use = null; - private static ?array $middleware = null; + private ?string $file = null; + + private static array $routes; + + private static array $route; private static ?array $redirect = null; @@ -78,10 +82,6 @@ class Route extends Controller implements RouteInterface private static ?array $view = null; - private static ?string $use = null; - - private static ?string $file = null; - private static ?array $map = null; /** @@ -343,7 +343,7 @@ public function name(string $name): self public function action(mixed $callback): self { if (self::$map) { - self::$action = $callback; + $this->action = $callback; } return $this; } @@ -358,7 +358,7 @@ public function action(mixed $callback): self public function use(string $controller): self { if (self::$map) { - self::$use = $controller; + $this->use = $controller; } return $this; } @@ -372,19 +372,21 @@ public function use(string $controller): self public function file(string $file): self { if (self::$map) { - self::$file = $file; + $this->file = $file; } return $this; } /** - * Add Middlewares. - * Middleware must be verified before redirecting to the specific Controller. + * Applies Authentication Guard to the current route. + * + * @param string ...$guards String parameters of registered guards. + * @return self */ - public function middleware(array $middleware): self + public function withGuard(string ...$guards): self { if (self::$map || self::$method || self::$view) { - self::$middleware = $middleware; + $this->guards = $guards; } return $this; } @@ -557,9 +559,9 @@ public function __destruct() $GLOBALS['__registered_routes'][$route_index]['map'] = self::$map; } - if (self::$middleware !== null) { - $GLOBALS['__registered_routes'][$route_index]['middleware'] = - self::$middleware; + if ($this->guards !== null) { + $GLOBALS['__registered_routes'][$route_index]['guards'] = + $this->guards; } if (self::$redirect !== null) { @@ -567,21 +569,21 @@ public function __destruct() self::$redirect; } - if (self::$action !== null) { + if ($this->action !== null) { $GLOBALS['__registered_routes'][$route_index]['action'] = - self::$action; + $this->action; } if (self::$any !== null) { $GLOBALS['__registered_routes'][$route_index]['any'] = self::$any; } - if (self::$use !== null) { - $GLOBALS['__registered_routes'][$route_index]['use'] = self::$use; + if ($this->use !== null) { + $GLOBALS['__registered_routes'][$route_index]['use'] = $this->use; } - if (self::$file !== null) { - $GLOBALS['__registered_routes'][$route_index]['file'] = self::$file; + if ($this->file !== null) { + $GLOBALS['__registered_routes'][$route_index]['file'] = $this->file; } if (self::$method !== null) { diff --git a/composer.json b/composer.json index 75b8ac5..22482c3 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "firebase/php-jwt": "^6.10" }, "suggest": { - "phpslides/status": "^0.0.1" + "phpslides/status": "^0.0.3" }, "require-dev": { "phpunit/phpunit": "^11.2" diff --git a/src/Config/cors.php b/src/Config/cors.php index 5610778..1899776 100644 --- a/src/Config/cors.php +++ b/src/Config/cors.php @@ -4,35 +4,35 @@ use PhpSlides\Loader\FileLoader; use PhpSlides\Foundation\Application; -$cors = (new FileLoader()) - ->safeLoad(Application::$configsDir . 'cors.php') - ->getLoad() ?: []; +$cors = + (new FileLoader()) + ->safeLoad(Application::$configsDir . 'cors.php') + ->getLoad() ?: + []; -foreach ($cors as $key => $value) -{ +foreach ($cors as $key => $value) { $key = 'Access-Control-' . str_replace('_', '-', ucwords($key, '_')); $value = is_array($value) ? implode(', ', $value) : $value; $header_value = - $key . ': ' . (is_bool($value) ? var_export($value, true) : $value); + $key . ': ' . (is_bool($value) ? var_export($value, true) : $value); header($header_value); } -/** - * Handle preflight requests (OPTIONS method) - */ -if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') -{ - new Log(); - http_response_code(200); - exit; -} - class Log { use Logger; - public function __construct () + public function __construct() { self::log(); } -} \ No newline at end of file +} + +/** + * Handle preflight requests (OPTIONS method) + */ +if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') { + new Log(); + http_response_code(200); + exit(); +} diff --git a/src/Config/middleware.php b/src/Config/guards.php similarity index 68% rename from src/Config/middleware.php rename to src/Config/guards.php index 96554b3..fbe273d 100644 --- a/src/Config/middleware.php +++ b/src/Config/guards.php @@ -4,5 +4,5 @@ use PhpSlides\Foundation\Application; return (new FileLoader()) - ->safeLoad(Application::$configsDir . 'middleware.php') + ->safeLoad(Application::$configsDir . 'guards.php') ->getLoad() ?: []; \ No newline at end of file diff --git a/src/ConsoleL/Command.php b/src/ConsoleL/Command.php index 70ee453..b8cb3a8 100644 --- a/src/ConsoleL/Command.php +++ b/src/ConsoleL/Command.php @@ -3,25 +3,25 @@ namespace PhpSlides\ConsoleL; use PhpSlides\Http\Request; +use PhpSlides\Http\ApiController; +use PhpSlides\Http\Auth\AuthGuard; use PhpSlides\Controller\Controller; use PhpSlides\ConsoleL\Style\Console; -use PhpSlides\Http\Interface\ApiController; -use PhpSlides\Interface\MiddlewareInterface; use PhpSlides\ConsoleL\Interface\CommandInterface; class Command implements CommandInterface { - public static function showHelp (): void + public static function showHelp(): void { echo file_get_contents( - dirname(__DIR__) . '/Foundation/template/commands/Commands.md.dist' + dirname(__DIR__) . '/Foundation/template/commands/Commands.md.dist' ); exit(); } - public static function makeController ( - array $arguments, - string $baseDir, + public static function makeController( + array $arguments, + string $baseDir ): void { $cn = $arguments[0]; $ct = $arguments[1] ?? null; @@ -38,8 +38,8 @@ public static function makeController ( $classname = $namespace . '\\' . $cn; $content = file_get_contents( - dirname(__DIR__) . - '/Foundation/template/controller/Controller.php.dist' + dirname(__DIR__) . + '/Foundation/template/controller/Controller.php.dist' ); $strict = $ct === '--strict' ? 'declare(strict_types=1);' : ''; @@ -48,46 +48,41 @@ public static function makeController ( $content = str_replace('{{name}}', $cn, $content); $content = str_replace( - 'load(__DIR__ . '/../Config/env.config.php'); - $loader->load(__DIR__ . '/../Config/config.php'); - self::$log = getenv('APP_DEBUG') == 'true' ? true : false; + + $loader->load(__DIR__ . '/../Config/config.php'); Route::config(); $loader - ->load(__DIR__ . '/../Globals/Functions.php') - ->load(self::$renderRoutePath); + ->load(__DIR__ . '/../Globals/Functions.php') + ->load(self::$renderRoutePath); } } diff --git a/src/Foundation/Render.php b/src/Foundation/Render.php index 7054b90..6afa2ff 100644 --- a/src/Foundation/Render.php +++ b/src/Foundation/Render.php @@ -13,8 +13,7 @@ final class Render extends Controller { use Resources; - - private static function Load () + private static function Load() { self::$request_uri = Application::$request_uri; } @@ -22,16 +21,15 @@ private static function Load () /** * Render the web route - primary routing */ - public static function WebRoute () + public static function WebRoute() { self::Load(); $reg_route = $GLOBALS['__registered_routes'] ?? []; - foreach ($reg_route as $route) - { - self::$middleware = $route['middleware'] ?? null; + foreach ($reg_route as $route) { self::$redirect = $route['redirect'] ?? null; self::$method = $route['method'] ?? null; + self::$guards = $route['guards'] ?? null; self::$action = $route['action'] ?? null; self::$view = $route['view'] ?? null; self::$file = $route['file'] ?? null; @@ -39,58 +37,49 @@ public static function WebRoute () self::$use = $route['use'] ?? null; self::$map = $route['map'] ?? null; - if (self::$map) - { + if (self::$map) { self::__map(); } - if (self::$redirect) - { + if (self::$redirect) { self::__redirect(); } - if (self::$method) - { + if (self::$method) { self::__method(); } - if (self::$view) - { + if (self::$view) { self::__view(); } - if (self::$any) - { + if (self::$any) { self::__any(); } } } - public static function ApiRoute () + public static function ApiRoute() { self::Load(); $static = new static(); $reg_route = $GLOBALS['__registered_api_routes'] ?? []; - foreach ($reg_route as $route) - { + foreach ($reg_route as $route) { self::$apiMap = $route['map'] ?? null; self::$route = $route['route'] ?? null; - self::$apiMiddleware = $route['middleware'] ?? null; - if (self::$route) - { + if (self::$route) { $static->__route(); } - if (self::$apiMap) - { + if (self::$apiMap) { $static->__api_map(); } } } - public static function FormsRoute () + public static function FormsRoute() { self::Load(); $reg_route = $GLOBALS['__registered_forms_routes'] ?? null; diff --git a/src/Foundation/template/api/ApiController.php.dist b/src/Foundation/template/api/ApiController.php.dist index 169c908..afdd14c 100644 --- a/src/Foundation/template/api/ApiController.php.dist +++ b/src/Foundation/template/api/ApiController.php.dist @@ -1,6 +1,6 @@ Create a route controller class. make:api-controller [name] Create an API controller class. - make:middleware [name] Create a middleware class. + make:auth-guard [name] Create an AuthGuard class. generate:secret-key Generate a random bytes of string used for JWT secret keys for generating tokens. -h, --help Show this help message and exit. @@ -18,8 +18,8 @@ Examples: php slide make:api-controller Product Creates an API controller class named `ProductController`. - php slide make:middleware Auth - Creates a middleware class named `AuthMiddleware`. + php slide make:auth-guard Token + Creates an AuthGuard class named `TokenGuard`. php slide generate:secret-key 20 It creates 20 random characters for secret keys. diff --git a/src/Foundation/template/guards/AuthGuard.php.dist b/src/Foundation/template/guards/AuthGuard.php.dist new file mode 100644 index 0000000..29e5f6b --- /dev/null +++ b/src/Foundation/template/guards/AuthGuard.php.dist @@ -0,0 +1,20 @@ +request->body(); + + if (!$body) { + echo 'No request body!'; + return false; + } + return true; + } +} \ No newline at end of file diff --git a/src/Foundation/template/middleware/Middleware.php.dist b/src/Foundation/template/middleware/Middleware.php.dist deleted file mode 100644 index 51d6a81..0000000 --- a/src/Foundation/template/middleware/Middleware.php.dist +++ /dev/null @@ -1,9 +0,0 @@ -load(__DIR__ . '/Chunks/trace.php'); $trace = filterTrace($exception->getTrace()); - $file = $trace[0]['file']; - $line = $trace[0]['line']; + $file = $trace[0]['file'] ?? ''; + $line = $trace[0]['line'] ?? 0; $codeSnippet = getCodeSnippet($file, $line, 10, 10); $detailedMessage = sprintf( diff --git a/src/Http/Api.php b/src/Http/Api.php index a02049d..a3dd27f 100644 --- a/src/Http/Api.php +++ b/src/Http/Api.php @@ -28,40 +28,31 @@ class Api extends Controller implements ApiInterface * The API version. Default is 'v1' * @var string */ - private ?array $route = null; + private static string $version = 'v1'; private ?array $define = null; - private static string $version = 'v1'; - - private static ?array $middleware = null; + private ?array $guards = null; private static array $regRoute = []; private static array $allRoutes; - private static ?array $map = null; - /** * Handles static method calls to set the API version dynamically. * * @param string $method The method name which starts with 'v' followed by the version number. Use `_` in place of `.` - * @param mixed $args The arguments for the method (not used). - * - * @throws \Exception + * @throws \PhpSlides\Exception * @return self */ - public static function __callStatic ($method, $args): self + public static function __callStatic($method, $args): self { - if (str_starts_with($method, 'v')) - { + if (str_starts_with($method, 'v')) { $method_v = str_replace('_', '.', $method); self::$version = $method_v; return new self(); - } - else - { + } else { throw new Exception('Version method starts with `v`'); } } @@ -72,12 +63,10 @@ public static function __callStatic ($method, $args): self * @param string $name The name to assign to the route. * @return self */ - public function name (string $name): self + public function name(string $name): self { - if (is_array(end(self::$regRoute))) - { - for ($i = 0; $i < count(end(self::$regRoute)); $i++) - { + if (is_array(end(self::$regRoute))) { + for ($i = 0; $i < count(end(self::$regRoute)); $i++) { add_route_name($name . '::' . $i, end(self::$regRoute)[$i]); self::$allRoutes[$name . '::' . $i] = end(self::$regRoute)[$i]; } @@ -97,54 +86,60 @@ public function name (string $name): self * if null is given, then it's consider dynamic, accepts all methods. * @return self */ - public function route ( - string $url, - string|array|null $controller = null, - ?string $req_method = null, + public function route( + string $url, + string|array|null $controller = null, + ?string $req_method = null ): self { $define = $this->define; // checks if $define is set, then assign $define methods to $url & $controller parameters $url = - $define !== null - ? rtrim($define['url'], '/') . '/' . trim($url, '/') - : trim($url, '/'); + $define !== null + ? rtrim($define['url'], '/') . '/' . trim($url, '/') + : trim($url, '/'); $url = trim($url, '/'); $uri = strtolower(self::$BASE_URL . self::$version . '/' . $url); self::$regRoute[] = $uri; - $this->route = [ - 'url' => $uri, - 'r_method' => $req_method, - 'controller' => - $define['controller'] ?? - (is_array($controller) ? $controller[0] : $controller) + $route = [ + 'url' => $uri, + 'guards' => $this->guards ?? null, + 'r_method' => $req_method, + 'controller' => + $define['controller'] ?? + (is_array($controller) ? $controller[0] : $controller) ]; - if ($define !== null && $controller !== null) - { - $this->route['c_method'] = trim($controller, '@'); + if ($define !== null && $controller !== null) { + $route['c_method'] = trim($controller, '@'); } - if (is_array($controller)) - { - $this->route['c_method'] = $controller[1]; + if (is_array($controller)) { + $route['c_method'] = $controller[1]; } + $GLOBALS['__registered_api_routes'][$uri]['route'] = $route; + $newInstance = new self(); $newInstance->define = $define; + $newInstance->guards = $this->guards ?? null; return $newInstance; } /** - * Applies middleware to the current route. + * Applies Authentication Guard to the current route. * - * @param array $middleware An array of middleware classes. + * @param ?string ...$guards String parameters of registered guards. * @return self */ - public function middleware (array $middleware): self + public function withGuard(?string ...$guards): self { - self::$middleware = $middleware; + if (!$guards[0]) { + $this->guards = null; + } else { + $this->guards = $guards; + } return $this; } @@ -155,11 +150,11 @@ public function middleware (array $middleware): self * @param string $controller The controller handling the routes. * @return self */ - public function define (string $url, string $controller): self + public function define(string $url, string $controller): self { $this->define = [ - 'url' => $url, - 'controller' => $controller + 'url' => $url, + 'controller' => $controller ]; return $this; @@ -171,2299 +166,2279 @@ public function define (string $url, string $controller): self * @param array An associative array where the key is the route and the value is an array with the HTTP method and controller method. * @return self */ - public function map (array $rest_url): self + public function map(array $rest_url): self { $define = $this->define; - if ($define !== null) - { + if ($define !== null) { /** * Get the map value, keys as the route url */ $routes = array_keys($rest_url); $base = strtolower( - self::$BASE_URL . - self::$version . - '/' . - trim($define['url'], '/') . - '/' + self::$BASE_URL . + self::$version . + '/' . + trim($define['url'], '/') . + '/' ); /** * Map route url array to the full base url */ - $full_url = array_map(function ($route) use ($base) - { - return $base . ltrim($route, '/'); - }, $routes); + $full_url = array_map( + fn($route) => $base . ltrim($route, '/'), + $routes + ); + + $rest_url = array_map(function ($uri) { + $uri[] = $this->guards ?? null; + return $uri; + }, $rest_url); self::$regRoute[] = $full_url; $rest_url['base_url'] = $base; $rest_url['controller'] = $define['controller']; - self::$map = $rest_url; + + $map = $rest_url; + $GLOBALS['__registered_api_routes'][$full_url[0]]['map'] = $map; } $newInstance = new self(); $newInstance->define = $define; + $newInstance->guards = $this->guards ?? null; return $newInstance; } - /** - * Automatically handles middleware, route, and map finalization when the object is destroyed. - */ - public function __destruct () - { - $route_index = end(self::$regRoute); - $route_index = is_array($route_index) ? $route_index[0] : $route_index; - - if (self::$middleware !== null) - { - $GLOBALS['__registered_api_routes'][$route_index]['middleware'] = - self::$middleware; - } - - if ($this->route !== null) - { - $GLOBALS['__registered_api_routes'][$route_index]['route'] = - $this->route; - } - - if (self::$map !== null) - { - $GLOBALS['__registered_api_routes'][$route_index]['map'] = self::$map; - } - } - - /** * Define an API route for version 1. * Also in use for defining urls * * @return self */ - public static function v1 (): self + public static function v1(): self { return self::__callStatic('v1', 0); } - public static function v1_0 (): self + public static function v1_0(): self { return self::__callStatic('v1_0', 0); } - public static function v1_1 (): self + public static function v1_1(): self { return self::__callStatic('v1_1', 0); } - public static function v1_1_1 (): self + public static function v1_1_1(): self { return self::__callStatic('v1_1_1', 0); } - public static function v1_1_2 (): self + public static function v1_1_2(): self { return self::__callStatic('v1_1_2', 0); } - public static function v1_1_3 (): self + public static function v1_1_3(): self { return self::__callStatic('v1_1_3', 0); } - public static function v1_1_4 (): self + public static function v1_1_4(): self { return self::__callStatic('v1_1_4', 0); } - public static function v1_1_5 (): self + public static function v1_1_5(): self { return self::__callStatic('v1_1_5', 0); } - public static function v1_1_6 (): self + public static function v1_1_6(): self { return self::__callStatic('v1_1_6', 0); } - public static function v1_1_7 (): self + public static function v1_1_7(): self { return self::__callStatic('v1_1_7', 0); } - public static function v1_1_8 (): self + public static function v1_1_8(): self { return self::__callStatic('v1_1_8', 0); } - public static function v1_1_9 (): self + public static function v1_1_9(): self { return self::__callStatic('v1_1_9', 0); } - public static function v1_2 (): self + public static function v1_2(): self { return self::__callStatic('v1_2', 0); } - public static function v1_2_1 (): self + public static function v1_2_1(): self { return self::__callStatic('v1_2_1', 0); } - public static function v1_2_2 (): self + public static function v1_2_2(): self { return self::__callStatic('v1_2_2', 0); } - public static function v1_2_3 (): self + public static function v1_2_3(): self { return self::__callStatic('v1_2_3', 0); } - public static function v1_2_4 (): self + public static function v1_2_4(): self { return self::__callStatic('v1_2_4', 0); } - public static function v1_2_5 (): self + public static function v1_2_5(): self { return self::__callStatic('v1_2_5', 0); } - public static function v1_2_6 (): self + public static function v1_2_6(): self { return self::__callStatic('v1_2_6', 0); } - public static function v1_2_7 (): self + public static function v1_2_7(): self { return self::__callStatic('v1_2_7', 0); } - public static function v1_2_8 (): self + public static function v1_2_8(): self { return self::__callStatic('v1_2_8', 0); } - public static function v1_2_9 (): self + public static function v1_2_9(): self { return self::__callStatic('v1_2_9', 0); } - public static function v1_3 (): self + public static function v1_3(): self { return self::__callStatic('v1_3', 0); } - public static function v1_3_1 (): self + public static function v1_3_1(): self { return self::__callStatic('v1_3_1', 0); } - public static function v1_3_2 (): self + public static function v1_3_2(): self { return self::__callStatic('v1_3_2', 0); } - public static function v1_3_3 (): self + public static function v1_3_3(): self { return self::__callStatic('v1_3_3', 0); } - public static function v1_3_4 (): self + public static function v1_3_4(): self { return self::__callStatic('v1_3_4', 0); } - public static function v1_3_5 (): self + public static function v1_3_5(): self { return self::__callStatic('v1_3_5', 0); } - public static function v1_3_6 (): self + public static function v1_3_6(): self { return self::__callStatic('v1_3_6', 0); } - public static function v1_3_7 (): self + public static function v1_3_7(): self { return self::__callStatic('v1_3_7', 0); } - public static function v1_3_8 (): self + public static function v1_3_8(): self { return self::__callStatic('v1_3_8', 0); } - public static function v1_3_9 (): self + public static function v1_3_9(): self { return self::__callStatic('v1_3_9', 0); } - public static function v1_4 (): self + public static function v1_4(): self { return self::__callStatic('v1_4', 0); } - public static function v1_4_1 (): self + public static function v1_4_1(): self { return self::__callStatic('v1_4_1', 0); } - public static function v1_4_2 (): self + public static function v1_4_2(): self { return self::__callStatic('v1_4_2', 0); } - public static function v1_4_3 (): self + public static function v1_4_3(): self { return self::__callStatic('v1_4_3', 0); } - public static function v1_4_4 (): self + public static function v1_4_4(): self { return self::__callStatic('v1_4_4', 0); } - public static function v1_4_5 (): self + public static function v1_4_5(): self { return self::__callStatic('v1_4_5', 0); } - public static function v1_4_6 (): self + public static function v1_4_6(): self { return self::__callStatic('v1_4_6', 0); } - public static function v1_4_7 (): self + public static function v1_4_7(): self { return self::__callStatic('v1_4_7', 0); } - public static function v1_4_8 (): self + public static function v1_4_8(): self { return self::__callStatic('v1_4_8', 0); } - public static function v1_4_9 (): self + public static function v1_4_9(): self { return self::__callStatic('v1_4_9', 0); } - public static function v1_5 (): self + public static function v1_5(): self { return self::__callStatic('v1_5', 0); } - public static function v1_5_1 (): self + public static function v1_5_1(): self { return self::__callStatic('v1_5_1', 0); } - public static function v1_5_2 (): self + public static function v1_5_2(): self { return self::__callStatic('v1_5_2', 0); } - public static function v1_5_3 (): self + public static function v1_5_3(): self { return self::__callStatic('v1_5_3', 0); } - public static function v1_5_4 (): self + public static function v1_5_4(): self { return self::__callStatic('v1_5_4', 0); } - public static function v1_5_5 (): self + public static function v1_5_5(): self { return self::__callStatic('v1_5_5', 0); } - public static function v1_5_6 (): self + public static function v1_5_6(): self { return self::__callStatic('v1_5_6', 0); } - public static function v1_5_7 (): self + public static function v1_5_7(): self { return self::__callStatic('v1_5_7', 0); } - public static function v1_5_8 (): self + public static function v1_5_8(): self { return self::__callStatic('v1_5_8', 0); } - public static function v1_5_9 (): self + public static function v1_5_9(): self { return self::__callStatic('v1_5_9', 0); } - public static function v1_6 (): self + public static function v1_6(): self { return self::__callStatic('v1_6', 0); } - public static function v1_6_1 (): self + public static function v1_6_1(): self { return self::__callStatic('v1_6_1', 0); } - public static function v1_6_2 (): self + public static function v1_6_2(): self { return self::__callStatic('v1_6_2', 0); } - public static function v1_6_3 (): self + public static function v1_6_3(): self { return self::__callStatic('v1_6_3', 0); } - public static function v1_6_4 (): self + public static function v1_6_4(): self { return self::__callStatic('v1_6_4', 0); } - public static function v1_6_5 (): self + public static function v1_6_5(): self { return self::__callStatic('v1_6_5', 0); } - public static function v1_6_6 (): self + public static function v1_6_6(): self { return self::__callStatic('v1_6_6', 0); } - public static function v1_6_7 (): self + public static function v1_6_7(): self { return self::__callStatic('v1_6_7', 0); } - public static function v1_6_8 (): self + public static function v1_6_8(): self { return self::__callStatic('v1_6_8', 0); } - public static function v1_6_9 (): self + public static function v1_6_9(): self { return self::__callStatic('v1_6_9', 0); } - public static function v1_7 (): self + public static function v1_7(): self { return self::__callStatic('v1_7', 0); } - public static function v1_7_1 (): self + public static function v1_7_1(): self { return self::__callStatic('v1_7_1', 0); } - public static function v1_7_2 (): self + public static function v1_7_2(): self { return self::__callStatic('v1_7_2', 0); } - public static function v1_7_3 (): self + public static function v1_7_3(): self { return self::__callStatic('v1_7_3', 0); } - public static function v1_7_4 (): self + public static function v1_7_4(): self { return self::__callStatic('v1_7_4', 0); } - public static function v1_7_5 (): self + public static function v1_7_5(): self { return self::__callStatic('v1_7_5', 0); } - public static function v1_7_6 (): self + public static function v1_7_6(): self { return self::__callStatic('v1_7_6', 0); } - public static function v1_7_7 (): self + public static function v1_7_7(): self { return self::__callStatic('v1_7_7', 0); } - public static function v1_7_8 (): self + public static function v1_7_8(): self { return self::__callStatic('v1_7_8', 0); } - public static function v1_7_9 (): self + public static function v1_7_9(): self { return self::__callStatic('v1_7_9', 0); } - public static function v1_8 (): self + public static function v1_8(): self { return self::__callStatic('v1_8', 0); } - public static function v1_8_1 (): self + public static function v1_8_1(): self { return self::__callStatic('v1_8_1', 0); } - public static function v1_8_2 (): self + public static function v1_8_2(): self { return self::__callStatic('v1_8_2', 0); } - public static function v1_8_3 (): self + public static function v1_8_3(): self { return self::__callStatic('v1_8_3', 0); } - public static function v1_8_4 (): self + public static function v1_8_4(): self { return self::__callStatic('v1_8_4', 0); } - public static function v1_8_5 (): self + public static function v1_8_5(): self { return self::__callStatic('v1_8_5', 0); } - public static function v1_8_6 (): self + public static function v1_8_6(): self { return self::__callStatic('v1_8_6', 0); } - public static function v1_8_7 (): self + public static function v1_8_7(): self { return self::__callStatic('v1_8_7', 0); } - public static function v1_8_8 (): self + public static function v1_8_8(): self { return self::__callStatic('v1_8_8', 0); } - public static function v1_8_9 (): self + public static function v1_8_9(): self { return self::__callStatic('v1_8_9', 0); } - public static function v1_9 (): self + public static function v1_9(): self { return self::__callStatic('v1_9', 0); } - public static function v1_9_1 (): self + public static function v1_9_1(): self { return self::__callStatic('v1_9_1', 0); } - public static function v1_9_2 (): self + public static function v1_9_2(): self { return self::__callStatic('v1_9_2', 0); } - public static function v1_9_3 (): self + public static function v1_9_3(): self { return self::__callStatic('v1_9_3', 0); } - public static function v1_9_4 (): self + public static function v1_9_4(): self { return self::__callStatic('v1_9_4', 0); } - public static function v1_9_5 (): self + public static function v1_9_5(): self { return self::__callStatic('v1_9_5', 0); } - public static function v1_9_6 (): self + public static function v1_9_6(): self { return self::__callStatic('v1_9_6', 0); } - public static function v1_9_7 (): self + public static function v1_9_7(): self { return self::__callStatic('v1_9_7', 0); } - public static function v1_9_8 (): self + public static function v1_9_8(): self { return self::__callStatic('v1_9_8', 0); } - public static function v1_9_9 (): self + public static function v1_9_9(): self { return self::__callStatic('v1_9_9', 0); } - public static function v2 (): self + public static function v2(): self { return self::__callStatic('v2', 0); } - public static function v2_0 (): self + public static function v2_0(): self { return self::__callStatic('v2_0', 0); } - public static function v2_1 (): self + public static function v2_1(): self { return self::__callStatic('v2_1', 0); } - public static function v2_1_1 (): self + public static function v2_1_1(): self { return self::__callStatic('v2_1_1', 0); } - public static function v2_1_2 (): self + public static function v2_1_2(): self { return self::__callStatic('v2_1_2', 0); } - public static function v2_1_3 (): self + public static function v2_1_3(): self { return self::__callStatic('v2_1_3', 0); } - public static function v2_1_4 (): self + public static function v2_1_4(): self { return self::__callStatic('v2_1_4', 0); } - public static function v2_1_5 (): self + public static function v2_1_5(): self { return self::__callStatic('v2_1_5', 0); } - public static function v2_1_6 (): self + public static function v2_1_6(): self { return self::__callStatic('v2_1_6', 0); } - public static function v2_1_7 (): self + public static function v2_1_7(): self { return self::__callStatic('v2_1_7', 0); } - public static function v2_1_8 (): self + public static function v2_1_8(): self { return self::__callStatic('v2_1_8', 0); } - public static function v2_1_9 (): self + public static function v2_1_9(): self { return self::__callStatic('v2_1_9', 0); } - public static function v2_2 (): self + public static function v2_2(): self { return self::__callStatic('v2_2', 0); } - public static function v2_2_1 (): self + public static function v2_2_1(): self { return self::__callStatic('v2_2_1', 0); } - public static function v2_2_2 (): self + public static function v2_2_2(): self { return self::__callStatic('v2_2_2', 0); } - public static function v2_2_3 (): self + public static function v2_2_3(): self { return self::__callStatic('v2_2_3', 0); } - public static function v2_2_4 (): self + public static function v2_2_4(): self { return self::__callStatic('v2_2_4', 0); } - public static function v2_2_5 (): self + public static function v2_2_5(): self { return self::__callStatic('v2_2_5', 0); } - public static function v2_2_6 (): self + public static function v2_2_6(): self { return self::__callStatic('v2_2_6', 0); } - public static function v2_2_7 (): self + public static function v2_2_7(): self { return self::__callStatic('v2_2_7', 0); } - public static function v2_2_8 (): self + public static function v2_2_8(): self { return self::__callStatic('v2_2_8', 0); } - public static function v2_2_9 (): self + public static function v2_2_9(): self { return self::__callStatic('v2_2_9', 0); } - public static function v2_3 (): self + public static function v2_3(): self { return self::__callStatic('v2_3', 0); } - public static function v2_3_1 (): self + public static function v2_3_1(): self { return self::__callStatic('v2_3_1', 0); } - public static function v2_3_2 (): self + public static function v2_3_2(): self { return self::__callStatic('v2_3_2', 0); } - public static function v2_3_3 (): self + public static function v2_3_3(): self { return self::__callStatic('v2_3_3', 0); } - public static function v2_3_4 (): self + public static function v2_3_4(): self { return self::__callStatic('v2_3_4', 0); } - public static function v2_3_5 (): self + public static function v2_3_5(): self { return self::__callStatic('v2_3_5', 0); } - public static function v2_3_6 (): self + public static function v2_3_6(): self { return self::__callStatic('v2_3_6', 0); } - public static function v2_3_7 (): self + public static function v2_3_7(): self { return self::__callStatic('v2_3_7', 0); } - public static function v2_3_8 (): self + public static function v2_3_8(): self { return self::__callStatic('v2_3_8', 0); } - public static function v2_3_9 (): self + public static function v2_3_9(): self { return self::__callStatic('v2_3_9', 0); } - public static function v2_4 (): self + public static function v2_4(): self { return self::__callStatic('v2_4', 0); } - public static function v2_4_1 (): self + public static function v2_4_1(): self { return self::__callStatic('v2_4_1', 0); } - public static function v2_4_2 (): self + public static function v2_4_2(): self { return self::__callStatic('v2_4_2', 0); } - public static function v2_4_3 (): self + public static function v2_4_3(): self { return self::__callStatic('v2_4_3', 0); } - public static function v2_4_4 (): self + public static function v2_4_4(): self { return self::__callStatic('v2_4_4', 0); } - public static function v2_4_5 (): self + public static function v2_4_5(): self { return self::__callStatic('v2_4_5', 0); } - public static function v2_4_6 (): self + public static function v2_4_6(): self { return self::__callStatic('v2_4_6', 0); } - public static function v2_4_7 (): self + public static function v2_4_7(): self { return self::__callStatic('v2_4_7', 0); } - public static function v2_4_8 (): self + public static function v2_4_8(): self { return self::__callStatic('v2_4_8', 0); } - public static function v2_4_9 (): self + public static function v2_4_9(): self { return self::__callStatic('v2_4_9', 0); } - public static function v2_5 (): self + public static function v2_5(): self { return self::__callStatic('v2_5', 0); } - public static function v2_5_1 (): self + public static function v2_5_1(): self { return self::__callStatic('v2_5_1', 0); } - public static function v2_5_2 (): self + public static function v2_5_2(): self { return self::__callStatic('v2_5_2', 0); } - public static function v2_5_3 (): self + public static function v2_5_3(): self { return self::__callStatic('v2_5_3', 0); } - public static function v2_5_4 (): self + public static function v2_5_4(): self { return self::__callStatic('v2_5_4', 0); } - public static function v2_5_5 (): self + public static function v2_5_5(): self { return self::__callStatic('v2_5_5', 0); } - public static function v2_5_6 (): self + public static function v2_5_6(): self { return self::__callStatic('v2_5_6', 0); } - public static function v2_5_7 (): self + public static function v2_5_7(): self { return self::__callStatic('v2_5_7', 0); } - public static function v2_5_8 (): self + public static function v2_5_8(): self { return self::__callStatic('v2_5_8', 0); } - public static function v2_5_9 (): self + public static function v2_5_9(): self { return self::__callStatic('v2_5_9', 0); } - public static function v2_6 (): self + public static function v2_6(): self { return self::__callStatic('v2_6', 0); } - public static function v2_6_1 (): self + public static function v2_6_1(): self { return self::__callStatic('v2_6_1', 0); } - public static function v2_6_2 (): self + public static function v2_6_2(): self { return self::__callStatic('v2_6_2', 0); } - public static function v2_6_3 (): self + public static function v2_6_3(): self { return self::__callStatic('v2_6_3', 0); } - public static function v2_6_4 (): self + public static function v2_6_4(): self { return self::__callStatic('v2_6_4', 0); } - public static function v2_6_5 (): self + public static function v2_6_5(): self { return self::__callStatic('v2_6_5', 0); } - public static function v2_6_6 (): self + public static function v2_6_6(): self { return self::__callStatic('v2_6_6', 0); } - public static function v2_6_7 (): self + public static function v2_6_7(): self { return self::__callStatic('v2_6_7', 0); } - public static function v2_6_8 (): self + public static function v2_6_8(): self { return self::__callStatic('v2_6_8', 0); } - public static function v2_6_9 (): self + public static function v2_6_9(): self { return self::__callStatic('v2_6_9', 0); } - public static function v2_7 (): self + public static function v2_7(): self { return self::__callStatic('v2_7', 0); } - public static function v2_7_1 (): self + public static function v2_7_1(): self { return self::__callStatic('v2_7_1', 0); } - public static function v2_7_2 (): self + public static function v2_7_2(): self { return self::__callStatic('v2_7_2', 0); } - public static function v2_7_3 (): self + public static function v2_7_3(): self { return self::__callStatic('v2_7_3', 0); } - public static function v2_7_4 (): self + public static function v2_7_4(): self { return self::__callStatic('v2_7_4', 0); } - public static function v2_7_5 (): self + public static function v2_7_5(): self { return self::__callStatic('v2_7_5', 0); } - public static function v2_7_6 (): self + public static function v2_7_6(): self { return self::__callStatic('v2_7_6', 0); } - public static function v2_7_7 (): self + public static function v2_7_7(): self { return self::__callStatic('v2_7_7', 0); } - public static function v2_7_8 (): self + public static function v2_7_8(): self { return self::__callStatic('v2_7_8', 0); } - public static function v2_7_9 (): self + public static function v2_7_9(): self { return self::__callStatic('v2_7_9', 0); } - public static function v2_8 (): self + public static function v2_8(): self { return self::__callStatic('v2_8', 0); } - public static function v2_8_1 (): self + public static function v2_8_1(): self { return self::__callStatic('v2_8_1', 0); } - public static function v2_8_2 (): self + public static function v2_8_2(): self { return self::__callStatic('v2_8_2', 0); } - public static function v2_8_3 (): self + public static function v2_8_3(): self { return self::__callStatic('v2_8_3', 0); } - public static function v2_8_4 (): self + public static function v2_8_4(): self { return self::__callStatic('v2_8_4', 0); } - public static function v2_8_5 (): self + public static function v2_8_5(): self { return self::__callStatic('v2_8_5', 0); } - public static function v2_8_6 (): self + public static function v2_8_6(): self { return self::__callStatic('v2_8_6', 0); } - public static function v2_8_7 (): self + public static function v2_8_7(): self { return self::__callStatic('v2_8_7', 0); } - public static function v2_8_8 (): self + public static function v2_8_8(): self { return self::__callStatic('v2_8_8', 0); } - public static function v2_8_9 (): self + public static function v2_8_9(): self { return self::__callStatic('v2_8_9', 0); } - public static function v2_9 (): self + public static function v2_9(): self { return self::__callStatic('v2_9', 0); } - public static function v2_9_1 (): self + public static function v2_9_1(): self { return self::__callStatic('v2_9_1', 0); } - public static function v2_9_2 (): self + public static function v2_9_2(): self { return self::__callStatic('v2_9_2', 0); } - public static function v2_9_3 (): self + public static function v2_9_3(): self { return self::__callStatic('v2_9_3', 0); } - public static function v2_9_4 (): self + public static function v2_9_4(): self { return self::__callStatic('v2_9_4', 0); } - public static function v2_9_5 (): self + public static function v2_9_5(): self { return self::__callStatic('v2_9_5', 0); } - public static function v2_9_6 (): self + public static function v2_9_6(): self { return self::__callStatic('v2_9_6', 0); } - public static function v2_9_7 (): self + public static function v2_9_7(): self { return self::__callStatic('v2_9_7', 0); } - public static function v2_9_8 (): self + public static function v2_9_8(): self { return self::__callStatic('v2_9_8', 0); } - public static function v2_9_9 (): self + public static function v2_9_9(): self { return self::__callStatic('v2_9_9', 0); } - public static function v3 (): self + public static function v3(): self { return self::__callStatic('v3', 0); } - public static function v3_0 (): self + public static function v3_0(): self { return self::__callStatic('v3_0', 0); } - public static function v3_1 (): self + public static function v3_1(): self { return self::__callStatic('v3_1', 0); } - public static function v3_1_1 (): self + public static function v3_1_1(): self { return self::__callStatic('v3_1_1', 0); } - public static function v3_1_2 (): self + public static function v3_1_2(): self { return self::__callStatic('v3_1_2', 0); } - public static function v3_1_3 (): self + public static function v3_1_3(): self { return self::__callStatic('v3_1_3', 0); } - public static function v3_1_4 (): self + public static function v3_1_4(): self { return self::__callStatic('v3_1_4', 0); } - public static function v3_1_5 (): self + public static function v3_1_5(): self { return self::__callStatic('v3_1_5', 0); } - public static function v3_1_6 (): self + public static function v3_1_6(): self { return self::__callStatic('v3_1_6', 0); } - public static function v3_1_7 (): self + public static function v3_1_7(): self { return self::__callStatic('v3_1_7', 0); } - public static function v3_1_8 (): self + public static function v3_1_8(): self { return self::__callStatic('v3_1_8', 0); } - public static function v3_1_9 (): self + public static function v3_1_9(): self { return self::__callStatic('v3_1_9', 0); } - public static function v3_2 (): self + public static function v3_2(): self { return self::__callStatic('v3_2', 0); } - public static function v3_2_1 (): self + public static function v3_2_1(): self { return self::__callStatic('v3_2_1', 0); } - public static function v3_2_2 (): self + public static function v3_2_2(): self { return self::__callStatic('v3_2_2', 0); } - public static function v3_2_3 (): self + public static function v3_2_3(): self { return self::__callStatic('v3_2_3', 0); } - public static function v3_2_4 (): self + public static function v3_2_4(): self { return self::__callStatic('v3_2_4', 0); } - public static function v3_2_5 (): self + public static function v3_2_5(): self { return self::__callStatic('v3_2_5', 0); } - public static function v3_2_6 (): self + public static function v3_2_6(): self { return self::__callStatic('v3_2_6', 0); } - public static function v3_2_7 (): self + public static function v3_2_7(): self { return self::__callStatic('v3_2_7', 0); } - public static function v3_2_8 (): self + public static function v3_2_8(): self { return self::__callStatic('v3_2_8', 0); } - public static function v3_2_9 (): self + public static function v3_2_9(): self { return self::__callStatic('v3_2_9', 0); } - public static function v3_3 (): self + public static function v3_3(): self { return self::__callStatic('v3_3', 0); } - public static function v3_3_1 (): self + public static function v3_3_1(): self { return self::__callStatic('v3_3_1', 0); } - public static function v3_3_2 (): self + public static function v3_3_2(): self { return self::__callStatic('v3_3_2', 0); } - public static function v3_3_3 (): self + public static function v3_3_3(): self { return self::__callStatic('v3_3_3', 0); } - public static function v3_3_4 (): self + public static function v3_3_4(): self { return self::__callStatic('v3_3_4', 0); } - public static function v3_3_5 (): self + public static function v3_3_5(): self { return self::__callStatic('v3_3_5', 0); } - public static function v3_3_6 (): self + public static function v3_3_6(): self { return self::__callStatic('v3_3_6', 0); } - public static function v3_3_7 (): self + public static function v3_3_7(): self { return self::__callStatic('v3_3_7', 0); } - public static function v3_3_8 (): self + public static function v3_3_8(): self { return self::__callStatic('v3_3_8', 0); } - public static function v3_3_9 (): self + public static function v3_3_9(): self { return self::__callStatic('v3_3_9', 0); } - public static function v3_4 (): self + public static function v3_4(): self { return self::__callStatic('v3_4', 0); } - public static function v3_4_1 (): self + public static function v3_4_1(): self { return self::__callStatic('v3_4_1', 0); } - public static function v3_4_2 (): self + public static function v3_4_2(): self { return self::__callStatic('v3_4_2', 0); } - public static function v3_4_3 (): self + public static function v3_4_3(): self { return self::__callStatic('v3_4_3', 0); } - public static function v3_4_4 (): self + public static function v3_4_4(): self { return self::__callStatic('v3_4_4', 0); } - public static function v3_4_5 (): self + public static function v3_4_5(): self { return self::__callStatic('v3_4_5', 0); } - public static function v3_4_6 (): self + public static function v3_4_6(): self { return self::__callStatic('v3_4_6', 0); } - public static function v3_4_7 (): self + public static function v3_4_7(): self { return self::__callStatic('v3_4_7', 0); } - public static function v3_4_8 (): self + public static function v3_4_8(): self { return self::__callStatic('v3_4_8', 0); } - public static function v3_4_9 (): self + public static function v3_4_9(): self { return self::__callStatic('v3_4_9', 0); } - public static function v3_5 (): self + public static function v3_5(): self { return self::__callStatic('v3_5', 0); } - public static function v3_5_1 (): self + public static function v3_5_1(): self { return self::__callStatic('v3_5_1', 0); } - public static function v3_5_2 (): self + public static function v3_5_2(): self { return self::__callStatic('v3_5_2', 0); } - public static function v3_5_3 (): self + public static function v3_5_3(): self { return self::__callStatic('v3_5_3', 0); } - public static function v3_5_4 (): self + public static function v3_5_4(): self { return self::__callStatic('v3_5_4', 0); } - public static function v3_5_5 (): self + public static function v3_5_5(): self { return self::__callStatic('v3_5_5', 0); } - public static function v3_5_6 (): self + public static function v3_5_6(): self { return self::__callStatic('v3_5_6', 0); } - public static function v3_5_7 (): self + public static function v3_5_7(): self { return self::__callStatic('v3_5_7', 0); } - public static function v3_5_8 (): self + public static function v3_5_8(): self { return self::__callStatic('v3_5_8', 0); } - public static function v3_5_9 (): self + public static function v3_5_9(): self { return self::__callStatic('v3_5_9', 0); } - public static function v3_6 (): self + public static function v3_6(): self { return self::__callStatic('v3_6', 0); } - public static function v3_6_1 (): self + public static function v3_6_1(): self { return self::__callStatic('v3_6_1', 0); } - public static function v3_6_2 (): self + public static function v3_6_2(): self { return self::__callStatic('v3_6_2', 0); } - public static function v3_6_3 (): self + public static function v3_6_3(): self { return self::__callStatic('v3_6_3', 0); } - public static function v3_6_4 (): self + public static function v3_6_4(): self { return self::__callStatic('v3_6_4', 0); } - public static function v3_6_5 (): self + public static function v3_6_5(): self { return self::__callStatic('v3_6_5', 0); } - public static function v3_6_6 (): self + public static function v3_6_6(): self { return self::__callStatic('v3_6_6', 0); } - public static function v3_6_7 (): self + public static function v3_6_7(): self { return self::__callStatic('v3_6_7', 0); } - public static function v3_6_8 (): self + public static function v3_6_8(): self { return self::__callStatic('v3_6_8', 0); } - public static function v3_6_9 (): self + public static function v3_6_9(): self { return self::__callStatic('v3_6_9', 0); } - public static function v3_7 (): self + public static function v3_7(): self { return self::__callStatic('v3_7', 0); } - public static function v3_7_1 (): self + public static function v3_7_1(): self { return self::__callStatic('v3_7_1', 0); } - public static function v3_7_2 (): self + public static function v3_7_2(): self { return self::__callStatic('v3_7_2', 0); } - public static function v3_7_3 (): self + public static function v3_7_3(): self { return self::__callStatic('v3_7_3', 0); } - public static function v3_7_4 (): self + public static function v3_7_4(): self { return self::__callStatic('v3_7_4', 0); } - public static function v3_7_5 (): self + public static function v3_7_5(): self { return self::__callStatic('v3_7_5', 0); } - public static function v3_7_6 (): self + public static function v3_7_6(): self { return self::__callStatic('v3_7_6', 0); } - public static function v3_7_7 (): self + public static function v3_7_7(): self { return self::__callStatic('v3_7_7', 0); } - public static function v3_7_8 (): self + public static function v3_7_8(): self { return self::__callStatic('v3_7_8', 0); } - public static function v3_7_9 (): self + public static function v3_7_9(): self { return self::__callStatic('v3_7_9', 0); } - public static function v3_8 (): self + public static function v3_8(): self { return self::__callStatic('v3_8', 0); } - public static function v3_8_1 (): self + public static function v3_8_1(): self { return self::__callStatic('v3_8_1', 0); } - public static function v3_8_2 (): self + public static function v3_8_2(): self { return self::__callStatic('v3_8_2', 0); } - public static function v3_8_3 (): self + public static function v3_8_3(): self { return self::__callStatic('v3_8_3', 0); } - public static function v3_8_4 (): self + public static function v3_8_4(): self { return self::__callStatic('v3_8_4', 0); } - public static function v3_8_5 (): self + public static function v3_8_5(): self { return self::__callStatic('v3_8_5', 0); } - public static function v3_8_6 (): self + public static function v3_8_6(): self { return self::__callStatic('v3_8_6', 0); } - public static function v3_8_7 (): self + public static function v3_8_7(): self { return self::__callStatic('v3_8_7', 0); } - public static function v3_8_8 (): self + public static function v3_8_8(): self { return self::__callStatic('v3_8_8', 0); } - public static function v3_8_9 (): self + public static function v3_8_9(): self { return self::__callStatic('v3_8_9', 0); } - public static function v3_9 (): self + public static function v3_9(): self { return self::__callStatic('v3_9', 0); } - public static function v3_9_1 (): self + public static function v3_9_1(): self { return self::__callStatic('v3_9_1', 0); } - public static function v3_9_2 (): self + public static function v3_9_2(): self { return self::__callStatic('v3_9_2', 0); } - public static function v3_9_3 (): self + public static function v3_9_3(): self { return self::__callStatic('v3_9_3', 0); } - public static function v3_9_4 (): self + public static function v3_9_4(): self { return self::__callStatic('v3_9_4', 0); } - public static function v3_9_5 (): self + public static function v3_9_5(): self { return self::__callStatic('v3_9_5', 0); } - public static function v3_9_6 (): self + public static function v3_9_6(): self { return self::__callStatic('v3_9_6', 0); } - public static function v3_9_7 (): self + public static function v3_9_7(): self { return self::__callStatic('v3_9_7', 0); } - public static function v3_9_8 (): self + public static function v3_9_8(): self { return self::__callStatic('v3_9_8', 0); } - public static function v3_9_9 (): self + public static function v3_9_9(): self { return self::__callStatic('v3_9_9', 0); } - public static function v4 (): self + public static function v4(): self { return self::__callStatic('v4', 0); } - public static function v4_0 (): self + public static function v4_0(): self { return self::__callStatic('v4_0', 0); } - public static function v4_1 (): self + public static function v4_1(): self { return self::__callStatic('v4_1', 0); } - public static function v4_1_1 (): self + public static function v4_1_1(): self { return self::__callStatic('v4_1_1', 0); } - public static function v4_1_2 (): self + public static function v4_1_2(): self { return self::__callStatic('v4_1_2', 0); } - public static function v4_1_3 (): self + public static function v4_1_3(): self { return self::__callStatic('v4_1_3', 0); } - public static function v4_1_4 (): self + public static function v4_1_4(): self { return self::__callStatic('v4_1_4', 0); } - public static function v4_1_5 (): self + public static function v4_1_5(): self { return self::__callStatic('v4_1_5', 0); } - public static function v4_1_6 (): self + public static function v4_1_6(): self { return self::__callStatic('v4_1_6', 0); } - public static function v4_1_7 (): self + public static function v4_1_7(): self { return self::__callStatic('v4_1_7', 0); } - public static function v4_1_8 (): self + public static function v4_1_8(): self { return self::__callStatic('v4_1_8', 0); } - public static function v4_1_9 (): self + public static function v4_1_9(): self { return self::__callStatic('v4_1_9', 0); } - public static function v4_2 (): self + public static function v4_2(): self { return self::__callStatic('v4_2', 0); } - public static function v4_2_1 (): self + public static function v4_2_1(): self { return self::__callStatic('v4_2_1', 0); } - public static function v4_2_2 (): self + public static function v4_2_2(): self { return self::__callStatic('v4_2_2', 0); } - public static function v4_2_3 (): self + public static function v4_2_3(): self { return self::__callStatic('v4_2_3', 0); } - public static function v4_2_4 (): self + public static function v4_2_4(): self { return self::__callStatic('v4_2_4', 0); } - public static function v4_2_5 (): self + public static function v4_2_5(): self { return self::__callStatic('v4_2_5', 0); } - public static function v4_2_6 (): self + public static function v4_2_6(): self { return self::__callStatic('v4_2_6', 0); } - public static function v4_2_7 (): self + public static function v4_2_7(): self { return self::__callStatic('v4_2_7', 0); } - public static function v4_2_8 (): self + public static function v4_2_8(): self { return self::__callStatic('v4_2_8', 0); } - public static function v4_2_9 (): self + public static function v4_2_9(): self { return self::__callStatic('v4_2_9', 0); } - public static function v4_3 (): self + public static function v4_3(): self { return self::__callStatic('v4_3', 0); } - public static function v4_3_1 (): self + public static function v4_3_1(): self { return self::__callStatic('v4_3_1', 0); } - public static function v4_3_2 (): self + public static function v4_3_2(): self { return self::__callStatic('v4_3_2', 0); } - public static function v4_3_3 (): self + public static function v4_3_3(): self { return self::__callStatic('v4_3_3', 0); } - public static function v4_3_4 (): self + public static function v4_3_4(): self { return self::__callStatic('v4_3_4', 0); } - public static function v4_3_5 (): self + public static function v4_3_5(): self { return self::__callStatic('v4_3_5', 0); } - public static function v4_3_6 (): self + public static function v4_3_6(): self { return self::__callStatic('v4_3_6', 0); } - public static function v4_3_7 (): self + public static function v4_3_7(): self { return self::__callStatic('v4_3_7', 0); } - public static function v4_3_8 (): self + public static function v4_3_8(): self { return self::__callStatic('v4_3_8', 0); } - public static function v4_3_9 (): self + public static function v4_3_9(): self { return self::__callStatic('v4_3_9', 0); } - public static function v4_4 (): self + public static function v4_4(): self { return self::__callStatic('v4_4', 0); } - public static function v4_4_1 (): self + public static function v4_4_1(): self { return self::__callStatic('v4_4_1', 0); } - public static function v4_4_2 (): self + public static function v4_4_2(): self { return self::__callStatic('v4_4_2', 0); } - public static function v4_4_3 (): self + public static function v4_4_3(): self { return self::__callStatic('v4_4_3', 0); } - public static function v4_4_4 (): self + public static function v4_4_4(): self { return self::__callStatic('v4_4_4', 0); } - public static function v4_4_5 (): self + public static function v4_4_5(): self { return self::__callStatic('v4_4_5', 0); } - public static function v4_4_6 (): self + public static function v4_4_6(): self { return self::__callStatic('v4_4_6', 0); } - public static function v4_4_7 (): self + public static function v4_4_7(): self { return self::__callStatic('v4_4_7', 0); } - public static function v4_4_8 (): self + public static function v4_4_8(): self { return self::__callStatic('v4_4_8', 0); } - public static function v4_4_9 (): self + public static function v4_4_9(): self { return self::__callStatic('v4_4_9', 0); } - public static function v4_5 (): self + public static function v4_5(): self { return self::__callStatic('v4_5', 0); } - public static function v4_5_1 (): self + public static function v4_5_1(): self { return self::__callStatic('v4_5_1', 0); } - public static function v4_5_2 (): self + public static function v4_5_2(): self { return self::__callStatic('v4_5_2', 0); } - public static function v4_5_3 (): self + public static function v4_5_3(): self { return self::__callStatic('v4_5_3', 0); } - public static function v4_5_4 (): self + public static function v4_5_4(): self { return self::__callStatic('v4_5_4', 0); } - public static function v4_5_5 (): self + public static function v4_5_5(): self { return self::__callStatic('v4_5_5', 0); } - public static function v4_5_6 (): self + public static function v4_5_6(): self { return self::__callStatic('v4_5_6', 0); } - public static function v4_5_7 (): self + public static function v4_5_7(): self { return self::__callStatic('v4_5_7', 0); } - public static function v4_5_8 (): self + public static function v4_5_8(): self { return self::__callStatic('v4_5_8', 0); } - public static function v4_5_9 (): self + public static function v4_5_9(): self { return self::__callStatic('v4_5_9', 0); } - public static function v4_6 (): self + public static function v4_6(): self { return self::__callStatic('v4_6', 0); } - public static function v4_6_1 (): self + public static function v4_6_1(): self { return self::__callStatic('v4_6_1', 0); } - public static function v4_6_2 (): self + public static function v4_6_2(): self { return self::__callStatic('v4_6_2', 0); } - public static function v4_6_3 (): self + public static function v4_6_3(): self { return self::__callStatic('v4_6_3', 0); } - public static function v4_6_4 (): self + public static function v4_6_4(): self { return self::__callStatic('v4_6_4', 0); } - public static function v4_6_5 (): self + public static function v4_6_5(): self { return self::__callStatic('v4_6_5', 0); } - public static function v4_6_6 (): self + public static function v4_6_6(): self { return self::__callStatic('v4_6_6', 0); } - public static function v4_6_7 (): self + public static function v4_6_7(): self { return self::__callStatic('v4_6_7', 0); } - public static function v4_6_8 (): self + public static function v4_6_8(): self { return self::__callStatic('v4_6_8', 0); } - public static function v4_6_9 (): self + public static function v4_6_9(): self { return self::__callStatic('v4_6_9', 0); } - public static function v4_7 (): self + public static function v4_7(): self { return self::__callStatic('v4_7', 0); } - public static function v4_7_1 (): self + public static function v4_7_1(): self { return self::__callStatic('v4_7_1', 0); } - public static function v4_7_2 (): self + public static function v4_7_2(): self { return self::__callStatic('v4_7_2', 0); } - public static function v4_7_3 (): self + public static function v4_7_3(): self { return self::__callStatic('v4_7_3', 0); } - public static function v4_7_4 (): self + public static function v4_7_4(): self { return self::__callStatic('v4_7_4', 0); } - public static function v4_7_5 (): self + public static function v4_7_5(): self { return self::__callStatic('v4_7_5', 0); } - public static function v4_7_6 (): self + public static function v4_7_6(): self { return self::__callStatic('v4_7_6', 0); } - public static function v4_7_7 (): self + public static function v4_7_7(): self { return self::__callStatic('v4_7_7', 0); } - public static function v4_7_8 (): self + public static function v4_7_8(): self { return self::__callStatic('v4_7_8', 0); } - public static function v4_7_9 (): self + public static function v4_7_9(): self { return self::__callStatic('v4_7_9', 0); } - public static function v4_8 (): self + public static function v4_8(): self { return self::__callStatic('v4_8', 0); } - public static function v4_8_1 (): self + public static function v4_8_1(): self { return self::__callStatic('v4_8_1', 0); } - public static function v4_8_2 (): self + public static function v4_8_2(): self { return self::__callStatic('v4_8_2', 0); } - public static function v4_8_3 (): self + public static function v4_8_3(): self { return self::__callStatic('v4_8_3', 0); } - public static function v4_8_4 (): self + public static function v4_8_4(): self { return self::__callStatic('v4_8_4', 0); } - public static function v4_8_5 (): self + public static function v4_8_5(): self { return self::__callStatic('v4_8_5', 0); } - public static function v4_8_6 (): self + public static function v4_8_6(): self { return self::__callStatic('v4_8_6', 0); } - public static function v4_8_7 (): self + public static function v4_8_7(): self { return self::__callStatic('v4_8_7', 0); } - public static function v4_8_8 (): self + public static function v4_8_8(): self { return self::__callStatic('v4_8_8', 0); } - public static function v4_8_9 (): self + public static function v4_8_9(): self { return self::__callStatic('v4_8_9', 0); } - public static function v4_9 (): self + public static function v4_9(): self { return self::__callStatic('v4_9', 0); } - public static function v4_9_1 (): self + public static function v4_9_1(): self { return self::__callStatic('v4_9_1', 0); } - public static function v4_9_2 (): self + public static function v4_9_2(): self { return self::__callStatic('v4_9_2', 0); } - public static function v4_9_3 (): self + public static function v4_9_3(): self { return self::__callStatic('v4_9_3', 0); } - public static function v4_9_4 (): self + public static function v4_9_4(): self { return self::__callStatic('v4_9_4', 0); } - public static function v4_9_5 (): self + public static function v4_9_5(): self { return self::__callStatic('v4_9_5', 0); } - public static function v4_9_6 (): self + public static function v4_9_6(): self { return self::__callStatic('v4_9_6', 0); } - public static function v4_9_7 (): self + public static function v4_9_7(): self { return self::__callStatic('v4_9_7', 0); } - public static function v4_9_8 (): self + public static function v4_9_8(): self { return self::__callStatic('v4_9_8', 0); } - public static function v4_9_9 (): self + public static function v4_9_9(): self { return self::__callStatic('v4_9_9', 0); } - public static function v5 (): self + public static function v5(): self { return self::__callStatic('v5', 0); } - public static function v5_0 (): self + public static function v5_0(): self { return self::__callStatic('v5_0', 0); } - public static function v5_1 (): self + public static function v5_1(): self { return self::__callStatic('v5_1', 0); } - public static function v5_1_1 (): self + public static function v5_1_1(): self { return self::__callStatic('v5_1_1', 0); } - public static function v5_1_2 (): self + public static function v5_1_2(): self { return self::__callStatic('v5_1_2', 0); } - public static function v5_1_3 (): self + public static function v5_1_3(): self { return self::__callStatic('v5_1_3', 0); } - public static function v5_1_4 (): self + public static function v5_1_4(): self { return self::__callStatic('v5_1_4', 0); } - public static function v5_1_5 (): self + public static function v5_1_5(): self { return self::__callStatic('v5_1_5', 0); } - public static function v5_1_6 (): self + public static function v5_1_6(): self { return self::__callStatic('v5_1_6', 0); } - public static function v5_1_7 (): self + public static function v5_1_7(): self { return self::__callStatic('v5_1_7', 0); } - public static function v5_1_8 (): self + public static function v5_1_8(): self { return self::__callStatic('v5_1_8', 0); } - public static function v5_1_9 (): self + public static function v5_1_9(): self { return self::__callStatic('v5_1_9', 0); } - public static function v5_2 (): self + public static function v5_2(): self { return self::__callStatic('v5_2', 0); } - public static function v5_2_1 (): self + public static function v5_2_1(): self { return self::__callStatic('v5_2_1', 0); } - public static function v5_2_2 (): self + public static function v5_2_2(): self { return self::__callStatic('v5_2_2', 0); } - public static function v5_2_3 (): self + public static function v5_2_3(): self { return self::__callStatic('v5_2_3', 0); } - public static function v5_2_4 (): self + public static function v5_2_4(): self { return self::__callStatic('v5_2_4', 0); } - public static function v5_2_5 (): self + public static function v5_2_5(): self { return self::__callStatic('v5_2_5', 0); } - public static function v5_2_6 (): self + public static function v5_2_6(): self { return self::__callStatic('v5_2_6', 0); } - public static function v5_2_7 (): self + public static function v5_2_7(): self { return self::__callStatic('v5_2_7', 0); } - public static function v5_2_8 (): self + public static function v5_2_8(): self { return self::__callStatic('v5_2_8', 0); } - public static function v5_2_9 (): self + public static function v5_2_9(): self { return self::__callStatic('v5_2_9', 0); } - public static function v5_3 (): self + public static function v5_3(): self { return self::__callStatic('v5_3', 0); } - public static function v5_3_1 (): self + public static function v5_3_1(): self { return self::__callStatic('v5_3_1', 0); } - public static function v5_3_2 (): self + public static function v5_3_2(): self { return self::__callStatic('v5_3_2', 0); } - public static function v5_3_3 (): self + public static function v5_3_3(): self { return self::__callStatic('v5_3_3', 0); } - public static function v5_3_4 (): self + public static function v5_3_4(): self { return self::__callStatic('v5_3_4', 0); } - public static function v5_3_5 (): self + public static function v5_3_5(): self { return self::__callStatic('v5_3_5', 0); } - public static function v5_3_6 (): self + public static function v5_3_6(): self { return self::__callStatic('v5_3_6', 0); } - public static function v5_3_7 (): self + public static function v5_3_7(): self { return self::__callStatic('v5_3_7', 0); } - public static function v5_3_8 (): self + public static function v5_3_8(): self { return self::__callStatic('v5_3_8', 0); } - public static function v5_3_9 (): self + public static function v5_3_9(): self { return self::__callStatic('v5_3_9', 0); } - public static function v5_4 (): self + public static function v5_4(): self { return self::__callStatic('v5_4', 0); } - public static function v5_4_1 (): self + public static function v5_4_1(): self { return self::__callStatic('v5_4_1', 0); } - public static function v5_4_2 (): self + public static function v5_4_2(): self { return self::__callStatic('v5_4_2', 0); } - public static function v5_4_3 (): self + public static function v5_4_3(): self { return self::__callStatic('v5_4_3', 0); } - public static function v5_4_4 (): self + public static function v5_4_4(): self { return self::__callStatic('v5_4_4', 0); } - public static function v5_4_5 (): self + public static function v5_4_5(): self { return self::__callStatic('v5_4_5', 0); } - public static function v5_4_6 (): self + public static function v5_4_6(): self { return self::__callStatic('v5_4_6', 0); } - public static function v5_4_7 (): self + public static function v5_4_7(): self { return self::__callStatic('v5_4_7', 0); } - public static function v5_4_8 (): self + public static function v5_4_8(): self { return self::__callStatic('v5_4_8', 0); } - public static function v5_4_9 (): self + public static function v5_4_9(): self { return self::__callStatic('v5_4_9', 0); } - public static function v5_5 (): self + public static function v5_5(): self { return self::__callStatic('v5_5', 0); } - public static function v5_5_1 (): self + public static function v5_5_1(): self { return self::__callStatic('v5_5_1', 0); } - public static function v5_5_2 (): self + public static function v5_5_2(): self { return self::__callStatic('v5_5_2', 0); } - public static function v5_5_3 (): self + public static function v5_5_3(): self { return self::__callStatic('v5_5_3', 0); } - public static function v5_5_4 (): self + public static function v5_5_4(): self { return self::__callStatic('v5_5_4', 0); } - public static function v5_5_5 (): self + public static function v5_5_5(): self { return self::__callStatic('v5_5_5', 0); } - public static function v5_5_6 (): self + public static function v5_5_6(): self { return self::__callStatic('v5_5_6', 0); } - public static function v5_5_7 (): self + public static function v5_5_7(): self { return self::__callStatic('v5_5_7', 0); } - public static function v5_5_8 (): self + public static function v5_5_8(): self { return self::__callStatic('v5_5_8', 0); } - public static function v5_5_9 (): self + public static function v5_5_9(): self { return self::__callStatic('v5_5_9', 0); } - public static function v5_6 (): self + public static function v5_6(): self { return self::__callStatic('v5_6', 0); } - public static function v5_6_1 (): self + public static function v5_6_1(): self { return self::__callStatic('v5_6_1', 0); } - public static function v5_6_2 (): self + public static function v5_6_2(): self { return self::__callStatic('v5_6_2', 0); } - public static function v5_6_3 (): self + public static function v5_6_3(): self { return self::__callStatic('v5_6_3', 0); } - public static function v5_6_4 (): self + public static function v5_6_4(): self { return self::__callStatic('v5_6_4', 0); } - public static function v5_6_5 (): self + public static function v5_6_5(): self { return self::__callStatic('v5_6_5', 0); } - public static function v5_6_6 (): self + public static function v5_6_6(): self { return self::__callStatic('v5_6_6', 0); } - public static function v5_6_7 (): self + public static function v5_6_7(): self { return self::__callStatic('v5_6_7', 0); } - public static function v5_6_8 (): self + public static function v5_6_8(): self { return self::__callStatic('v5_6_8', 0); } - public static function v5_6_9 (): self + public static function v5_6_9(): self { return self::__callStatic('v5_6_9', 0); } - public static function v5_7 (): self + public static function v5_7(): self { return self::__callStatic('v5_7', 0); } - public static function v5_7_1 (): self + public static function v5_7_1(): self { return self::__callStatic('v5_7_1', 0); } - public static function v5_7_2 (): self + public static function v5_7_2(): self { return self::__callStatic('v5_7_2', 0); } - public static function v5_7_3 (): self + public static function v5_7_3(): self { return self::__callStatic('v5_7_3', 0); } - public static function v5_7_4 (): self + public static function v5_7_4(): self { return self::__callStatic('v5_7_4', 0); } - public static function v5_7_5 (): self + public static function v5_7_5(): self { return self::__callStatic('v5_7_5', 0); } - public static function v5_7_6 (): self + public static function v5_7_6(): self { return self::__callStatic('v5_7_6', 0); } - public static function v5_7_7 (): self + public static function v5_7_7(): self { return self::__callStatic('v5_7_7', 0); } - public static function v5_7_8 (): self + public static function v5_7_8(): self { return self::__callStatic('v5_7_8', 0); } - public static function v5_7_9 (): self + public static function v5_7_9(): self { return self::__callStatic('v5_7_9', 0); } - public static function v5_8 (): self + public static function v5_8(): self { return self::__callStatic('v5_8', 0); } - public static function v5_8_1 (): self + public static function v5_8_1(): self { return self::__callStatic('v5_8_1', 0); } - public static function v5_8_2 (): self + public static function v5_8_2(): self { return self::__callStatic('v5_8_2', 0); } - public static function v5_8_3 (): self + public static function v5_8_3(): self { return self::__callStatic('v5_8_3', 0); } - public static function v5_8_4 (): self + public static function v5_8_4(): self { return self::__callStatic('v5_8_4', 0); } - public static function v5_8_5 (): self + public static function v5_8_5(): self { return self::__callStatic('v5_8_5', 0); } - public static function v5_8_6 (): self + public static function v5_8_6(): self { return self::__callStatic('v5_8_6', 0); } - public static function v5_8_7 (): self + public static function v5_8_7(): self { return self::__callStatic('v5_8_7', 0); } - public static function v5_8_8 (): self + public static function v5_8_8(): self { return self::__callStatic('v5_8_8', 0); } - public static function v5_8_9 (): self + public static function v5_8_9(): self { return self::__callStatic('v5_8_9', 0); } - public static function v5_9 (): self + public static function v5_9(): self { return self::__callStatic('v5_9', 0); } - public static function v5_9_1 (): self + public static function v5_9_1(): self { return self::__callStatic('v5_9_1', 0); } - public static function v5_9_2 (): self + public static function v5_9_2(): self { return self::__callStatic('v5_9_2', 0); } - public static function v5_9_3 (): self + public static function v5_9_3(): self { return self::__callStatic('v5_9_3', 0); } - public static function v5_9_4 (): self + public static function v5_9_4(): self { return self::__callStatic('v5_9_4', 0); } - public static function v5_9_5 (): self + public static function v5_9_5(): self { return self::__callStatic('v5_9_5', 0); } - public static function v5_9_6 (): self + public static function v5_9_6(): self { return self::__callStatic('v5_9_6', 0); } - public static function v5_9_7 (): self + public static function v5_9_7(): self { return self::__callStatic('v5_9_7', 0); } - public static function v5_9_8 (): self + public static function v5_9_8(): self { return self::__callStatic('v5_9_8', 0); } - public static function v5_9_9 (): self + public static function v5_9_9(): self { return self::__callStatic('v5_9_9', 0); } - public static function v6 (): self + public static function v6(): self { return self::__callStatic('v6', 0); } - public static function v6_0 (): self + public static function v6_0(): self { return self::__callStatic('v6_0', 0); } - public static function v6_1 (): self + public static function v6_1(): self { return self::__callStatic('v6_1', 0); } - public static function v6_1_1 (): self + public static function v6_1_1(): self { return self::__callStatic('v6_1_1', 0); } - public static function v6_1_2 (): self + public static function v6_1_2(): self { return self::__callStatic('v6_1_2', 0); } - public static function v6_1_3 (): self + public static function v6_1_3(): self { return self::__callStatic('v6_1_3', 0); } - public static function v6_1_4 (): self + public static function v6_1_4(): self { return self::__callStatic('v6_1_4', 0); } - public static function v6_1_5 (): self + public static function v6_1_5(): self { return self::__callStatic('v6_1_5', 0); } - public static function v6_1_6 (): self + public static function v6_1_6(): self { return self::__callStatic('v6_1_6', 0); } - public static function v6_1_7 (): self + public static function v6_1_7(): self { return self::__callStatic('v6_1_7', 0); } - public static function v6_1_8 (): self + public static function v6_1_8(): self { return self::__callStatic('v6_1_8', 0); } - public static function v6_1_9 (): self + public static function v6_1_9(): self { return self::__callStatic('v6_1_9', 0); } - public static function v6_2 (): self + public static function v6_2(): self { return self::__callStatic('v6_2', 0); } - public static function v6_2_1 (): self + public static function v6_2_1(): self { return self::__callStatic('v6_2_1', 0); } - public static function v6_2_2 (): self + public static function v6_2_2(): self { return self::__callStatic('v6_2_2', 0); } - public static function v6_2_3 (): self + public static function v6_2_3(): self { return self::__callStatic('v6_2_3', 0); } - public static function v6_2_4 (): self + public static function v6_2_4(): self { return self::__callStatic('v6_2_4', 0); } - public static function v6_2_5 (): self + public static function v6_2_5(): self { return self::__callStatic('v6_2_5', 0); } - public static function v6_2_6 (): self + public static function v6_2_6(): self { return self::__callStatic('v6_2_6', 0); } - public static function v6_2_7 (): self + public static function v6_2_7(): self { return self::__callStatic('v6_2_7', 0); } - public static function v6_2_8 (): self + public static function v6_2_8(): self { return self::__callStatic('v6_2_8', 0); } - public static function v6_2_9 (): self + public static function v6_2_9(): self { return self::__callStatic('v6_2_9', 0); } - public static function v6_3 (): self + public static function v6_3(): self { return self::__callStatic('v6_3', 0); } - public static function v6_3_1 (): self + public static function v6_3_1(): self { return self::__callStatic('v6_3_1', 0); } - public static function v6_3_2 (): self + public static function v6_3_2(): self { return self::__callStatic('v6_3_2', 0); } - public static function v6_3_3 (): self + public static function v6_3_3(): self { return self::__callStatic('v6_3_3', 0); } - public static function v6_3_4 (): self + public static function v6_3_4(): self { return self::__callStatic('v6_3_4', 0); } - public static function v6_3_5 (): self + public static function v6_3_5(): self { return self::__callStatic('v6_3_5', 0); } - public static function v6_3_6 (): self + public static function v6_3_6(): self { return self::__callStatic('v6_3_6', 0); } - public static function v6_3_7 (): self + public static function v6_3_7(): self { return self::__callStatic('v6_3_7', 0); } - public static function v6_3_8 (): self + public static function v6_3_8(): self { return self::__callStatic('v6_3_8', 0); } - public static function v6_3_9 (): self + public static function v6_3_9(): self { return self::__callStatic('v6_3_9', 0); } - public static function v6_4 (): self + public static function v6_4(): self { return self::__callStatic('v6_4', 0); } - public static function v6_4_1 (): self + public static function v6_4_1(): self { return self::__callStatic('v6_4_1', 0); } - public static function v6_4_2 (): self + public static function v6_4_2(): self { return self::__callStatic('v6_4_2', 0); } - public static function v6_4_3 (): self + public static function v6_4_3(): self { return self::__callStatic('v6_4_3', 0); } - public static function v6_4_4 (): self + public static function v6_4_4(): self { return self::__callStatic('v6_4_4', 0); } - public static function v6_4_5 (): self + public static function v6_4_5(): self { return self::__callStatic('v6_4_5', 0); } - public static function v6_4_6 (): self + public static function v6_4_6(): self { return self::__callStatic('v6_4_6', 0); } - public static function v6_4_7 (): self + public static function v6_4_7(): self { return self::__callStatic('v6_4_7', 0); } - public static function v6_4_8 (): self + public static function v6_4_8(): self { return self::__callStatic('v6_4_8', 0); } - public static function v6_4_9 (): self + public static function v6_4_9(): self { return self::__callStatic('v6_4_9', 0); } - public static function v6_5 (): self + public static function v6_5(): self { return self::__callStatic('v6_5', 0); } - public static function v6_5_1 (): self + public static function v6_5_1(): self { return self::__callStatic('v6_5_1', 0); } - public static function v6_5_2 (): self + public static function v6_5_2(): self { return self::__callStatic('v6_5_2', 0); } - public static function v6_5_3 (): self + public static function v6_5_3(): self { return self::__callStatic('v6_5_3', 0); } - public static function v6_5_4 (): self + public static function v6_5_4(): self { return self::__callStatic('v6_5_4', 0); } - public static function v6_5_5 (): self + public static function v6_5_5(): self { return self::__callStatic('v6_5_5', 0); } - public static function v6_5_6 (): self + public static function v6_5_6(): self { return self::__callStatic('v6_5_6', 0); } - public static function v6_5_7 (): self + public static function v6_5_7(): self { return self::__callStatic('v6_5_7', 0); } - public static function v6_5_8 (): self + public static function v6_5_8(): self { return self::__callStatic('v6_5_8', 0); } - public static function v6_5_9 (): self + public static function v6_5_9(): self { return self::__callStatic('v6_5_9', 0); } - public static function v6_6 (): self + public static function v6_6(): self { return self::__callStatic('v6_6', 0); } - public static function v6_6_1 (): self + public static function v6_6_1(): self { return self::__callStatic('v6_6_1', 0); } - public static function v6_6_2 (): self + public static function v6_6_2(): self { return self::__callStatic('v6_6_2', 0); } - public static function v6_6_3 (): self + public static function v6_6_3(): self { return self::__callStatic('v6_6_3', 0); } - public static function v6_6_4 (): self + public static function v6_6_4(): self { return self::__callStatic('v6_6_4', 0); } - public static function v6_6_5 (): self + public static function v6_6_5(): self { return self::__callStatic('v6_6_5', 0); } - public static function v6_6_6 (): self + public static function v6_6_6(): self { return self::__callStatic('v6_6_6', 0); } - public static function v6_6_7 (): self + public static function v6_6_7(): self { return self::__callStatic('v6_6_7', 0); } - public static function v6_6_8 (): self + public static function v6_6_8(): self { return self::__callStatic('v6_6_8', 0); } - public static function v6_6_9 (): self + public static function v6_6_9(): self { return self::__callStatic('v6_6_9', 0); } - public static function v6_7 (): self + public static function v6_7(): self { return self::__callStatic('v6_7', 0); } - public static function v6_7_1 (): self + public static function v6_7_1(): self { return self::__callStatic('v6_7_1', 0); } - public static function v6_7_2 (): self + public static function v6_7_2(): self { return self::__callStatic('v6_7_2', 0); } - public static function v6_7_3 (): self + public static function v6_7_3(): self { return self::__callStatic('v6_7_3', 0); } - public static function v6_7_4 (): self + public static function v6_7_4(): self { return self::__callStatic('v6_7_4', 0); } - public static function v6_7_5 (): self + public static function v6_7_5(): self { return self::__callStatic('v6_7_5', 0); } - public static function v6_7_6 (): self + public static function v6_7_6(): self { return self::__callStatic('v6_7_6', 0); } - public static function v6_7_7 (): self + public static function v6_7_7(): self { return self::__callStatic('v6_7_7', 0); } - public static function v6_7_8 (): self + public static function v6_7_8(): self { return self::__callStatic('v6_7_8', 0); } - public static function v6_7_9 (): self + public static function v6_7_9(): self { return self::__callStatic('v6_7_9', 0); } - public static function v6_8 (): self + public static function v6_8(): self { return self::__callStatic('v6_8', 0); } - public static function v6_8_1 (): self + public static function v6_8_1(): self { return self::__callStatic('v6_8_1', 0); } - public static function v6_8_2 (): self + public static function v6_8_2(): self { return self::__callStatic('v6_8_2', 0); } - public static function v6_8_3 (): self + public static function v6_8_3(): self { return self::__callStatic('v6_8_3', 0); } - public static function v6_8_4 (): self + public static function v6_8_4(): self { return self::__callStatic('v6_8_4', 0); } - public static function v6_8_5 (): self + public static function v6_8_5(): self { return self::__callStatic('v6_8_5', 0); } - public static function v6_8_6 (): self + public static function v6_8_6(): self { return self::__callStatic('v6_8_6', 0); } - public static function v6_8_7 (): self + public static function v6_8_7(): self { return self::__callStatic('v6_8_7', 0); } - public static function v6_8_8 (): self + public static function v6_8_8(): self { return self::__callStatic('v6_8_8', 0); } - public static function v6_8_9 (): self + public static function v6_8_9(): self { return self::__callStatic('v6_8_9', 0); } - public static function v6_9 (): self + public static function v6_9(): self { return self::__callStatic('v6_9', 0); } - public static function v6_9_1 (): self + public static function v6_9_1(): self { return self::__callStatic('v6_9_1', 0); } - public static function v6_9_2 (): self + public static function v6_9_2(): self { return self::__callStatic('v6_9_2', 0); } - public static function v6_9_3 (): self + public static function v6_9_3(): self { return self::__callStatic('v6_9_3', 0); } - public static function v6_9_4 (): self + public static function v6_9_4(): self { return self::__callStatic('v6_9_4', 0); } - public static function v6_9_5 (): self + public static function v6_9_5(): self { return self::__callStatic('v6_9_5', 0); } - public static function v6_9_6 (): self + public static function v6_9_6(): self { return self::__callStatic('v6_9_6', 0); } - public static function v6_9_7 (): self + public static function v6_9_7(): self { return self::__callStatic('v6_9_7', 0); } - public static function v6_9_8 (): self + public static function v6_9_8(): self { return self::__callStatic('v6_9_8', 0); } - public static function v6_9_9 (): self + public static function v6_9_9(): self { return self::__callStatic('v6_9_9', 0); } - public static function v7 (): self + public static function v7(): self { return self::__callStatic('v7', 0); } - public static function v7_0 (): self + public static function v7_0(): self { return self::__callStatic('v7_0', 0); } - public static function v7_0_0 (): self + public static function v7_0_0(): self { return self::__callStatic('v7_0_0', 0); } diff --git a/src/Http/Interface/ApiController.php b/src/Http/ApiController.php similarity index 82% rename from src/Http/Interface/ApiController.php rename to src/Http/ApiController.php index 0caaf59..e91004c 100644 --- a/src/Http/Interface/ApiController.php +++ b/src/Http/ApiController.php @@ -1,8 +1,6 @@ param = $urlParam; } - /** * Returns URL parameters as an object. * * @return object The URL parameters. */ - public function urlParam (): object + public function urlParam(): object { return (object) $this->param; } @@ -49,20 +48,18 @@ public function urlParam (): object * * @return stdClass The parsed query parameters. */ - public function urlQuery (): stdClass + public function urlQuery(): stdClass { $cl = new stdClass(); $parsed = parse_url(self::$request_uri, PHP_URL_QUERY); - if (!$parsed) - { + if (!$parsed) { return $cl; } $parsed = mb_split('&', $parsed); $i = 0; - while ($i < count($parsed)) - { + while ($i < count($parsed)) { $p = mb_split('=', $parsed[$i]); $key = $p[0]; $value = $p[1] ? $this->validate($p[1]) : null; @@ -78,23 +75,19 @@ public function urlQuery (): stdClass * Retrieves headers from the request. * * @param ?string $name Optional header name to retrieve a specific header. - * @return array|string|false The headers, or a specific header value if $name is provided. + * @return mixed The headers, or a specific header value if $name is provided. */ - public function headers (?string $name = null): array|string|false + public function headers(?string $name = null): mixed { $headers = getallheaders(); - if (!$name) - { - return array_map([ $this, 'validate' ], $headers); + if (!$name) { + return array_map([$this, 'validate'], $headers); } - if (isset($headers[$name])) - { + if (isset($headers[$name])) { return $this->validate($headers[$name]); - } - else - { - return false; + } else { + return null; } } @@ -103,7 +96,7 @@ public function headers (?string $name = null): array|string|false * * @return stdClass The authentication credentials. */ - public function auth (): stdClass + public function auth(): stdClass { $cl = new stdClass(); $cl->basic = self::BasicAuthCredentials(); @@ -117,25 +110,22 @@ public function auth (): stdClass * Parses and returns the body of the request as an associative array. * * @param ?string $name The particular request body to get - * @return array|string|null The request body data, or null if parsing fails. + * @return mixed The request body data, or null if parsing fails. */ - public function body (?string $name = null): array|string|null + public function body(?string $name = null): mixed { $data = json_decode(file_get_contents('php://input'), true); - if ($data === null || json_last_error() !== JSON_ERROR_NONE) - { + if ($data === null || json_last_error() !== JSON_ERROR_NONE) { return null; } - if ($name !== null) - { + if ($name !== null) { return $this->validate($data[$name]); } $res = []; - foreach ($data as $key => $value) - { + foreach ($data as $key => $value) { $key = $this->validate($key); $value = $this->validate($value); @@ -149,16 +139,14 @@ public function body (?string $name = null): array|string|null * And if no parameter is provided, returns all key and values in pairs * * @param ?string $key The key of the GET parameter. - * @return string|array|null The parameter value, or null if not set. + * @return mixed The parameter value, or null if not set. */ - public function get (?string $key = null): string|array|null + public function get(?string $key = null): mixed { - if (!$key) - { - return array_map([ $this, 'validate' ], $_GET); + if (!$key) { + return array_map([$this, 'validate'], $_GET); } - if (!isset($_GET[$key])) - { + if (!isset($_GET[$key])) { return null; } @@ -171,16 +159,14 @@ public function get (?string $key = null): string|array|null * And if no parameter is provided, returns all key and values in pairs * * @param string $key The key of the POST parameter. - * @return string|array|null The parameter values, or null if not set. + * @return mixed The parameter values, or null if not set. */ - public function post (?string $key = null): string|array|null + public function post(?string $key = null): mixed { - if (!$key) - { - return array_map([ $this, 'validate' ], $_POST); + if (!$key) { + return array_map([$this, 'validate'], $_POST); } - if (!isset($_POST[$key])) - { + if (!isset($_POST[$key])) { return null; } @@ -193,16 +179,14 @@ public function post (?string $key = null): string|array|null * And if no parameter is provided, returns all key and values in pairs * * @param ?string $key The key of the request parameter. - * @return string|array|null The parameter value, or null if not set. + * @return mixed The parameter value, or null if not set. */ - public function request (?string $key = null): string|array|null + public function request(?string $key = null): mixed { - if (!$key) - { - return array_map([ $this, 'validate' ], $_REQUEST); + if (!$key) { + return array_map([$this, 'validate'], $_REQUEST); } - if (!isset($_REQUEST[$key])) - { + if (!isset($_REQUEST[$key])) { return null; } @@ -217,14 +201,12 @@ public function request (?string $key = null): string|array|null * @param ?string $name The name of the file input. * @return object|null File data, or null if not set. */ - public function files (?string $name = null): object|null + public function files(?string $name = null): object|null { - if (!$name) - { + if (!$name) { return (object) $_FILES; } - if (!isset($_FILES[$name])) - { + if (!isset($_FILES[$name])) { return null; } @@ -236,13 +218,12 @@ public function files (?string $name = null): object|null * Retrieves a cookie value by key, or all cookies if no key is provided. * * @param ?string $key Optional cookie key. - * @return string|object|null The cookie value, all cookies as an object, or null if key is provided but not found. + * @return mixed The cookie value, all cookies as an object, or null if key is provided but not found. */ - public function cookie (?string $key = null): string|object|null + public function cookie(?string $key = null): mixed { - if (!$key) - { - return (object) $_COOKIE; + if (!$key) { + return (object) array_map([$this, 'validate'], $_COOKIE); } return isset($_COOKIE[$key]) ? $this->validate($_COOKIE[$key]) : null; } @@ -251,14 +232,13 @@ public function cookie (?string $key = null): string|object|null * Retrieves a session value by key, or all session if no key is provided. * * @param ?string $key Optional cookie key. - * @return string|object|null The cookie value, all cookies as an object, or null if key is provided but not found. + * @return mixed The cookie value, all cookies as an object, or null if key is provided but not found. */ - public function session (?string $key = null): string|object|null + public function session(?string $key = null): mixed { session_status() < 2 && session_start(); - if (!$key) - { - return (object) $_SESSION; + if (!$key) { + return (object) array_map([$this, 'validate'], $_SESSION); } return isset($_SESSION[$key]) ? $this->validate($_SESSION[$key]) : null; } @@ -268,7 +248,7 @@ public function session (?string $key = null): string|object|null * * @return string The HTTP method (e.g., GET, POST). */ - public function method (): string + public function method(): string { return $_SERVER['REQUEST_METHOD']; } @@ -278,7 +258,7 @@ public function method (): string * * @return string The URI. */ - public function uri (): string + public function uri(): string { return self::$request_uri; } @@ -288,7 +268,7 @@ public function uri (): string * * @return object The parsed URL components. */ - public function url (): object + public function url(): object { $uri = $this->uri(); $parsed = parse_url($uri); @@ -304,7 +284,7 @@ public function url (): object * * @return string The client's IP address. */ - public function ip (): string + public function ip(): string { return $this->validate($_SERVER['REMOTE_ADDR']); } @@ -314,7 +294,7 @@ public function ip (): string * * @return string The user agent string. */ - public function userAgent (): string + public function userAgent(): string { return $this->validate($_SERVER['HTTP_USER_AGENT']); } @@ -324,10 +304,10 @@ public function userAgent (): string * * @return bool True if the request is an AJAX request, false otherwise. */ - public function isAjax (): bool + public function isAjax(): bool { return !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && - strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest'; + strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest'; } /** @@ -335,11 +315,11 @@ public function isAjax (): bool * * @return string|null The referrer URL, or null if not set. */ - public function referrer (): ?string + public function referrer(): ?string { return isset($_SERVER['HTTP_REFERER']) - ? $this->validate($_SERVER['HTTP_REFERER']) - : null; + ? $this->validate($_SERVER['HTTP_REFERER']) + : null; } /** @@ -347,7 +327,7 @@ public function referrer (): ?string * * @return string The server protocol. */ - public function protocol (): string + public function protocol(): string { return $this->validate($_SERVER['SERVER_PROTOCOL']); } @@ -357,10 +337,10 @@ public function protocol (): string * * @return array The combined input data. */ - public function all (): array + public function all(): array { $data = array_merge($_GET, $_POST, $this->body() ?? []); - return array_map([ $this, 'validate' ], $data); + return array_map([$this, 'validate'], $data); } /** @@ -368,13 +348,12 @@ public function all (): array * And if no parameter is provided, it returns all the keys and values in pairs * * @param string $key The key of the server parameter. - * @return object|string|null The server parameter value, or null if not set. + * @return mixed The server parameter value, or null if not set. */ - public function server (?string $key = null): object|string|null + public function server(?string $key = null): mixed { - if (!$key) - { - return (object) array_map([ $this, 'validate' ], $_SERVER); + if (!$key) { + return (object) array_map([$this, 'validate'], $_SERVER); } return isset($_SERVER[$key]) ? $this->validate($_SERVER[$key]) : null; } @@ -385,7 +364,7 @@ public function server (?string $key = null): object|string|null * @param string $method The HTTP method to check. * @return bool True if the request method matches, false otherwise. */ - public function isMethod (string $method): bool + public function isMethod(string $method): bool { return strtoupper($this->method()) === strtoupper($method); } @@ -395,7 +374,7 @@ public function isMethod (string $method): bool * * @return bool True if the request is HTTPS, false otherwise. */ - public function isHttps (): bool + public function isHttps(): bool { return isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on'; } @@ -405,8 +384,8 @@ public function isHttps (): bool * * @return int The request time as a Unix timestamp. */ - public function requestTime (): int + public function requestTime(): int { return $_SERVER['REQUEST_TIME']; } -} \ No newline at end of file +} diff --git a/src/Interface/MiddlewareInterface.php b/src/Interface/MiddlewareInterface.php deleted file mode 100644 index 4976fa7..0000000 --- a/src/Interface/MiddlewareInterface.php +++ /dev/null @@ -1,11 +0,0 @@ -__api_middleware(); - } + self::__api_guards(self::$route['guards'] ?? null); print_r(self::__routeSelection()); exit(); @@ -101,74 +95,56 @@ protected function __routeSelection(?Request $request = null) } EXECUTE: - if ($cc instanceof ApiController) { - if ($request === null) { - $request = new Request($params); - } + if ($request === null) { + $request = new Request($params); + } - if (method_exists($cc, $r_method)) { - $response = $cc->$r_method($request); - } + if (method_exists($cc, $r_method)) { + $response = $cc->$r_method($request); + } - $r_method = 'error'; - $response = !$response ? $cc->$r_method($request) : $response; + $r_method = 'error'; + $response = !$response ? $cc->$r_method($request) : $response; - self::log(); - return $response; - } else { - throw new Exception( - 'Api controller class must implements `ApiController`' - ); - } + self::log(); + return $response; } - protected function __api_middleware(): void + protected function __api_guards(?array $guards): bool { - $middleware = self::$apiMiddleware ?? []; - $response = ''; + if (!$guards) { + return true; + } $params = self::$map_info['params'] ?? null; $request = new Request($params); - for ($i = 0; $i < count((array) $middleware); $i++) { - $middlewares = (new FileLoader()) - ->load(__DIR__ . '/../../Config/middleware.php') + for ($i = 0; $i < count((array) $guards); $i++) { + $registered_guards = (new FileLoader()) + ->load(__DIR__ . '/../../Config/guards.php') ->getLoad(); - if (array_key_exists($middleware[$i], $middlewares)) { - $middleware = $middlewares[$middleware[$i]]; + if (array_key_exists($guards[$i], $registered_guards)) { + $guard = $registered_guards[$guards[$i]]; } else { self::log(); throw new Exception( - 'No Registered Middleware as `' . $middleware[$i] . '`' + 'No Registered AuthGuard as `' . $guards[$i] . '`' ); } - if (!class_exists($middleware)) { + if (!class_exists($guard)) { self::log(); - throw new Exception( - "Middleware class does not exist: `{$middleware}`" - ); + throw new Exception("AuthGuard class does not exist: `{$guard}`"); } - $mw = new $middleware(); - - if ($mw instanceof MiddlewareInterface) { - $next = function (Request $request) { - return $this->__routeSelection($request); - }; + $cl = new $guard($request); - $response = $mw->handle($request, $next); - } else { + if ($cl->authorize() !== true) { self::log(); - throw new Exception( - 'Middleware class must implements `MiddlewareInterface`' - ); + exit(); } } - - print_r($response); - self::log(); - exit(); + return true; } protected function __api_map(?Request $request = null): void @@ -178,8 +154,9 @@ protected function __api_map(?Request $request = null): void $controller = $map['controller'] ?? ''; foreach ($map as $route => $method) { - $r_method = $method[0]; - $c_method = $method[1]; + $r_method = $method[0] ?? 'GET'; + $c_method = $method[1] ?? ''; + $guards = $method[2] ?? null; $url = $base_url . trim($route, '/'); self::$apiMap = [ @@ -192,9 +169,7 @@ protected function __api_map(?Request $request = null): void self::$map_info = $match->match($r_method, $url); if (self::$map_info) { - if (self::$apiMiddleware !== null) { - $this->__api_middleware(); - } + $this->__api_guards($guards); print_r(self::__routeSelection()); exit(); diff --git a/src/Traits/Resources/RouteResources.php b/src/Traits/Resources/RouteResources.php index 4e56c68..fa0e23d 100644 --- a/src/Traits/Resources/RouteResources.php +++ b/src/Traits/Resources/RouteResources.php @@ -7,13 +7,12 @@ use PhpSlides\Exception; use PhpSlides\Http\Request; use PhpSlides\Loader\FileLoader; -use PhpSlides\Interface\MiddlewareInterface; trait RouteResources { protected static mixed $action = null; - protected static ?array $middleware = null; + protected static ?array $guards = null; protected static ?array $redirect = null; @@ -50,9 +49,7 @@ protected static function __map(): void self::$map_info = $match->match($method, $route); if (self::$map_info) { - if (self::$middleware !== null) { - $static->__middleware(); - } + $static->__guards(self::$guards ?? null); if (self::$use !== null) { $static->__use(); @@ -242,8 +239,8 @@ protected static function __any(?Request $request = null): void exit('Method Not Allowed'); } - if (self::$middleware !== null) { - (new static())->__middleware(); + if (self::$guards !== null) { + (new static())->__guards(self::$guards ?? null); } http_response_code(200); @@ -338,9 +335,7 @@ protected static function __view(?Request $request = null): void exit('Method Not Allowed'); } - if (self::$middleware !== null) { - (new static())->__middleware(); - } + (new static())->__guards(self::$guards ?? null); // render view page to browser $GLOBALS['request'] = $request; @@ -350,82 +345,40 @@ protected static function __view(?Request $request = null): void } } - protected function __middleware(): void + protected function __guards(?array $guards): bool { - $use = self::$use; - $file = self::$file; - $action = self::$action; - - $any = self::$any; - $view = self::$view; - $method = self::$method; - $middleware = self::$middleware ?? []; - self::$middleware = null; - + if (!$guards) { + return true; + } $params = self::$map_info['params'] ?? null; $request = new Request($params); - for ($i = 0; $i < count((array) $middleware); $i++) { - $middlewares = (new FileLoader()) - ->load(__DIR__ . '/../../Config/middleware.php') + for ($i = 0; $i < count((array) $guards); $i++) { + $registered_guards = (new FileLoader()) + ->load(__DIR__ . '/../../Config/guards.php') ->getLoad(); - if (array_key_exists($middleware[$i], $middlewares)) { - $middleware = $middlewares[$middleware[$i]]; + if (array_key_exists($guards[$i], $registered_guards)) { + $guard = $registered_guards[$guards[$i]]; } else { self::log(); throw new Exception( - 'No Registered Middleware as `' . $middleware[$i] . '`' + 'No Registered AuthGuard as `' . $guards[$i] . '`' ); } - if (!class_exists($middleware)) { + if (!class_exists($guard)) { self::log(); - throw new Exception( - "Middleware class does not exist: `{$middleware}`" - ); + throw new Exception("AuthGuard class does not exist: `{$guard}`"); } + $cl = new $guard($request); - $mw = new $middleware(); - if ($mw instanceof MiddlewareInterface) { - $next = function (Request $req) use ( - $any, - $use, - $file, - $action, - $view, - $method - ) { - if ($use !== null) { - self::__use($req); - } elseif ($any !== null) { - self::__any($req); - } elseif ($file !== null) { - self::__file($req); - } elseif ($action !== null) { - self::__action($req); - } elseif ($view !== null) { - self::__view($req); - } elseif ($method !== null) { - self::__method($req); - } else { - self::log(); - throw new Exception('Cannot use middleware with this method'); - } - }; - $response = $mw->handle($request, $next); - } else { + if ($cl->authorize() !== true) { self::log(); - throw new Exception( - 'Middleware class must implements `MiddlewareInterface`' - ); + exit(); } } - if (!empty($response)) { - print_r($response); - self::log(); - exit(); - } + return true; } protected function __file(?Request $request = null): void From 342ee2b90b603c9215eec25df5f3da3ce730fafb Mon Sep 17 00:00:00 2001 From: dconco Date: Sun, 25 Aug 2024 06:31:27 +0100 Subject: [PATCH 2/2] Added Authorization Guard --- ChangeLog.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 68b48dd..1d44921 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,10 +2,10 @@ ## [v1.2.9] -### [Sat, 24-08-2024] - -- Added Authorization Guard. -- Implemented AuthGuard to Routes -- Implemented AuthGuard to APIs -- Middleware is now deprecated and removed -- Added AuthGuard to Console \ No newline at end of file +- Added Authorization Guard. +- Implemented AuthGuard to Routes +- Implemented AuthGuard to APIs +- Middleware is now deprecated and removed +- Added AuthGuard to Console +- Updated ApiController and no more interface, now an abstract class. +-