1 | <?php |
||
20 | final class StaticValidator |
||
21 | { |
||
22 | |||
23 | /** |
||
24 | * @var array List of available validators |
||
25 | */ |
||
26 | public static $validators = [ |
||
27 | 'notEmpty' => 'Slick\Validator\NotEmpty', |
||
28 | 'email' => 'Slick\Validator\Email', |
||
29 | 'alphaNumeric' => 'Slick\Validator\AlphaNumeric', |
||
30 | 'number' => 'Slick\Validator\Number', |
||
31 | 'url' => 'Slick\Validator\Url' |
||
32 | ]; |
||
33 | |||
34 | /** |
||
35 | * @var array The error messages from last validation |
||
36 | */ |
||
37 | protected static $messages = []; |
||
38 | |||
39 | /** |
||
40 | * @var string |
||
41 | */ |
||
42 | protected static $message = ''; |
||
43 | |||
44 | /** |
||
45 | * Returns true if and only if $value meets the validation requirements |
||
46 | * |
||
47 | * @param string $validator The validator name |
||
48 | * @param mixed $value |
||
49 | * |
||
50 | * @throws Exception\UnknownValidatorClassException |
||
51 | * @return bool |
||
52 | * |
||
53 | * @deprecated Should use the validates instead |
||
54 | * |
||
55 | * @see Slick\Validator\StaticValidator::$validators |
||
56 | */ |
||
57 | public static function isValid($validator, $value) |
||
65 | |||
66 | /** |
||
67 | * Returns true if and only if $value meets the validation requirements |
||
68 | * |
||
69 | * The context specified can be used in the validation process so that |
||
70 | * the same value can be valid or invalid depending on that data. |
||
71 | * |
||
72 | * @param string $validator |
||
73 | * @param mixed $value |
||
74 | * @param array|mixed $context |
||
75 | * |
||
76 | * @return bool |
||
77 | */ |
||
78 | 2 | public static function validates($validator, $value, $context = []) |
|
86 | |||
87 | /** |
||
88 | * Creates a validator object |
||
89 | * |
||
90 | * @param string $validator The validator class name or alias |
||
91 | * |
||
92 | * @param null $message |
||
93 | * @throws Exception\UnknownValidatorClassException |
||
94 | * |
||
95 | * @return ValidatorInterface |
||
96 | * |
||
97 | */ |
||
98 | 22 | public static function create($validator, $message = null) |
|
109 | |||
110 | /** |
||
111 | * Returns an array of messages that explain why the most recent |
||
112 | * isValid() call returned false. The array keys are validation failure |
||
113 | * message identifiers, and the array values are the corresponding |
||
114 | * human-readable message strings. |
||
115 | * |
||
116 | * @deprecated You should use instead the StaticValidator::getMessage() |
||
117 | * |
||
118 | * @return array |
||
119 | */ |
||
120 | public static function geMessages() |
||
124 | |||
125 | /** |
||
126 | * Returns the message that explain why the most recent |
||
127 | * validates() call returned false. |
||
128 | * |
||
129 | * @return array |
||
130 | */ |
||
131 | 2 | public static function geMessage() |
|
135 | |||
136 | /** |
||
137 | * Check if the provided validator is a known alias or a valid validator |
||
138 | * interface class |
||
139 | * |
||
140 | * @param string $validator Alias or FQ class name of the validator |
||
141 | * |
||
142 | * @return string |
||
143 | */ |
||
144 | 22 | private static function checkValidator($validator) |
|
151 | |||
152 | /** |
||
153 | * Check if is a valid validator class |
||
154 | * |
||
155 | * @param string $validator FQ class name of validator |
||
156 | * |
||
157 | * @return string |
||
158 | */ |
||
159 | 6 | private static function checkClass($validator) |
|
176 | |||
177 | } |
||
178 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: