@@ -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 Validation) { |
|
10 | + if (!$this instanceof Validation) { |
|
11 | 11 | return; |
12 | 12 | } |
13 | 13 |
@@ -23,7 +23,7 @@ |
||
23 | 23 | public function validate($input, array $context = []): Result |
24 | 24 | { |
25 | 25 | $result = $this->newEmptyValidationResult(); |
26 | - return $this->isValid($input, $context) ? $result: $result->error($this->message); |
|
26 | + return $this->isValid($input, $context) ? $result : $result->error($this->message); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | abstract protected function isValid($input, array $context = []): bool; |
@@ -23,7 +23,7 @@ |
||
23 | 23 | return $this->field !== null; |
24 | 24 | } |
25 | 25 | |
26 | - private function newEmptyValidationResult(): ValidationResult|ValidationResultByField |
|
26 | + private function newEmptyValidationResult(): ValidationResult | ValidationResultByField |
|
27 | 27 | { |
28 | 28 | return $this->belongsToField() ? new ValidationResultByField($this->getField()) : new ValidationResult; |
29 | 29 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | return $this->ruleSets[] = (new ValidationSet)->setField($field); |
27 | 27 | } |
28 | 28 | |
29 | - public function field(string $field, Validation|ValidationSet ...$rules): self |
|
29 | + public function field(string $field, Validation | ValidationSet ...$rules): self |
|
30 | 30 | { |
31 | 31 | $ruleset = $this->ruleSet($field); |
32 | 32 | foreach ($rules as $rule) { |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @return static |
81 | 81 | * @throws ReflectionException if the class does not exist |
82 | 82 | */ |
83 | - public static function fromProperties(string|object $objectOrClass, ?int $filter = null): self |
|
83 | + public static function fromProperties(string | object $objectOrClass, ?int $filter = null): self |
|
84 | 84 | { |
85 | 85 | $instance = new self; |
86 | 86 | $instance->ruleSets = ValidationSet::fromProperties($objectOrClass, $filter); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | return $this; |
32 | 32 | } |
33 | 33 | |
34 | - public function validate($input, array $context = []): ValidationResult|ValidationResultByField |
|
34 | + public function validate($input, array $context = []): ValidationResult | ValidationResultByField |
|
35 | 35 | { |
36 | 36 | $violations = $this->newEmptyValidationResult(); |
37 | 37 | foreach ($this->rules as $constraint) { |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @return array |
73 | 73 | * @throws ReflectionException if the class does not exist |
74 | 74 | */ |
75 | - public static function fromProperties(string|object $objectOrClass, ?int $filter = null): array |
|
75 | + public static function fromProperties(string | object $objectOrClass, ?int $filter = null): array |
|
76 | 76 | { |
77 | 77 | $ruleSets = []; |
78 | 78 | foreach ((new ReflectionClass($objectOrClass))->getProperties($filter) as $property) { |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @return static |
89 | 89 | * @throws ReflectionException if the class or property does not exist. |
90 | 90 | */ |
91 | - public static function fromProperty(string|object $objectOrClass, string $property): self |
|
91 | + public static function fromProperty(string | object $objectOrClass, string $property): self |
|
92 | 92 | { |
93 | 93 | return self::fromReflectionProperty(new ReflectionProperty($objectOrClass, $property)); |
94 | 94 | } |
@@ -8,10 +8,10 @@ discard block |
||
8 | 8 | |
9 | 9 | class ValidationException extends Exception |
10 | 10 | { |
11 | - private ValidationResultSet|ValidationResult $violations; |
|
11 | + private ValidationResultSet | ValidationResult $violations; |
|
12 | 12 | |
13 | 13 | public function __construct( |
14 | - ValidationResultSet|ValidationResult $violations, |
|
14 | + ValidationResultSet | ValidationResult $violations, |
|
15 | 15 | ?string $message = null, |
16 | 16 | $code = 422, |
17 | 17 | Throwable $previous = null |
@@ -27,8 +27,7 @@ discard block |
||
27 | 27 | { |
28 | 28 | return |
29 | 29 | $this->violations instanceof ValidationResultSet ? |
30 | - $this->violations->validationResults() : |
|
31 | - [$this->violations]; |
|
30 | + $this->violations->validationResults() : [$this->violations]; |
|
32 | 31 | } |
33 | 32 | |
34 | 33 | private function formatMessage(): string |
@@ -41,6 +40,6 @@ discard block |
||
41 | 40 | } |
42 | 41 | } |
43 | 42 | |
44 | - return "Validation errors:" . PHP_EOL . implode(PHP_EOL, $messages); |
|
43 | + return "Validation errors:".PHP_EOL.implode(PHP_EOL, $messages); |
|
45 | 44 | } |
46 | 45 | } |