1 | <?php |
||
9 | class ValidatorResult |
||
10 | { |
||
11 | /** |
||
12 | * List of errors from validation |
||
13 | * |
||
14 | * @var string[][] |
||
15 | */ |
||
16 | private $errors = []; |
||
17 | |||
18 | /** |
||
19 | * @var array |
||
20 | */ |
||
21 | private $values = []; |
||
22 | |||
23 | /** |
||
24 | * @var HtmlDomParser |
||
25 | */ |
||
26 | private $formDocument; |
||
27 | |||
28 | /** |
||
29 | * ValidatorResult constructor. |
||
30 | * |
||
31 | * @param HtmlDomParser $formDocument |
||
32 | */ |
||
33 | 24 | public function __construct($formDocument) |
|
37 | |||
38 | /** |
||
39 | * @return int |
||
40 | */ |
||
41 | 9 | public function countErrors(): int |
|
45 | |||
46 | /** |
||
47 | * @return array |
||
48 | */ |
||
49 | 17 | public function getErrorMessages(): array |
|
53 | |||
54 | /** |
||
55 | * @return string |
||
56 | */ |
||
57 | 3 | public function getHtml(): string |
|
61 | |||
62 | /** |
||
63 | * @return array |
||
64 | */ |
||
65 | 2 | public function getValues(): array |
|
69 | |||
70 | /** |
||
71 | * @return bool |
||
72 | */ |
||
73 | 9 | public function isSuccess(): bool |
|
77 | |||
78 | /** |
||
79 | * @param string $field |
||
80 | * @param string $fieldRule |
||
81 | * @param string|string[] $errorMsg |
||
82 | * @param mixed $currentFieldValue |
||
83 | * |
||
84 | * @return self |
||
85 | */ |
||
86 | 17 | public function setError(string $field, string $fieldRule, $errorMsg, $currentFieldValue): self |
|
120 | |||
121 | /** |
||
122 | * @param string $field |
||
123 | * @param mixed $value |
||
124 | * |
||
125 | * @return self |
||
126 | */ |
||
127 | 19 | public function setValue(string $field, $value): self |
|
140 | |||
141 | /** |
||
142 | * Write the error messages into the dom, if needed. |
||
143 | * |
||
144 | * @return self |
||
145 | */ |
||
146 | 23 | public function writeErrorsIntoTheDom(): self |
|
165 | |||
166 | /** |
||
167 | * @param string $field |
||
168 | * @param mixed $value |
||
169 | * |
||
170 | * @return self |
||
171 | */ |
||
172 | 23 | public function saveValue(string $field, $value): self |
|
178 | } |
||
179 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: