1 | <?php |
||
14 | final class Validator |
||
15 | { |
||
16 | /** |
||
17 | * @var ObjectFacade |
||
18 | */ |
||
19 | private $facade; |
||
20 | |||
21 | /** |
||
22 | * Validator constructor. |
||
23 | * |
||
24 | * @param ObjectFacade $facade |
||
25 | */ |
||
26 | 4 | public function __construct(ObjectFacade $facade) |
|
30 | |||
31 | /** |
||
32 | * @param ObjectFacade $facade |
||
33 | * |
||
34 | * @return Validator |
||
|
|||
35 | */ |
||
36 | 4 | public static function new(ObjectFacade $facade): self |
|
40 | |||
41 | /** |
||
42 | * @param ReflectionMethod $method |
||
43 | * @param mixed $value |
||
44 | * |
||
45 | * @return bool |
||
46 | 3 | */ |
|
47 | public function isValidSetterMethod(ReflectionMethod $method, $value): bool |
||
67 | 1 | ||
68 | /** |
||
69 | 1 | * @param ReflectionParameter $parameter |
|
70 | * @param mixed $value |
||
71 | * |
||
72 | * @return bool |
||
73 | 1 | */ |
|
74 | 1 | public function isValidParameterValue(ReflectionParameter $parameter, $value): bool |
|
78 | |||
79 | /** |
||
80 | * @param ReflectionMethod $method |
||
81 | 1 | * |
|
82 | 1 | * @return bool |
|
83 | */ |
||
84 | public function isValidGetterMethod(ReflectionMethod $method): bool |
||
100 | |||
101 | /** |
||
102 | * @param ReflectionMethod $method |
||
103 | * @param array ...$args |
||
104 | 2 | * |
|
105 | * @return bool |
||
106 | 2 | */ |
|
107 | public function areValidMethodArguments(ReflectionMethod $method, ...$args): bool |
||
119 | |||
120 | /** |
||
121 | * @param ReflectionMethod $method |
||
122 | * @param array ...$args |
||
123 | * |
||
124 | * @return bool |
||
125 | */ |
||
126 | private function validateMethodArguments(ReflectionMethod $method, ...$args): bool |
||
145 | } |
||
146 | |||
147 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.