@@ -30,7 +30,6 @@ |
||
30 | 30 | public function translate(string $string): string |
31 | 31 | { |
32 | 32 | return array_key_exists($string, $this->dictionary) ? |
33 | - $this->dictionary[$string] : |
|
34 | - $string; |
|
33 | + $this->dictionary[$string] : $string; |
|
35 | 34 | } |
36 | 35 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | public function join(self $that, callable $joinValid, callable $joinErrors): self |
56 | 56 | { |
57 | - if (! $this->isValid || ! $that->isValid) { |
|
57 | + if (!$this->isValid || !$that->isValid) { |
|
58 | 58 | return self::errors($joinErrors($this->messages, $that->messages)); |
59 | 59 | } |
60 | 60 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | callable $processValid, |
84 | 84 | callable $processErrors |
85 | 85 | ) { |
86 | - if (! $this->isValid) { |
|
86 | + if (!$this->isValid) { |
|
87 | 87 | return $processErrors($this->messages); |
88 | 88 | } |
89 | 89 | |
@@ -98,10 +98,10 @@ discard block |
||
98 | 98 | { |
99 | 99 | return $this->process( |
100 | 100 | /** @param mixed $validContent */ |
101 | - function ($validContent) use ($map): self { |
|
101 | + function($validContent) use ($map): self { |
|
102 | 102 | return self::valid($map($validContent)); |
103 | 103 | }, |
104 | - function (array $messages): self { |
|
104 | + function(array $messages): self { |
|
105 | 105 | return self::errors($messages); |
106 | 106 | } |
107 | 107 | ); |
@@ -111,10 +111,10 @@ discard block |
||
111 | 111 | { |
112 | 112 | return $this->process( |
113 | 113 | /** @param mixed $validContent */ |
114 | - function ($validContent): self { |
|
114 | + function($validContent): self { |
|
115 | 115 | return self::valid($validContent); |
116 | 116 | }, |
117 | - function (array $messages) use ($map): self { |
|
117 | + function(array $messages) use ($map): self { |
|
118 | 118 | return self::errors($map($messages)); |
119 | 119 | } |
120 | 120 | ); |
@@ -127,17 +127,17 @@ discard block |
||
127 | 127 | public function apply(ValidationResult $apply): self |
128 | 128 | { |
129 | 129 | return $apply->process( |
130 | - function (callable $validApply): self { |
|
130 | + function(callable $validApply): self { |
|
131 | 131 | return $this->map($validApply); |
132 | 132 | }, |
133 | 133 | /** @return mixed */ |
134 | - function (array $applyMessages) { |
|
134 | + function(array $applyMessages) { |
|
135 | 135 | return $this->process( |
136 | 136 | /** @param mixed $validContent */ |
137 | - function ($validContent) use ($applyMessages): self { |
|
137 | + function($validContent) use ($applyMessages): self { |
|
138 | 138 | return self::errors($applyMessages); |
139 | 139 | }, |
140 | - function (array $messages) use ($applyMessages): self { |
|
140 | + function(array $messages) use ($applyMessages): self { |
|
141 | 141 | return self::errors(array_merge($applyMessages, $messages)); |
142 | 142 | } |
143 | 143 | ); |
@@ -153,10 +153,10 @@ discard block |
||
153 | 153 | { |
154 | 154 | return $this->process( |
155 | 155 | /** @param mixed $validContent */ |
156 | - function ($validContent) use ($bind): self { |
|
156 | + function($validContent) use ($bind): self { |
|
157 | 157 | return $bind($validContent); |
158 | 158 | }, |
159 | - function (array $messages): self { |
|
159 | + function(array $messages): self { |
|
160 | 160 | return self::errors($messages); |
161 | 161 | } |
162 | 162 | ); |
@@ -23,11 +23,11 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @psalm-return Closure(): ValidationResult |
25 | 25 | */ |
26 | - static function ( |
|
26 | + static function( |
|
27 | 27 | callable $f, |
28 | 28 | ?int $numberOfParameters = null, |
29 | 29 | array $parameters = [] |
30 | - ) use (&$innerLift): Closure { |
|
30 | + ) use (&$innerLift) : Closure { |
|
31 | 31 | if (null === $numberOfParameters) { |
32 | 32 | // retrieve number of parameters from reflection |
33 | 33 | $fClosure = Closure::fromCallable($f); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | /** @return ValidationResult|Closure */ |
39 | 39 | /** @psalm-suppress MissingClosureReturnType */ |
40 | - return static function () use ($f, $numberOfParameters, $parameters, $innerLift) { |
|
40 | + return static function() use ($f, $numberOfParameters, $parameters, $innerLift) { |
|
41 | 41 | // collect all necessary parameters |
42 | 42 | |
43 | 43 | /** @var array<int, mixed> $newParameters */ |
@@ -109,11 +109,11 @@ discard block |
||
109 | 109 | |
110 | 110 | public static function fromPreviousAndCallable(ValidationResult $previous, callable $f): ValidationResult |
111 | 111 | { |
112 | - return $previous->bind(function (DoPartialTempResult $doPartialTempResult) use ($f): ValidationResult { |
|
112 | + return $previous->bind(function(DoPartialTempResult $doPartialTempResult) use ($f): ValidationResult { |
|
113 | 113 | $lastArgumentResult = $doPartialTempResult(); |
114 | 114 | |
115 | 115 | /** @psalm-suppress MissingClosureParamType */ |
116 | - return $lastArgumentResult->bind(function ($lastArgument) use ($doPartialTempResult, $f): ValidationResult { |
|
116 | + return $lastArgumentResult->bind(function($lastArgument) use ($doPartialTempResult, $f): ValidationResult { |
|
117 | 117 | $fArguments = array_merge($doPartialTempResult->arguments, [$lastArgument]); |
118 | 118 | |
119 | 119 | return self::fromCallableAndArguments($f, $fArguments); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | $doPartialTempResult = DoPartialTempResult::fromPreviousAndCallable($doPartialTempResult, $f); |
143 | 143 | } |
144 | 144 | |
145 | - return $doPartialTempResult->bind(function (DoPartialTempResult $doPartialTempResult): ValidationResult { |
|
145 | + return $doPartialTempResult->bind(function(DoPartialTempResult $doPartialTempResult): ValidationResult { |
|
146 | 146 | return $doPartialTempResult(); |
147 | 147 | }); |
148 | 148 | } |
@@ -24,8 +24,7 @@ discard block |
||
24 | 24 | { |
25 | 25 | $this->elementValidation = $validation; |
26 | 26 | $this->errorFormatter = is_callable($errorFormatter) ? |
27 | - $errorFormatter : |
|
28 | - /** |
|
27 | + $errorFormatter : /** |
|
29 | 28 | * @template K |
30 | 29 | * @template V |
31 | 30 | * @psalm-param K $key |
@@ -33,7 +32,7 @@ discard block |
||
33 | 32 | * @param array $validationMessages |
34 | 33 | * @return array<K, V> |
35 | 34 | */ |
36 | - function ($key, array $resultMessages, array $validationMessages): array { |
|
35 | + function($key, array $resultMessages, array $validationMessages): array { |
|
37 | 36 | $resultMessages[$key] = $validationMessages; |
38 | 37 | |
39 | 38 | return $resultMessages; |
@@ -69,7 +68,7 @@ discard block |
||
69 | 68 | /** |
70 | 69 | * @return array |
71 | 70 | */ |
72 | - function (array $resultMessages, array $validationMessages) use ($key, $errorFormatter) { |
|
71 | + function(array $resultMessages, array $validationMessages) use ($key, $errorFormatter) { |
|
73 | 72 | return $errorFormatter($key, $resultMessages, $validationMessages); |
74 | 73 | } |
75 | 74 | ); |
@@ -79,7 +78,7 @@ discard block |
||
79 | 78 | /** |
80 | 79 | * @return T |
81 | 80 | */ |
82 | - function () use ($data) { |
|
81 | + function() use ($data) { |
|
83 | 82 | return $data; |
84 | 83 | } |
85 | 84 | ); |
@@ -24,8 +24,7 @@ discard block |
||
24 | 24 | { |
25 | 25 | $this->elementValidation = $validation; |
26 | 26 | $this->errorFormatter = is_callable($errorFormatter) ? |
27 | - $errorFormatter : |
|
28 | - /** |
|
27 | + $errorFormatter : /** |
|
29 | 28 | * @template K |
30 | 29 | * @template V |
31 | 30 | * @psalm-param K $key |
@@ -33,7 +32,7 @@ discard block |
||
33 | 32 | * @param array $validationMessages |
34 | 33 | * @return array<K, V> |
35 | 34 | */ |
36 | - function ($key, array $resultMessages, array $validationMessages): array { |
|
35 | + function($key, array $resultMessages, array $validationMessages): array { |
|
37 | 36 | $resultMessages[$key] = $validationMessages; |
38 | 37 | |
39 | 38 | return $resultMessages; |
@@ -71,10 +70,10 @@ discard block |
||
71 | 70 | * @psalm-param U $b |
72 | 71 | * @return T |
73 | 72 | */ |
74 | - function ($a, $b) { |
|
73 | + function($a, $b) { |
|
75 | 74 | return $a; |
76 | 75 | }, |
77 | - function (array $resultMessages, array $validationMessages) use ($key, $errorFormatter): array { |
|
76 | + function(array $resultMessages, array $validationMessages) use ($key, $errorFormatter): array { |
|
78 | 77 | return $errorFormatter($key, $resultMessages, $validationMessages); |
79 | 78 | } |
80 | 79 | ); |
@@ -48,7 +48,7 @@ |
||
48 | 48 | * @psalm-param T $message |
49 | 49 | * @return T |
50 | 50 | */ |
51 | - function ($message) use ($translator) { |
|
51 | + function($message) use ($translator) { |
|
52 | 52 | if (is_string($message)) { |
53 | 53 | return $translator->translate($message); |
54 | 54 | } |
@@ -42,13 +42,13 @@ |
||
42 | 42 | { |
43 | 43 | return array_reduce( |
44 | 44 | $this->validations, |
45 | - function (ValidationResult $carry, Validation $validation) use ($context): ValidationResult { |
|
45 | + function(ValidationResult $carry, Validation $validation) use ($context): ValidationResult { |
|
46 | 46 | return $carry->process( |
47 | 47 | /** @psalm-suppress MissingClosureParamType */ |
48 | - function ($validData) use ($validation, $context): ValidationResult { |
|
48 | + function($validData) use ($validation, $context): ValidationResult { |
|
49 | 49 | return $validation->validate($validData, $context); |
50 | 50 | }, |
51 | - function () use ($carry): ValidationResult { |
|
51 | + function() use ($carry): ValidationResult { |
|
52 | 52 | return $carry; |
53 | 53 | } |
54 | 54 | ); |
@@ -54,7 +54,7 @@ |
||
54 | 54 | /** |
55 | 55 | * @return T |
56 | 56 | */ |
57 | - function () use ($data) { |
|
57 | + function() use ($data) { |
|
58 | 58 | return $data; |
59 | 59 | } |
60 | 60 | ); |
@@ -34,13 +34,12 @@ discard block |
||
34 | 34 | |
35 | 35 | $this->validations = $validations; |
36 | 36 | $this->errorFormatter = is_callable($errorFormatter) ? |
37 | - $errorFormatter : |
|
38 | - /** |
|
37 | + $errorFormatter : /** |
|
39 | 38 | * @return array[] |
40 | 39 | * |
41 | 40 | * @psalm-return array<string, array> |
42 | 41 | */ |
43 | - function (array $messages): array { |
|
42 | + function(array $messages): array { |
|
44 | 43 | return [ |
45 | 44 | self::NOT_EVEN_ONE => $messages |
46 | 45 | ]; |
@@ -75,7 +74,7 @@ discard block |
||
75 | 74 | * |
76 | 75 | * @psalm-return array<string, array> |
77 | 76 | */ |
78 | - function (array $messages) use ($translator): array { |
|
77 | + function(array $messages) use ($translator): array { |
|
79 | 78 | return [ |
80 | 79 | $translator->translate(self::NOT_EVEN_ONE) => $messages |
81 | 80 | ]; |
@@ -104,7 +103,7 @@ discard block |
||
104 | 103 | /** |
105 | 104 | * @return T |
106 | 105 | */ |
107 | - function () use ($data) { |
|
106 | + function() use ($data) { |
|
108 | 107 | return $data; |
109 | 108 | } |
110 | 109 | ); |