1 | <?php namespace Limoncello\Application\FormValidation; |
||
39 | class Validator extends BaseValidator implements FormValidatorInterface |
||
40 | { |
||
41 | use HasContainerTrait; |
||
42 | |||
43 | /** |
||
44 | * Namespace for string resources. |
||
45 | */ |
||
46 | const RESOURCES_NAMESPACE = 'Limoncello.Application.Validation'; |
||
47 | |||
48 | /** Rule description index */ |
||
49 | const RULE_INDEX = 0; |
||
50 | |||
51 | /** Rule description index */ |
||
52 | const RULE_ATTRIBUTES = self::RULE_INDEX + 1; |
||
53 | |||
54 | /** Rule description index */ |
||
55 | const RULE_TO_ONE = self::RULE_ATTRIBUTES + 1; |
||
56 | |||
57 | /** Rule description index */ |
||
58 | const RULE_TO_MANY = self::RULE_TO_ONE + 1; |
||
59 | |||
60 | /** Rule description index */ |
||
61 | const RULE_UNLISTED_ATTRIBUTE = self::RULE_TO_MANY + 1; |
||
62 | |||
63 | /** Rule description index */ |
||
64 | const RULE_UNLISTED_RELATIONSHIP = self::RULE_UNLISTED_ATTRIBUTE + 1; |
||
65 | |||
66 | /** |
||
67 | * @var ContextStorageInterface |
||
68 | */ |
||
69 | private $contextStorage; |
||
70 | |||
71 | /** |
||
72 | * @var FormatterInterface |
||
73 | */ |
||
74 | private $messageFormatter; |
||
75 | |||
76 | /** |
||
77 | * @var array |
||
78 | */ |
||
79 | private $blocks; |
||
80 | |||
81 | /** |
||
82 | * @var int[] |
||
83 | */ |
||
84 | private $attributeRules; |
||
85 | |||
86 | /** |
||
87 | * @param string $name |
||
88 | * @param array $data |
||
89 | * @param ContainerInterface $container |
||
90 | * @param FormatterInterface $messageFormatter |
||
91 | * |
||
92 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
93 | */ |
||
94 | 2 | public function __construct( |
|
108 | |||
109 | /** |
||
110 | * @inheritdoc |
||
111 | * |
||
112 | * @SuppressWarnings(PHPMD.ElseExpression) |
||
113 | */ |
||
114 | 2 | public function validate($input): bool |
|
130 | |||
131 | /** |
||
132 | * @inheritdoc |
||
133 | */ |
||
134 | 1 | public function getMessages(): iterable |
|
144 | |||
145 | /** |
||
146 | * @return BaseValidator |
||
|
|||
147 | */ |
||
148 | 2 | protected function resetAggregators(): BaseValidator |
|
156 | |||
157 | /** |
||
158 | * @return ContextStorageInterface |
||
159 | */ |
||
160 | 1 | protected function getContextStorage(): ContextStorageInterface |
|
164 | |||
165 | /** |
||
166 | * @return FormatterInterface |
||
167 | */ |
||
168 | 1 | protected function getMessageFormatter(): FormatterInterface |
|
172 | |||
173 | /** |
||
174 | * @param FormatterInterface $messageFormatter |
||
175 | * |
||
176 | * @return self |
||
177 | */ |
||
178 | 2 | private function setMessageFormatter(FormatterInterface $messageFormatter): self |
|
184 | |||
185 | /** |
||
186 | * @return ContextStorageInterface |
||
187 | */ |
||
188 | 2 | protected function createContextStorage(): ContextStorageInterface |
|
192 | |||
193 | /** |
||
194 | * @param array $attributes |
||
195 | * |
||
196 | * @return self |
||
197 | * @SuppressWarnings(PHPMD.ElseExpression) |
||
198 | */ |
||
199 | 1 | private function validateAttributes(array $attributes): self |
|
217 | |||
218 | /** |
||
219 | * @param mixed $input |
||
220 | * @param int $index |
||
221 | * |
||
222 | * @return void |
||
223 | * |
||
224 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
225 | */ |
||
226 | 1 | private function executeBlock($input, int $index): void |
|
237 | |||
238 | /** |
||
239 | * @param array $indexes |
||
240 | * |
||
241 | * @return void |
||
242 | * |
||
243 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
244 | */ |
||
245 | 1 | private function executeStarts(array $indexes): void |
|
254 | |||
255 | /** |
||
256 | * @param array $indexes |
||
257 | * |
||
258 | * @return void |
||
259 | * |
||
260 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
261 | */ |
||
262 | 1 | private function executeEnds(array $indexes): void |
|
271 | |||
272 | /** |
||
273 | * @param array $rules |
||
274 | * |
||
275 | * @return self |
||
276 | */ |
||
277 | 2 | private function setAttributeRules(array $rules): self |
|
285 | |||
286 | /** |
||
287 | * @return int[] |
||
288 | */ |
||
289 | 1 | private function getAttributeRules(): array |
|
293 | |||
294 | /** |
||
295 | * @return array |
||
296 | */ |
||
297 | 2 | private function getBlocks(): array |
|
301 | |||
302 | /** |
||
303 | * @param array $blocks |
||
304 | * |
||
305 | * @return self |
||
306 | */ |
||
307 | 2 | private function setBlocks(array $blocks): self |
|
313 | |||
314 | /** |
||
315 | * @param string $name |
||
316 | * |
||
317 | * @return int|null |
||
318 | * |
||
319 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
320 | */ |
||
321 | 1 | private function getAttributeIndex(string $name): ?int |
|
328 | |||
329 | /** |
||
330 | * @param array $rules |
||
331 | * |
||
332 | * @return bool |
||
333 | * |
||
334 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
335 | */ |
||
336 | 2 | private function debugCheckIndexesExist(array $rules): bool |
|
352 | } |
||
353 |
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.