1 | <?php /** MicroValidator */ |
||
21 | class Validator |
||
22 | { |
||
23 | /** @var array $validators supported validations */ |
||
24 | protected static $validators = [ |
||
25 | 'required' => 'RequiredValidator', |
||
26 | 'captcha' => 'CaptchaValidator', |
||
27 | 'boolean' => 'BooleanValidator', |
||
28 | 'compare' => 'CompareValidator', |
||
29 | 'string' => 'StringValidator', |
||
30 | 'regexp' => 'RegexpValidator', |
||
31 | 'number' => 'NumberValidator', |
||
32 | 'unique' => 'UniqueValidator', |
||
33 | 'range' => 'RangeValidator', |
||
34 | 'email' => 'EmailValidator', |
||
35 | 'url' => 'UrlValidator', |
||
36 | 'file' => 'FileValidator' |
||
37 | ]; |
||
38 | /** @var array $errors errors summary */ |
||
39 | public $errors = []; |
||
40 | /** @var array $elements validation elements */ |
||
41 | public $elements = []; |
||
42 | /** @var array $params validation parameters */ |
||
43 | public $params = []; |
||
44 | /** @var IContainer $container Container */ |
||
45 | protected $container; |
||
46 | /** @var array $rule current rule */ |
||
47 | protected $rule = []; |
||
48 | |||
49 | /** |
||
50 | * Constructor validator object |
||
51 | * |
||
52 | * @access public |
||
53 | * |
||
54 | * @param array $params configuration array |
||
55 | * |
||
56 | * @result void |
||
57 | */ |
||
58 | public function __construct(array $params) |
||
63 | |||
64 | /** |
||
65 | * Running validation process |
||
66 | * |
||
67 | * @access public |
||
68 | * |
||
69 | * @param IFormModel $model model |
||
70 | * @param bool $client run on client side? |
||
71 | * |
||
72 | * @return bool|string |
||
73 | * @throws Exception |
||
74 | */ |
||
75 | public function run($model, $client = false) |
||
113 | |||
114 | /** |
||
115 | * @param $name |
||
116 | * @return bool|string |
||
117 | */ |
||
118 | protected function getValidatorClass($name) |
||
130 | |||
131 | /** |
||
132 | * Client validation making |
||
133 | * |
||
134 | * @access public |
||
135 | * |
||
136 | * @param IValidator $validator |
||
137 | * @param IFormModel $model |
||
138 | * |
||
139 | * @return string |
||
140 | */ |
||
141 | public function clientValidate(IValidator $validator, IFormModel $model) |
||
157 | |||
158 | /** |
||
159 | * Get errors after run validation |
||
160 | * |
||
161 | * @access public |
||
162 | * @return array |
||
163 | */ |
||
164 | public function getErrors() |
||
168 | |||
169 | /** |
||
170 | * Check is empty property |
||
171 | * |
||
172 | * @access protected |
||
173 | * |
||
174 | * @param mixed $value check value is empty |
||
175 | * @param bool $trim run trim? |
||
176 | * |
||
177 | * @return bool |
||
178 | */ |
||
179 | protected function isEmpty($value, $trim = false) |
||
183 | } |
||
184 |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: