1 | <?php |
||
10 | class ValidatorResult |
||
11 | { |
||
12 | /** |
||
13 | * List of errors from validation |
||
14 | * |
||
15 | * @var string[] |
||
16 | */ |
||
17 | private $errors = []; |
||
18 | |||
19 | /** |
||
20 | * @var array |
||
21 | */ |
||
22 | private $values = []; |
||
23 | |||
24 | /** |
||
25 | * @var HtmlDomParser |
||
26 | */ |
||
27 | private $formDocument; |
||
28 | |||
29 | /** |
||
30 | * ValidatorResult constructor. |
||
31 | * |
||
32 | * @param HtmlDomParser $formDocument |
||
33 | */ |
||
34 | 19 | public function __construct($formDocument) |
|
38 | |||
39 | /** |
||
40 | * @return int |
||
41 | */ |
||
42 | 7 | public function countErrors(): int |
|
46 | |||
47 | /** |
||
48 | * @return array |
||
49 | */ |
||
50 | 13 | public function getErrorMessages(): array |
|
54 | |||
55 | /** |
||
56 | * @return string |
||
57 | */ |
||
58 | 2 | public function getHtml(): string |
|
62 | |||
63 | /** |
||
64 | * @return array |
||
65 | */ |
||
66 | 2 | public function getValues(): array |
|
70 | |||
71 | /** |
||
72 | * @return bool |
||
73 | */ |
||
74 | 7 | public function isSuccess(): bool |
|
78 | |||
79 | /** |
||
80 | * @param string $field |
||
81 | * @param string|string[] $errorMsg |
||
82 | * |
||
83 | * @return ValidatorResult |
||
84 | */ |
||
85 | 12 | public function setError(string $field, $errorMsg): ValidatorResult |
|
108 | |||
109 | 18 | public function setValues(string $field, $value): ValidatorResult |
|
115 | } |
||
116 |
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: