1 | <?php |
||
26 | final class Methods |
||
27 | { |
||
28 | private const MAGIC_METHODS = [ |
||
29 | '__construct', |
||
30 | '__destruct', |
||
31 | '__call', |
||
32 | '__callStatic', |
||
33 | '__get', |
||
34 | '__set', |
||
35 | '__isset', |
||
36 | '__unset', |
||
37 | '__sleep', |
||
38 | '__wakeup', |
||
39 | '__toString', |
||
40 | '__invoke', |
||
41 | '__set_state', |
||
42 | '__debugInfo', |
||
43 | ]; |
||
44 | |||
45 | private const RESERVED_UNQUALIFIED_RETURN_TYPES = ['self', 'static', 'object']; |
||
46 | |||
47 | /** @varTraverser */ |
||
48 | private $traverser; |
||
49 | |||
50 | /** @var Parser */ |
||
51 | private $parser; |
||
52 | |||
53 | /** |
||
54 | * @param Traverser $traverser |
||
55 | * @param Parser|null $parser |
||
56 | */ |
||
57 | public function __construct( |
||
64 | |||
65 | /** |
||
66 | * @param ReflectionClass $reflection |
||
67 | * @return array |
||
68 | * @throws ReflectionException |
||
69 | */ |
||
70 | public function getMethods(ReflectionClass $reflection): array |
||
97 | |||
98 | /** |
||
99 | * @param ReflectionMethod $method |
||
100 | * @return bool |
||
101 | */ |
||
102 | private function isIgnoredMethod(ReflectionMethod $method): bool |
||
110 | |||
111 | /** |
||
112 | * @param string $name |
||
113 | * @return bool |
||
114 | */ |
||
115 | private function isMagicMethod(string $name): bool |
||
119 | |||
120 | /** |
||
121 | * @param ReflectionMethod $method |
||
122 | * @return int |
||
123 | */ |
||
124 | private function packFlags(ReflectionMethod $method): int |
||
137 | |||
138 | /** |
||
139 | * @param ReflectionMethod $method |
||
140 | * @return Node|null |
||
141 | */ |
||
142 | private function defineReturnType(ReflectionMethod $method): ?Node |
||
152 | |||
153 | /** |
||
154 | * @param ReflectionMethod $method |
||
155 | * @return array |
||
156 | * @throws ReflectionException |
||
157 | */ |
||
158 | private function packParams(ReflectionMethod $method): array |
||
186 | |||
187 | /** |
||
188 | * @param ReflectionParameter $parameter |
||
189 | * @param ReflectionMethod $method |
||
190 | * @return string|null |
||
191 | */ |
||
192 | private function defineParamType(ReflectionParameter $parameter, ReflectionMethod $method): ?string |
||
200 | |||
201 | /** |
||
202 | * @param ReflectionMethod $method |
||
203 | * @param ReflectionType|null $type |
||
204 | * @return string|null |
||
205 | */ |
||
206 | private function defineType(ReflectionMethod $method, ?ReflectionType $type): ?string |
||
225 | |||
226 | /** |
||
227 | * @param ReflectionMethod $method |
||
228 | * @param string $name |
||
229 | * @return string |
||
230 | */ |
||
231 | private function replacedSelfTypeName(ReflectionMethod $method, string $name): string |
||
235 | |||
236 | /** |
||
237 | * @param ReflectionType $returnType |
||
238 | * @param string $name |
||
239 | * @return bool |
||
240 | */ |
||
241 | private function typeShouldBeQualified(ReflectionType $returnType, string $name): bool |
||
249 | |||
250 | /** |
||
251 | * @param ReflectionClass[] $reflections |
||
252 | * @return Node\Stmt\ClassMethod[] |
||
253 | */ |
||
254 | private function getExtendedMethodNodes(array $reflections): array |
||
274 | } |
||
275 |