1 | <?php |
||
9 | class Validation |
||
10 | { |
||
11 | |||
12 | /** |
||
13 | * Validators. |
||
14 | * |
||
15 | * @var array |
||
16 | */ |
||
17 | protected $validators = []; |
||
18 | |||
19 | /** |
||
20 | * The translator to use fro the exception message. |
||
21 | * |
||
22 | * @var callable |
||
23 | */ |
||
24 | protected $translator = null; |
||
25 | |||
26 | /** |
||
27 | * Errors from the validation. |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | protected $errors = []; |
||
32 | |||
33 | /** |
||
34 | * Create new Validator service provider |
||
35 | * |
||
36 | * @param null|array|ArrayAccess $validators |
||
37 | * @param null|callable $translator |
||
38 | */ |
||
39 | 10 | public function __construct($validators = null, $translator = null) |
|
40 | { |
||
41 | // Set the validators |
||
42 | 10 | if (is_array($validators) || $validators instanceof ArrayAccess) { |
|
|
|||
43 | 9 | $this->validators = $validators; |
|
44 | 10 | } elseif (is_null($validators)) { |
|
45 | 1 | $this->validators = []; |
|
46 | 1 | } |
|
47 | 10 | $this->translator = $translator; |
|
48 | 10 | } |
|
49 | |||
50 | /** |
||
51 | * Validation middleware invokable class |
||
52 | * |
||
53 | * @param \Psr\Http\Message\ServerRequestInterface $request PSR7 request |
||
54 | * @param \Psr\Http\Message\ResponseInterface $response PSR7 response |
||
55 | * @param callable $next Next middleware |
||
56 | * |
||
57 | * @return \Psr\Http\Message\ResponseInterface |
||
58 | */ |
||
59 | 10 | public function __invoke($request, $response, $next) |
|
78 | |||
79 | /** |
||
80 | * Check if there are any errors. |
||
81 | * @return boolean |
||
82 | */ |
||
83 | 10 | public function hasErrors(){ |
|
86 | |||
87 | /** |
||
88 | * Get errors. |
||
89 | * @return array The errors array. |
||
90 | */ |
||
91 | 8 | public function getErrors(){ |
|
94 | |||
95 | /** |
||
96 | * Get validators. |
||
97 | * @return array The validators array. |
||
98 | */ |
||
99 | 10 | public function getValidators(){ |
|
102 | |||
103 | /** |
||
104 | * Set validators. |
||
105 | * @param array $validators The validators array. |
||
106 | */ |
||
107 | 1 | public function setValidators($validators){ |
|
110 | |||
111 | /** |
||
112 | * Get translator. |
||
113 | * @return callable The translator. |
||
114 | */ |
||
115 | 2 | public function getTranslator(){ |
|
118 | |||
119 | /** |
||
120 | * Set translator. |
||
121 | * @param callable $translator The translator. |
||
122 | */ |
||
123 | 1 | public function setTranslator($translator){ |
|
126 | } |
||
127 |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.