diff --git a/dabestaniha-authenticate-bridge.php b/dabestaniha-authenticate-bridge.php index 5c425a5..aa01930 100644 --- a/dabestaniha-authenticate-bridge.php +++ b/dabestaniha-authenticate-bridge.php @@ -3,8 +3,8 @@ /** * Plugin Name: Mahak Authenticate Bridge * Description: Authenticate WordPress user via json web token from Mahakiha Application. - * Version: 1.0 - * Requires PHP: 8.0 + * Version: 2.0 + * Requires PHP: 7.4 * Author: Dabestaniha * * Example: https://wordpress.test/mahak/login/?token=eyJ0... @@ -29,4 +29,4 @@ add_action('init', fn() => AuthenticateController::resolve()); add_action('admin_menu', fn() => SettingsPageMenuController::resolve()); add_action('admin_init', fn() => SettingsPageFormController::resolve()); -echo true; \ No newline at end of file +echo true; diff --git a/src/app/Http/Requests/BaseFormRequest.php b/src/app/Http/Requests/BaseFormRequest.php index 58f30b8..7a075a9 100644 --- a/src/app/Http/Requests/BaseFormRequest.php +++ b/src/app/Http/Requests/BaseFormRequest.php @@ -6,7 +6,7 @@ use Dabestaniha\AuthenticateBridge\App\Support\Collection; abstract class BaseFormRequest { - public static function make(): static + public static function make(): self { return new static(); } @@ -58,11 +58,14 @@ abstract class BaseFormRequest protected function validateValue($value, $rule): bool { - return match ($rule) { - 'required' => !empty($value), - 'nullable' => true, - default => false, - }; + switch ($rule) { + case 'required': + return !empty($value); + case 'nullable': + return true; + default: + return false; + } } diff --git a/src/app/Support/Collection.php b/src/app/Support/Collection.php index 0d578ed..7a88152 100644 --- a/src/app/Support/Collection.php +++ b/src/app/Support/Collection.php @@ -4,18 +4,20 @@ namespace Dabestaniha\AuthenticateBridge\App\Support; class Collection { - public static function make(array $items): static + public static function make(array $items): self { return new static($items); } - public function __construct(private array $items) + private array $items; + + public function __construct(array $items) { - // + $this->items = $items; } public function get(string $key, $default = null) { return $this->items[$key] ?? $default; } -} \ No newline at end of file +} diff --git a/src/app/Support/JwtDecoder.php b/src/app/Support/JwtDecoder.php index 46da01b..b6f9e25 100644 --- a/src/app/Support/JwtDecoder.php +++ b/src/app/Support/JwtDecoder.php @@ -81,7 +81,7 @@ final class JwtDecoder return self::objectToArray($decoded); } - private static function objectToArray(mixed $value): mixed + private static function objectToArray($value) { if ($value instanceof stdClass) { $items = []; @@ -119,7 +119,7 @@ final class JwtDecoder } } - private static function numericDate(mixed $value, string $claim): int + private static function numericDate($value, string $claim): int { if (is_int($value) || is_float($value)) { return (int) $value; diff --git a/src/helpers.php b/src/helpers.php index 1b0a27e..c335b16 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -9,7 +9,7 @@ if (!function_exists('view')) { } if (!function_exists('dd')) { - function dd(): never + function dd(): void { echo '
';
array_map(function ($arg) {
@@ -32,7 +32,7 @@ function setup_configs(): void
setup_configs();
if (!function_exists('config')) {
- function config(string $key, ?string $default = null): null|string|array
+ function config(string $key, ?string $default = null)
{
$value = MAHAK_CASHED_CONFIG;
foreach (explode('.', $key) as $key) {
@@ -44,7 +44,7 @@ if (!function_exists('config')) {
if (!function_exists('get_configured_option')) {
- function get_configured_option(string $key, ?string $default = null): null|string|array
+ function get_configured_option(string $key, ?string $default = null)
{
return get_option(config("mahak.options.$key"), $default);
}