1 | <?php declare (strict_types = 1); |
||
46 | class FormValidator extends BaseValidator implements FormValidatorInterface |
||
47 | { |
||
48 | use ClassIsTrait; |
||
49 | |||
50 | /** |
||
51 | * It is string though it can be used to access static methods of the interface. |
||
52 | * |
||
53 | * @var FormRulesSerializerInterface|string |
||
54 | */ |
||
55 | private $serializerClass; |
||
56 | |||
57 | /** |
||
58 | * @var ContextStorageInterface |
||
59 | */ |
||
60 | private $contextStorage; |
||
61 | |||
62 | /** |
||
63 | * @var FormatterInterface |
||
64 | */ |
||
65 | private $messageFormatter; |
||
66 | |||
67 | /** |
||
68 | * @var array |
||
69 | */ |
||
70 | private $blocks; |
||
71 | |||
72 | /** |
||
73 | * @var int[] |
||
74 | */ |
||
75 | private $ruleIndexes; |
||
76 | |||
77 | /** |
||
78 | * @var array |
||
79 | */ |
||
80 | private $ruleMainIndexes; |
||
81 | 4 | ||
82 | /** |
||
83 | * @param string $rulesClass |
||
84 | * @param string $serializerClass |
||
85 | * @param array $serializedData |
||
86 | * @param ContextStorageInterface $context |
||
87 | * @param FormatterInterface $messageFormatter |
||
88 | */ |
||
89 | 4 | public function __construct( |
|
107 | 4 | ||
108 | 1 | /** |
|
109 | * @inheritdoc |
||
110 | * |
||
111 | 3 | * @SuppressWarnings(PHPMD.ElseExpression) |
|
112 | 2 | */ |
|
113 | public function validate($input): bool |
||
129 | |||
130 | 2 | /** |
|
131 | * @inheritdoc |
||
132 | 2 | */ |
|
133 | public function getMessages(): iterable |
||
143 | 4 | ||
144 | /** |
||
145 | 4 | * @return BaseValidator |
|
|
|||
146 | */ |
||
147 | protected function resetAggregators(): BaseValidator |
||
155 | |||
156 | /** |
||
157 | * @return FormRulesSerializerInterface|string |
||
158 | */ |
||
159 | protected function getSerializer() |
||
163 | 4 | ||
164 | /** |
||
165 | 4 | * @param string $serializerClass |
|
166 | * |
||
167 | 4 | * @return self |
|
168 | */ |
||
169 | protected function setSerializer(string $serializerClass): self |
||
177 | |||
178 | /** |
||
179 | * @return ContextStorageInterface |
||
180 | */ |
||
181 | protected function getContext(): ContextStorageInterface |
||
185 | 4 | ||
186 | /** |
||
187 | 4 | * @param ContextStorageInterface $context |
|
188 | * |
||
189 | * @return self |
||
190 | */ |
||
191 | protected function setContext(ContextStorageInterface $context): self |
||
197 | |||
198 | /** |
||
199 | * @return FormatterInterface |
||
200 | */ |
||
201 | protected function getMessageFormatter(): FormatterInterface |
||
205 | 4 | ||
206 | /** |
||
207 | 4 | * @param FormatterInterface $messageFormatter |
|
208 | * |
||
209 | * @return self |
||
210 | */ |
||
211 | private function setMessageFormatter(FormatterInterface $messageFormatter): self |
||
217 | 3 | ||
218 | /** |
||
219 | * @param iterable $attributes |
||
220 | 3 | * |
|
221 | * @return self |
||
222 | 3 | * @SuppressWarnings(PHPMD.StaticAccess) |
|
223 | 3 | * @SuppressWarnings(PHPMD.ElseExpression) |
|
224 | 3 | */ |
|
225 | private function validateAttributes(iterable $attributes): self |
||
245 | |||
246 | 3 | /** |
|
247 | * @param mixed $input |
||
248 | 3 | * @param int $index |
|
249 | 3 | * |
|
250 | 3 | * @return void |
|
251 | 3 | * |
|
252 | 3 | * @SuppressWarnings(PHPMD.StaticAccess) |
|
253 | 3 | */ |
|
254 | 3 | private function executeBlock($input, int $index): void |
|
265 | 3 | ||
266 | /** |
||
267 | 3 | * @param array $indexes |
|
268 | 3 | * |
|
269 | 3 | * @return void |
|
270 | 3 | * |
|
271 | 3 | * @SuppressWarnings(PHPMD.StaticAccess) |
|
272 | */ |
||
273 | private function executeStarts(array $indexes): void |
||
282 | 3 | ||
283 | /** |
||
284 | 3 | * @param array $indexes |
|
285 | 3 | * |
|
286 | 3 | * @return void |
|
287 | 3 | * |
|
288 | 3 | * @SuppressWarnings(PHPMD.StaticAccess) |
|
289 | */ |
||
290 | private function executeEnds(array $indexes): void |
||
299 | 4 | ||
300 | /** |
||
301 | 4 | * @param array $ruleIndexes |
|
302 | * |
||
303 | 4 | * @return self |
|
304 | 4 | * |
|
305 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
306 | 4 | */ |
|
307 | private function setRuleIndexes(array $ruleIndexes): self |
||
316 | |||
317 | /** |
||
318 | * @return int[] |
||
319 | */ |
||
320 | 4 | private function getRuleIndexes(): array |
|
324 | |||
325 | /** |
||
326 | * @return array |
||
327 | */ |
||
328 | private function getBlocks(): array |
||
332 | 4 | ||
333 | /** |
||
334 | 4 | * @param array $blocks |
|
335 | * |
||
336 | * @return self |
||
337 | */ |
||
338 | private function setBlocks(array $blocks): self |
||
344 | 3 | ||
345 | /** |
||
346 | 3 | * @param string $name |
|
347 | * |
||
348 | 3 | * @return int|null |
|
349 | * |
||
350 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
351 | */ |
||
352 | private function getAttributeIndex(string $name): ?int |
||
358 | 4 | ||
359 | /** |
||
360 | 4 | * @param array $rules |
|
361 | * |
||
362 | 4 | * @return bool |
|
363 | 4 | * |
|
364 | 4 | * @SuppressWarnings(PHPMD.StaticAccess) |
|
365 | 4 | */ |
|
366 | private function debugCheckIndexesExist(array $rules): bool |
||
382 | } |
||
383 |
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.