@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @return ValidationSet[] |
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 ValidationSet[] |
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 ValidationSet |
49 | 49 | * @throws ReflectionException if the class or property does not exist. |
50 | 50 | */ |
51 | - public static function fromProperty(string|object $objectOrClass, string $property): ValidationSet |
|
51 | + public static function fromProperty(string | object $objectOrClass, string $property): ValidationSet |
|
52 | 52 | { |
53 | 53 | return self::fromReflectionProperty(new ReflectionProperty($objectOrClass, $property)); |
54 | 54 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @return ValidationSet |
60 | 60 | * @throws ReflectionException |
61 | 61 | */ |
62 | - public static function fromMethod(string|object $objectOrClass, string $method): ValidationSet |
|
62 | + public static function fromMethod(string | object $objectOrClass, string $method): ValidationSet |
|
63 | 63 | { |
64 | 64 | return self::fromReflectionMethod(new ReflectionMethod($objectOrClass, $method)); |
65 | 65 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | return true; |
38 | 38 | } |
39 | 39 | |
40 | - public function indexOf(mixed $element): bool|int|string |
|
40 | + public function indexOf(mixed $element): bool | int | string |
|
41 | 41 | { |
42 | 42 | return array_search($element, $this->elements, true); |
43 | 43 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | return $this; |
81 | 81 | } |
82 | 82 | |
83 | - public function forEach(callable $callback, bool $stopable = false): static |
|
83 | + public function forEach (callable $callback, bool $stopable = false): static |
|
84 | 84 | { |
85 | 85 | foreach ($this->elements as $index => $element) { |
86 | 86 | $result = call_user_func_array($callback, [$element, $index]); |
@@ -14,13 +14,13 @@ discard block |
||
14 | 14 | } |
15 | 15 | } |
16 | 16 | |
17 | - public function set(string|int $index, $value): self |
|
17 | + public function set(string | int $index, $value): self |
|
18 | 18 | { |
19 | 19 | $this->insert($value, $index); |
20 | 20 | return $this; |
21 | 21 | } |
22 | 22 | |
23 | - public function get(string|int $index, $default = null): mixed |
|
23 | + public function get(string | int $index, $default = null): mixed |
|
24 | 24 | { |
25 | 25 | return $this->elements[$index] ?? $default; |
26 | 26 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | return array_key_exists($index, $this->elements); |
31 | 31 | } |
32 | 32 | |
33 | - public function delete(string|int $index): bool |
|
33 | + public function delete(string | int $index): bool |
|
34 | 34 | { |
35 | 35 | return $this->deleteByIndex($index); |
36 | 36 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | return $this->ruleSets[$field] ?? null; |
22 | 22 | } |
23 | 23 | |
24 | - public function ruleSet(string $field, Validation|ValidationSet ...$rules): self |
|
24 | + public function ruleSet(string $field, Validation | ValidationSet ...$rules): self |
|
25 | 25 | { |
26 | 26 | $ruleSet = $this->ruleSets[$field] ?? ValidationSet::forField($field); |
27 | 27 | $this->ruleSets[$field] = $ruleSet->add(...$rules); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @return static |
107 | 107 | * @throws ReflectionException if the class does not exist |
108 | 108 | */ |
109 | - public static function fromProperties(string|object $objectOrClass, ?int $filter = null): self |
|
109 | + public static function fromProperties(string | object $objectOrClass, ?int $filter = null): self |
|
110 | 110 | { |
111 | 111 | $instance = new self; |
112 | 112 | $instance->ruleSets = ValidationSetFactory::fromProperties($objectOrClass, $filter); |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | |
18 | 18 | private SplObjectStorage $rules; |
19 | 19 | |
20 | - final public function __construct(?string $field = null, Validation|ValidationSet ...$rules) |
|
20 | + final public function __construct(?string $field = null, Validation | ValidationSet ...$rules) |
|
21 | 21 | { |
22 | 22 | $this->rules = new SplObjectStorage; |
23 | 23 | $this->withField($field); |
@@ -29,24 +29,24 @@ discard block |
||
29 | 29 | return new self; |
30 | 30 | } |
31 | 31 | |
32 | - public static function forField(string $field, Validation|ValidationSet ...$rules): self |
|
32 | + public static function forField(string $field, Validation | ValidationSet ...$rules): self |
|
33 | 33 | { |
34 | 34 | return new self($field, ...$rules); |
35 | 35 | } |
36 | 36 | |
37 | - public static function withRules(Validation|ValidationSet ...$rules): self |
|
37 | + public static function withRules(Validation | ValidationSet ...$rules): self |
|
38 | 38 | { |
39 | 39 | return new self(null, ...$rules); |
40 | 40 | } |
41 | 41 | |
42 | - public function add(Validation|ValidationSet ...$rules): self |
|
42 | + public function add(Validation | ValidationSet ...$rules): self |
|
43 | 43 | { |
44 | 44 | $instance = clone $this; |
45 | 45 | $instance->attachRules(...$rules); |
46 | 46 | return $instance; |
47 | 47 | } |
48 | 48 | |
49 | - private function attachRules(Validation|ValidationSet ...$rules): void |
|
49 | + private function attachRules(Validation | ValidationSet ...$rules): void |
|
50 | 50 | { |
51 | 51 | foreach ($rules as $validationOrSet) { |
52 | 52 | if ($validationOrSet instanceof Validation) { |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
64 | - public function validate(mixed $input, array $context = []): ValidationResult|ValidationResultByField |
|
64 | + public function validate(mixed $input, array $context = []): ValidationResult | ValidationResultByField |
|
65 | 65 | { |
66 | 66 | $violations = $empty = $this->newEmptyValidationResult(); |
67 | 67 | if (null === $input && $this->allowsNull()) { |