1 | <?php namespace Limoncello\Flute\Validation\Form; |
||
37 | class FormValidator extends BaseValidator implements FormValidatorInterface |
||
38 | { |
||
39 | /** |
||
40 | * It is string though it can be used to access static methods of the interface. |
||
41 | * |
||
42 | * @var FormRulesSerializerInterface|string |
||
43 | */ |
||
44 | private $serializerClass; |
||
45 | |||
46 | /** |
||
47 | * @var ContextStorageInterface |
||
48 | */ |
||
49 | private $contextStorage; |
||
50 | |||
51 | /** |
||
52 | * @var FormatterInterface |
||
53 | */ |
||
54 | private $messageFormatter; |
||
55 | |||
56 | /** |
||
57 | * @var array |
||
58 | */ |
||
59 | private $blocks; |
||
60 | |||
61 | /** |
||
62 | * @var int[] |
||
63 | */ |
||
64 | private $ruleIndexes; |
||
65 | |||
66 | /** |
||
67 | * @var array |
||
68 | */ |
||
69 | private $ruleMainIndexes; |
||
70 | |||
71 | /** |
||
72 | * @param string $rulesClass |
||
73 | * @param string $serializerClass |
||
74 | * @param array $serializedData |
||
75 | * @param ContextStorageInterface $context |
||
76 | * @param FormatterInterface $messageFormatter |
||
77 | */ |
||
78 | 3 | public function __construct( |
|
96 | |||
97 | /** |
||
98 | * @inheritdoc |
||
99 | * |
||
100 | * @SuppressWarnings(PHPMD.ElseExpression) |
||
101 | */ |
||
102 | 3 | public function validate($input): bool |
|
118 | |||
119 | /** |
||
120 | * @inheritdoc |
||
121 | */ |
||
122 | 1 | public function getMessages(): iterable |
|
132 | |||
133 | /** |
||
134 | * @return BaseValidator |
||
|
|||
135 | */ |
||
136 | 3 | protected function resetAggregators(): BaseValidator |
|
144 | |||
145 | /** |
||
146 | * @return FormRulesSerializerInterface|string |
||
147 | */ |
||
148 | 3 | protected function getSerializer() |
|
152 | |||
153 | /** |
||
154 | * @param string $serializerClass |
||
155 | * |
||
156 | * @return self |
||
157 | */ |
||
158 | 3 | protected function setSerializer(string $serializerClass): self |
|
166 | |||
167 | /** |
||
168 | * @return ContextStorageInterface |
||
169 | */ |
||
170 | 2 | protected function getContext(): ContextStorageInterface |
|
174 | |||
175 | /** |
||
176 | * @param ContextStorageInterface $context |
||
177 | * |
||
178 | * @return self |
||
179 | */ |
||
180 | 3 | protected function setContext(ContextStorageInterface $context): self |
|
186 | |||
187 | /** |
||
188 | * @return FormatterInterface |
||
189 | */ |
||
190 | 1 | protected function getMessageFormatter(): FormatterInterface |
|
194 | |||
195 | /** |
||
196 | * @param FormatterInterface $messageFormatter |
||
197 | * |
||
198 | * @return self |
||
199 | */ |
||
200 | 3 | private function setMessageFormatter(FormatterInterface $messageFormatter): self |
|
206 | |||
207 | /** |
||
208 | * @param iterable $attributes |
||
209 | * |
||
210 | * @return self |
||
211 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
212 | * @SuppressWarnings(PHPMD.ElseExpression) |
||
213 | */ |
||
214 | 2 | private function validateAttributes(iterable $attributes): self |
|
232 | |||
233 | /** |
||
234 | * @param mixed $input |
||
235 | * @param int $index |
||
236 | * |
||
237 | * @return void |
||
238 | * |
||
239 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
240 | */ |
||
241 | 2 | private function executeBlock($input, int $index): void |
|
252 | |||
253 | /** |
||
254 | * @param array $indexes |
||
255 | * |
||
256 | * @return void |
||
257 | * |
||
258 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
259 | */ |
||
260 | 2 | private function executeStarts(array $indexes): void |
|
269 | |||
270 | /** |
||
271 | * @param array $indexes |
||
272 | * |
||
273 | * @return void |
||
274 | * |
||
275 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
276 | */ |
||
277 | 2 | private function executeEnds(array $indexes): void |
|
286 | |||
287 | /** |
||
288 | * @param array $ruleIndexes |
||
289 | * |
||
290 | * @return self |
||
291 | * |
||
292 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
293 | */ |
||
294 | 3 | private function setRuleIndexes(array $ruleIndexes): self |
|
303 | |||
304 | /** |
||
305 | * @return int[] |
||
306 | */ |
||
307 | 2 | private function getRuleIndexes(): array |
|
311 | |||
312 | /** |
||
313 | * @return array |
||
314 | */ |
||
315 | 3 | private function getBlocks(): array |
|
319 | |||
320 | /** |
||
321 | * @param array $blocks |
||
322 | * |
||
323 | * @return self |
||
324 | */ |
||
325 | 3 | private function setBlocks(array $blocks): self |
|
331 | |||
332 | /** |
||
333 | * @param string $name |
||
334 | * |
||
335 | * @return int|null |
||
336 | * |
||
337 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
338 | */ |
||
339 | 2 | private function getAttributeIndex(string $name): ?int |
|
345 | |||
346 | /** |
||
347 | * @param array $rules |
||
348 | * |
||
349 | * @return bool |
||
350 | * |
||
351 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
352 | */ |
||
353 | 3 | private function debugCheckIndexesExist(array $rules): bool |
|
369 | } |
||
370 |
This check looks for the generic type
array
as a return type and suggests a more specific type. This type is inferred from the actual code.