@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | } |
19 | 19 | } |
20 | 20 | |
21 | - public function get(string|int $index, $default = null): mixed |
|
21 | + public function get(string | int $index, $default = null): mixed |
|
22 | 22 | { |
23 | 23 | return $this->elements[$index] ?? $default; |
24 | 24 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | return true; |
45 | 45 | } |
46 | 46 | |
47 | - public function indexOf(mixed $element): bool|int|string |
|
47 | + public function indexOf(mixed $element): bool | int | string |
|
48 | 48 | { |
49 | 49 | return array_search($element, $this->elements, true); |
50 | 50 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | return $this; |
98 | 98 | } |
99 | 99 | |
100 | - public function forEach(callable $callback, bool $stopable = false): static |
|
100 | + public function forEach (callable $callback, bool $stopable = false): static |
|
101 | 101 | { |
102 | 102 | foreach ($this->elements as $index => $element) { |
103 | 103 | $result = call_user_func_array($callback, [$element, $index]); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @return RuleSet[] |
17 | 17 | * @throws ReflectionException if the class does not exist |
18 | 18 | */ |
19 | - public static function fromProperties(string|object $objectOrClass, ?int $filter = null): array |
|
19 | + public static function fromProperties(string | object $objectOrClass, ?int $filter = null): array |
|
20 | 20 | { |
21 | 21 | $ruleSets = []; |
22 | 22 | foreach ((new ReflectionClass($objectOrClass))->getProperties($filter) as $property) { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @return RuleSet[] |
33 | 33 | * @throws ReflectionException |
34 | 34 | */ |
35 | - public static function fromMethods(string|object $objectOrClass, ?int $filter = null): array |
|
35 | + public static function fromMethods(string | object $objectOrClass, ?int $filter = null): array |
|
36 | 36 | { |
37 | 37 | $ruleSets = []; |
38 | 38 | foreach ((new ReflectionClass($objectOrClass))->getMethods($filter) as $method) { |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @return RuleSet |
49 | 49 | * @throws ReflectionException if the class or property does not exist. |
50 | 50 | */ |
51 | - public static function fromProperty(string|object $objectOrClass, string $property): RuleSet |
|
51 | + public static function fromProperty(string | object $objectOrClass, string $property): RuleSet |
|
52 | 52 | { |
53 | 53 | return self::fromReflectionProperty(new ReflectionProperty($objectOrClass, $property)); |
54 | 54 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @return RuleSet |
60 | 60 | * @throws ReflectionException |
61 | 61 | */ |
62 | - public static function fromMethod(string|object $objectOrClass, string $method): RuleSet |
|
62 | + public static function fromMethod(string | object $objectOrClass, string $method): RuleSet |
|
63 | 63 | { |
64 | 64 | return self::fromReflectionMethod(new ReflectionMethod($objectOrClass, $method)); |
65 | 65 | } |
@@ -7,7 +7,7 @@ |
||
7 | 7 | { |
8 | 8 | public function validateOrFail($input, array $context = [], string $message = 'Validation errors'): void |
9 | 9 | { |
10 | - if (! $this instanceof Rule) { |
|
10 | + if (!$this instanceof Rule) { |
|
11 | 11 | return; |
12 | 12 | } |
13 | 13 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * @throws ValidationException if the field is provided and is blank |
24 | 24 | */ |
25 | - final public function __construct(?string $field = null, Rule|RuleSet ...$rules) |
|
25 | + final public function __construct(?string $field = null, Rule | RuleSet ...$rules) |
|
26 | 26 | { |
27 | 27 | $this->rules = new SplObjectStorage; |
28 | 28 | $this->setField($field); |
@@ -34,17 +34,17 @@ discard block |
||
34 | 34 | return new self; |
35 | 35 | } |
36 | 36 | |
37 | - public static function forField(string $field, Rule|RuleSet ...$rules): self |
|
37 | + public static function forField(string $field, Rule | RuleSet ...$rules): self |
|
38 | 38 | { |
39 | 39 | return new self($field, ...$rules); |
40 | 40 | } |
41 | 41 | |
42 | - public static function withRules(Rule|RuleSet ...$rules): self |
|
42 | + public static function withRules(Rule | RuleSet ...$rules): self |
|
43 | 43 | { |
44 | 44 | return new self(null, ...$rules); |
45 | 45 | } |
46 | 46 | |
47 | - private function attachRules(Rule|RuleSet ...$rules): void |
|
47 | + private function attachRules(Rule | RuleSet ...$rules): void |
|
48 | 48 | { |
49 | 49 | foreach ($rules as $validationOrSet) { |
50 | 50 | if ($validationOrSet instanceof Rule) { |
@@ -59,14 +59,14 @@ discard block |
||
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
62 | - public function add(Rule|RuleSet ...$rules): self |
|
62 | + public function add(Rule | RuleSet ...$rules): self |
|
63 | 63 | { |
64 | 64 | $instance = clone $this; |
65 | 65 | $instance->attachRules(...$rules); |
66 | 66 | return $instance; |
67 | 67 | } |
68 | 68 | |
69 | - public function validate(mixed $input, array $context = []): ValidationResult|ValidationResultByField |
|
69 | + public function validate(mixed $input, array $context = []): ValidationResult | ValidationResultByField |
|
70 | 70 | { |
71 | 71 | $violations = $empty = $this->newEmptyValidationResult(); |
72 | 72 | if (null === $input && $this->allowsNull()) { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @param Rule|RuleSet ...$rules |
33 | 33 | * @return $this |
34 | 34 | */ |
35 | - public function field(string $field, Rule|RuleSet ...$rules): self |
|
35 | + public function field(string $field, Rule | RuleSet ...$rules): self |
|
36 | 36 | { |
37 | 37 | $ruleSet = $this->ruleSets[$field] ?? RuleSet::forField($field); |
38 | 38 | $this->ruleSets[$field] = $ruleSet->add(...$rules); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @return static |
118 | 118 | * @throws ReflectionException if the class does not exist |
119 | 119 | */ |
120 | - public static function fromProperties(string|object $objectOrClass, ?int $filter = null): self |
|
120 | + public static function fromProperties(string | object $objectOrClass, ?int $filter = null): self |
|
121 | 121 | { |
122 | 122 | $instance = new self; |
123 | 123 | $instance->ruleSets = RuleSetFactory::fromProperties($objectOrClass, $filter); |