1 | <?php |
||
21 | final class Methods |
||
22 | { |
||
23 | private const MAGIC_METHODS = [ |
||
24 | '__construct', |
||
25 | '__destruct', |
||
26 | '__call', |
||
27 | '__callStatic', |
||
28 | '__get', |
||
29 | '__set', |
||
30 | '__isset', |
||
31 | '__unset', |
||
32 | '__sleep', |
||
33 | '__wakeup', |
||
34 | '__toString', |
||
35 | '__invoke', |
||
36 | '__set_state', |
||
37 | '__debugInfo', |
||
38 | ]; |
||
39 | |||
40 | private const RESERVED_UNQUALIFIED_RETURN_TYPES = ['self', 'static', 'object']; |
||
41 | |||
42 | /** @varTraverser */ |
||
43 | private $traverser; |
||
44 | |||
45 | /** @var Parser */ |
||
46 | private $parser; |
||
47 | |||
48 | /** |
||
49 | * @param Traverser $traverser |
||
50 | * @param Parser|null $parser |
||
51 | */ |
||
52 | public function __construct( |
||
59 | |||
60 | /** |
||
61 | * @param \ReflectionClass $reflection |
||
62 | * @return array |
||
63 | * @throws \ReflectionException |
||
64 | */ |
||
65 | public function getMethods(\ReflectionClass $reflection): array |
||
92 | |||
93 | /** |
||
94 | * @param \ReflectionMethod $method |
||
95 | * @return bool |
||
96 | */ |
||
97 | private function isIgnoredMethod(\ReflectionMethod $method): bool |
||
105 | |||
106 | /** |
||
107 | * @param string $name |
||
108 | * @return bool |
||
109 | */ |
||
110 | private function isMagicMethod(string $name): bool |
||
114 | |||
115 | /** |
||
116 | * @param \ReflectionMethod $method |
||
117 | * @return int |
||
118 | */ |
||
119 | private function packFlags(\ReflectionMethod $method): int |
||
132 | |||
133 | /** |
||
134 | * @param \ReflectionMethod $method |
||
135 | * @return Node|null |
||
136 | */ |
||
137 | private function defineReturnType(\ReflectionMethod $method): ?Node |
||
162 | |||
163 | /** |
||
164 | * @param \ReflectionMethod $method |
||
165 | * @param string $name |
||
166 | * @return string |
||
167 | */ |
||
168 | private function replacedSelfReturnTypeName(\ReflectionMethod $method, string $name): string |
||
172 | |||
173 | /** |
||
174 | * @param \ReflectionType $returnType |
||
175 | * @param string $name |
||
176 | * @return bool |
||
177 | */ |
||
178 | private function returnTypeShouldBeQualified(\ReflectionType $returnType, string $name): bool |
||
186 | |||
187 | /** |
||
188 | * @param \ReflectionMethod $method |
||
189 | * @return array |
||
190 | * @throws \ReflectionException |
||
191 | */ |
||
192 | private function packParams(\ReflectionMethod $method): array |
||
220 | |||
221 | /** |
||
222 | * @param \ReflectionParameter $parameter |
||
223 | * @return string|null |
||
224 | */ |
||
225 | private function defineParamReturnType(\ReflectionParameter $parameter): ?string |
||
243 | |||
244 | /** |
||
245 | * @param \ReflectionClass[] $reflections |
||
246 | * @return Node\Stmt\ClassMethod[] |
||
247 | */ |
||
248 | private function getExtendedMethodNodes(array $reflections): array |
||
268 | } |
||
269 |