@@ -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 = ValidationSet::fromProperties($objectOrClass, $filter); |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | private SplObjectStorage $rules; |
| 24 | 24 | |
| 25 | - final public function __construct(?string $field = null, Validation|ValidationSet ...$rules) |
|
| 25 | + final public function __construct(?string $field = null, Validation | ValidationSet ...$rules) |
|
| 26 | 26 | { |
| 27 | 27 | $this->rules = new SplObjectStorage; |
| 28 | 28 | $this->withField($field); |
@@ -34,24 +34,24 @@ discard block |
||
| 34 | 34 | return new self; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public static function forField(string $field, Validation|ValidationSet ...$rules): self |
|
| 37 | + public static function forField(string $field, Validation | ValidationSet ...$rules): self |
|
| 38 | 38 | { |
| 39 | 39 | return new self($field, ...$rules); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - public static function withRules(Validation|ValidationSet ...$rules): self |
|
| 42 | + public static function withRules(Validation | ValidationSet ...$rules): self |
|
| 43 | 43 | { |
| 44 | 44 | return new self(null, ...$rules); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - public function add(Validation|ValidationSet ...$rules): self |
|
| 47 | + public function add(Validation | ValidationSet ...$rules): self |
|
| 48 | 48 | { |
| 49 | 49 | $instance = clone $this; |
| 50 | 50 | $instance->attachRules(...$rules); |
| 51 | 51 | return $instance; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - private function attachRules(Validation|ValidationSet ...$rules): void |
|
| 54 | + private function attachRules(Validation | ValidationSet ...$rules): void |
|
| 55 | 55 | { |
| 56 | 56 | foreach ($rules as $validationOrSet) { |
| 57 | 57 | if ($validationOrSet instanceof Validation) { |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | } |
| 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()) { |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * @return ValidationSet[] |
| 156 | 156 | * @throws ReflectionException if the class does not exist |
| 157 | 157 | */ |
| 158 | - public static function fromProperties(string|object $objectOrClass, ?int $filter = null): array |
|
| 158 | + public static function fromProperties(string | object $objectOrClass, ?int $filter = null): array |
|
| 159 | 159 | { |
| 160 | 160 | $ruleSets = []; |
| 161 | 161 | foreach ((new ReflectionClass($objectOrClass))->getProperties($filter) as $property) { |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | * @return ValidationSet[] |
| 172 | 172 | * @throws ReflectionException |
| 173 | 173 | */ |
| 174 | - public static function fromMethods(string|object $objectOrClass, ?int $filter = null): array |
|
| 174 | + public static function fromMethods(string | object $objectOrClass, ?int $filter = null): array |
|
| 175 | 175 | { |
| 176 | 176 | $ruleSets = []; |
| 177 | 177 | foreach ((new ReflectionClass($objectOrClass))->getMethods($filter) as $method) { |
@@ -187,12 +187,12 @@ discard block |
||
| 187 | 187 | * @return static |
| 188 | 188 | * @throws ReflectionException if the class or property does not exist. |
| 189 | 189 | */ |
| 190 | - public static function fromProperty(string|object $objectOrClass, string $property): self |
|
| 190 | + public static function fromProperty(string | object $objectOrClass, string $property): self |
|
| 191 | 191 | { |
| 192 | 192 | return self::fromReflectionProperty(new ReflectionProperty($objectOrClass, $property)); |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - public static function fromMethod(string|object $objectOrClass, string $method): self |
|
| 195 | + public static function fromMethod(string | object $objectOrClass, string $method): self |
|
| 196 | 196 | { |
| 197 | 197 | return self::fromReflectionMethod(new ReflectionMethod($objectOrClass, $method)); |
| 198 | 198 | } |