From 9d99fd534f029630d40de1b14417cf9da0eb718d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Zapletal?= Date: Sun, 21 Apr 2024 19:07:28 -0600 Subject: [PATCH] Added shortcut for null --- src/Collection/WriteBuilder/Rule/AnyOfRule.php | 6 ++---- src/Collection/WriteBuilder/Rule/Base/BaseRule.php | 2 +- src/Collection/WriteBuilder/Rule/CallableRule.php | 2 +- src/Collection/WriteBuilder/Rule/EqualRule.php | 4 ++-- src/Collection/WriteBuilder/Rule/HourMinuteRule.php | 4 ++-- src/Collection/WriteBuilder/Rule/MaxRule.php | 4 ++-- src/Collection/WriteBuilder/Rule/MinRule.php | 4 ++-- src/Collection/WriteBuilder/Rule/PhoneCzRule.php | 4 ++-- src/Collection/WriteBuilder/Rule/RegexRule.php | 8 ++------ src/Collection/WriteBuilder/Rule/UniqueRule.php | 11 ++++------- src/Collection/WriteBuilder/Rule/VideoLinkRule.php | 4 ++-- src/Http/Request/Resource/ReadAllRequest.php | 2 +- 12 files changed, 23 insertions(+), 32 deletions(-) diff --git a/src/Collection/WriteBuilder/Rule/AnyOfRule.php b/src/Collection/WriteBuilder/Rule/AnyOfRule.php index 3febecd..6bff561 100644 --- a/src/Collection/WriteBuilder/Rule/AnyOfRule.php +++ b/src/Collection/WriteBuilder/Rule/AnyOfRule.php @@ -8,13 +8,11 @@ class AnyOfRule extends BaseRule { /** - * AnyOfRule constructor. * @param array $keys - * @param string|null $message */ public function __construct( - protected array $keys, - protected string|null $message = null + protected array $keys, + protected ?string $message = null ) { parent::__construct(message: $message); diff --git a/src/Collection/WriteBuilder/Rule/Base/BaseRule.php b/src/Collection/WriteBuilder/Rule/Base/BaseRule.php index ee6cb5a..5b701fd 100644 --- a/src/Collection/WriteBuilder/Rule/Base/BaseRule.php +++ b/src/Collection/WriteBuilder/Rule/Base/BaseRule.php @@ -18,7 +18,7 @@ abstract class BaseRule implements IRule /** @var IRule[] */ protected array $relatedRules = []; - public function __construct(protected string|null $message = null) + public function __construct(protected ?string $message = null) { } diff --git a/src/Collection/WriteBuilder/Rule/CallableRule.php b/src/Collection/WriteBuilder/Rule/CallableRule.php index 4a33183..44d3d22 100644 --- a/src/Collection/WriteBuilder/Rule/CallableRule.php +++ b/src/Collection/WriteBuilder/Rule/CallableRule.php @@ -15,7 +15,7 @@ class CallableRule extends BaseRule public function __construct( callable $callback, - protected string|null $message = null, + protected ?string $message = null, ) { $this->callback = [$callback]; diff --git a/src/Collection/WriteBuilder/Rule/EqualRule.php b/src/Collection/WriteBuilder/Rule/EqualRule.php index b8689f2..77f4dcd 100644 --- a/src/Collection/WriteBuilder/Rule/EqualRule.php +++ b/src/Collection/WriteBuilder/Rule/EqualRule.php @@ -8,8 +8,8 @@ class EqualRule extends BaseRule { public function __construct( - protected string $targetField, - protected string|null $message = null + protected string $targetField, + protected ?string $message = null ) { parent::__construct(message: $message); diff --git a/src/Collection/WriteBuilder/Rule/HourMinuteRule.php b/src/Collection/WriteBuilder/Rule/HourMinuteRule.php index dfeb5c6..9273df5 100644 --- a/src/Collection/WriteBuilder/Rule/HourMinuteRule.php +++ b/src/Collection/WriteBuilder/Rule/HourMinuteRule.php @@ -8,8 +8,8 @@ class HourMinuteRule extends BaseRule { public function __construct( - protected string|null $message = null, - protected bool $normalize = true + protected ?string $message = null, + protected bool $normalize = true ) { parent::__construct(message: $message); diff --git a/src/Collection/WriteBuilder/Rule/MaxRule.php b/src/Collection/WriteBuilder/Rule/MaxRule.php index 815427d..760a8d4 100644 --- a/src/Collection/WriteBuilder/Rule/MaxRule.php +++ b/src/Collection/WriteBuilder/Rule/MaxRule.php @@ -8,8 +8,8 @@ class MaxRule extends BaseRule { public function __construct( - protected int $max, - protected string|null $message = null + protected int $max, + protected ?string $message = null ) { parent::__construct(message: $message); diff --git a/src/Collection/WriteBuilder/Rule/MinRule.php b/src/Collection/WriteBuilder/Rule/MinRule.php index 72e99c0..ff252a8 100644 --- a/src/Collection/WriteBuilder/Rule/MinRule.php +++ b/src/Collection/WriteBuilder/Rule/MinRule.php @@ -8,8 +8,8 @@ class MinRule extends BaseRule { public function __construct( - protected int $min, - protected string|null $message = null + protected int $min, + protected ?string $message = null ) { parent::__construct(message: $message); diff --git a/src/Collection/WriteBuilder/Rule/PhoneCzRule.php b/src/Collection/WriteBuilder/Rule/PhoneCzRule.php index e4ca882..bf7fd10 100644 --- a/src/Collection/WriteBuilder/Rule/PhoneCzRule.php +++ b/src/Collection/WriteBuilder/Rule/PhoneCzRule.php @@ -8,8 +8,8 @@ class PhoneCzRule extends BaseRule { public function __construct( - protected string|null $message = null, - protected bool $normalize = true + protected ?string $message = null, + protected bool $normalize = true ) { parent::__construct(message: $message); diff --git a/src/Collection/WriteBuilder/Rule/RegexRule.php b/src/Collection/WriteBuilder/Rule/RegexRule.php index 60fcb9c..acf6ad4 100644 --- a/src/Collection/WriteBuilder/Rule/RegexRule.php +++ b/src/Collection/WriteBuilder/Rule/RegexRule.php @@ -7,13 +7,9 @@ class RegexRule extends BaseRule { - /** - * @param string $expression - * @param string|null $message - */ public function __construct( - protected string $expression, - protected string|null $message = null + protected string $expression, + protected ?string $message = null ) { parent::__construct(message: $message); diff --git a/src/Collection/WriteBuilder/Rule/UniqueRule.php b/src/Collection/WriteBuilder/Rule/UniqueRule.php index 4617ee1..bd8e1fa 100644 --- a/src/Collection/WriteBuilder/Rule/UniqueRule.php +++ b/src/Collection/WriteBuilder/Rule/UniqueRule.php @@ -12,15 +12,12 @@ class UniqueRule extends BaseRule { /** * @param class-string $targetEntity - * @param string $columnName - * @param string $primaryKey - * @param string|null $message */ public function __construct( - protected string $targetEntity, - protected string $columnName, - protected string $primaryKey = 'id', - protected string|null $message = null + protected string $targetEntity, + protected string $columnName, + protected string $primaryKey = 'id', + protected ?string $message = null ) { parent::__construct(message: $message); diff --git a/src/Collection/WriteBuilder/Rule/VideoLinkRule.php b/src/Collection/WriteBuilder/Rule/VideoLinkRule.php index 7d60128..74595e1 100644 --- a/src/Collection/WriteBuilder/Rule/VideoLinkRule.php +++ b/src/Collection/WriteBuilder/Rule/VideoLinkRule.php @@ -8,8 +8,8 @@ class VideoLinkRule extends BaseRule { public function __construct( - protected string|null $message = null, - protected bool $normalize = true + protected ?string $message = null, + protected bool $normalize = true ) { parent::__construct(message: $message); diff --git a/src/Http/Request/Resource/ReadAllRequest.php b/src/Http/Request/Resource/ReadAllRequest.php index a6ee2b3..e18f750 100644 --- a/src/Http/Request/Resource/ReadAllRequest.php +++ b/src/Http/Request/Resource/ReadAllRequest.php @@ -133,7 +133,7 @@ private function sortCollectionDataResources(array $resources): array return $resources; } - private function createHint(ResourceType $type, string $name): string|null + private function createHint(ResourceType $type, string $name): ?string { if ($type === ResourceType::VUE_ROUTER) { return null;