Updated the project for PHP 7.4+ compatibility.

This commit is contained in:
2026-05-31 12:54:12 +03:30
parent a8a5065553
commit 2703e956da
5 changed files with 23 additions and 18 deletions
+2 -2
View File
@@ -3,8 +3,8 @@
/** /**
* Plugin Name: Mahak Authenticate Bridge * Plugin Name: Mahak Authenticate Bridge
* Description: Authenticate WordPress user via json web token from Mahakiha Application. * Description: Authenticate WordPress user via json web token from Mahakiha Application.
* Version: 1.0 * Version: 2.0
* Requires PHP: 8.0 * Requires PHP: 7.4
* Author: Dabestaniha * Author: Dabestaniha
* *
* Example: https://wordpress.test/mahak/login/?token=eyJ0... * Example: https://wordpress.test/mahak/login/?token=eyJ0...
+9 -6
View File
@@ -6,7 +6,7 @@ use Dabestaniha\AuthenticateBridge\App\Support\Collection;
abstract class BaseFormRequest abstract class BaseFormRequest
{ {
public static function make(): static public static function make(): self
{ {
return new static(); return new static();
} }
@@ -58,11 +58,14 @@ abstract class BaseFormRequest
protected function validateValue($value, $rule): bool protected function validateValue($value, $rule): bool
{ {
return match ($rule) { switch ($rule) {
'required' => !empty($value), case 'required':
'nullable' => true, return !empty($value);
default => false, case 'nullable':
}; return true;
default:
return false;
}
} }
+5 -3
View File
@@ -4,14 +4,16 @@ namespace Dabestaniha\AuthenticateBridge\App\Support;
class Collection class Collection
{ {
public static function make(array $items): static public static function make(array $items): self
{ {
return new static($items); 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) public function get(string $key, $default = null)
+2 -2
View File
@@ -81,7 +81,7 @@ final class JwtDecoder
return self::objectToArray($decoded); return self::objectToArray($decoded);
} }
private static function objectToArray(mixed $value): mixed private static function objectToArray($value)
{ {
if ($value instanceof stdClass) { if ($value instanceof stdClass) {
$items = []; $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)) { if (is_int($value) || is_float($value)) {
return (int) $value; return (int) $value;
+3 -3
View File
@@ -9,7 +9,7 @@ if (!function_exists('view')) {
} }
if (!function_exists('dd')) { if (!function_exists('dd')) {
function dd(): never function dd(): void
{ {
echo '<pre>'; echo '<pre>';
array_map(function ($arg) { array_map(function ($arg) {
@@ -32,7 +32,7 @@ function setup_configs(): void
setup_configs(); setup_configs();
if (!function_exists('config')) { 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; $value = MAHAK_CASHED_CONFIG;
foreach (explode('.', $key) as $key) { foreach (explode('.', $key) as $key) {
@@ -44,7 +44,7 @@ if (!function_exists('config')) {
if (!function_exists('get_configured_option')) { 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); return get_option(config("mahak.options.$key"), $default);
} }