1 | <?php |
||
21 | class ReflectedMethod { |
||
22 | |||
23 | CONST VISIBILITY_PUBLIC = 'public'; |
||
24 | CONST VISIBILITY_PRIVATE = 'private'; |
||
25 | CONST VISIBILITY_PROTECTED = 'protected'; |
||
26 | CONST STATE_LOCAL = 1; |
||
27 | CONST STATE_STATIC = 2; |
||
28 | |||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | private $name; |
||
34 | |||
35 | /** |
||
36 | * @var array |
||
37 | */ |
||
38 | private $arguments = array(); |
||
39 | |||
40 | /** |
||
41 | * @var array |
||
42 | */ |
||
43 | private $returns = array(); |
||
44 | |||
45 | /** |
||
46 | * @var array |
||
47 | */ |
||
48 | private $dependencies = array(); |
||
49 | |||
50 | /** |
||
51 | * Resolver for names |
||
52 | * |
||
53 | * @var NameResolver |
||
54 | */ |
||
55 | private $nameResolver; |
||
56 | |||
57 | /** |
||
58 | * @var array |
||
59 | */ |
||
60 | private $tokens = array(); |
||
61 | |||
62 | /** |
||
63 | * @var string |
||
64 | */ |
||
65 | private $content; |
||
66 | |||
67 | /** |
||
68 | * Usage of method (getter, setter...) |
||
69 | * |
||
70 | * @var string |
||
71 | */ |
||
72 | private $usage; |
||
73 | |||
74 | /** |
||
75 | * @var int |
||
76 | */ |
||
77 | private $visibility = self::VISIBILITY_PUBLIC; |
||
78 | |||
79 | /** |
||
80 | * @var int |
||
81 | */ |
||
82 | private $state = self::STATE_LOCAL; |
||
83 | |||
84 | /** |
||
85 | * Anonymous class contained in this method |
||
86 | * |
||
87 | * @var array |
||
88 | */ |
||
89 | private $anonymousClasses = array(); |
||
90 | |||
91 | /** |
||
92 | * @var array |
||
93 | */ |
||
94 | private $instanciedClasses = array(); |
||
95 | |||
96 | /** |
||
97 | * @var string |
||
98 | */ |
||
99 | private $namespace; |
||
100 | |||
101 | /** |
||
102 | * @var array |
||
103 | */ |
||
104 | private $internalCalls = array(); |
||
105 | |||
106 | /** |
||
107 | * @var array |
||
108 | */ |
||
109 | private $externalCalls = array(); |
||
110 | |||
111 | /** |
||
112 | * @param string $name |
||
113 | */ |
||
114 | public function __construct($name) |
||
115 | { |
||
116 | $this->name = (string) $name; |
||
117 | $this->nameResolver = new NameResolver(); |
||
118 | } |
||
119 | |||
120 | /** |
||
121 | * @return string |
||
122 | */ |
||
123 | public function getName() |
||
127 | |||
128 | /** |
||
129 | * @return \SplObjectStorage |
||
130 | */ |
||
131 | public function getArguments() |
||
135 | |||
136 | /** |
||
137 | * Attach argument |
||
138 | * |
||
139 | * @param ReflectedArgument $arg |
||
140 | * @return $this |
||
141 | */ |
||
142 | public function pushArgument(ReflectedArgument $arg) { |
||
146 | |||
147 | /** |
||
148 | * @return string |
||
149 | */ |
||
150 | public function getContent() |
||
154 | |||
155 | /** |
||
156 | * @param string $content |
||
157 | * @return $this |
||
158 | */ |
||
159 | public function setContent($content) |
||
164 | |||
165 | /** |
||
166 | * @return array |
||
167 | */ |
||
168 | public function getTokens() |
||
172 | |||
173 | /** |
||
174 | * @param \Hal\Component\Token\TokenCollection $tokens |
||
175 | * @return self |
||
176 | */ |
||
177 | public function setTokens($tokens) |
||
182 | |||
183 | /** |
||
184 | * Get returned value |
||
185 | * |
||
186 | * @return array |
||
187 | */ |
||
188 | public function getReturns() { |
||
204 | |||
205 | /** |
||
206 | * Attach ne return information |
||
207 | * |
||
208 | * It make no sense for the moment to store any information abour return value / type. Maybe in PHP 6 ? :) |
||
209 | * |
||
210 | * @param ReflectedReturn $return |
||
211 | * @return $this |
||
212 | */ |
||
213 | public function pushReturn(ReflectedReturn $return) { |
||
217 | |||
218 | /** |
||
219 | * Push dependency |
||
220 | * |
||
221 | * @param $name |
||
222 | * @return self |
||
223 | */ |
||
224 | public function pushDependency($name) { |
||
228 | |||
229 | /** |
||
230 | * @return array |
||
231 | */ |
||
232 | public function getDependencies() |
||
233 | { |
||
234 | // on read : compare with aliases. We cannot make it in pushDependency() => aliases aren't yet known |
||
235 | $dependencies = array(); |
||
236 | foreach($this->dependencies as $name) { |
||
237 | array_push($dependencies, $this->nameResolver->resolve($name, null)); |
||
238 | } |
||
239 | |||
240 | // returned values |
||
241 | $resolver = new TypeResolver(); |
||
242 | foreach($this->returns as $return) { |
||
243 | $name = $return->getType(); |
||
244 | if(!$resolver->isNative($name)) { |
||
245 | array_push($dependencies, $this->nameResolver->resolve($name, null)); |
||
246 | } |
||
247 | } |
||
248 | |||
249 | // anonymous classes in method (inner class) |
||
250 | foreach($this->anonymousClasses as $c) { |
||
251 | array_push($dependencies, $c->getParent()); |
||
252 | $dependencies = array_merge($dependencies, $c->getDependencies()); |
||
253 | } |
||
254 | return array_unique($dependencies); |
||
255 | } |
||
256 | |||
257 | /** |
||
258 | * @param NameResolver $resolver |
||
259 | * @return self |
||
260 | */ |
||
261 | public function setNameResolver(NameResolver $resolver) |
||
262 | { |
||
263 | $this->nameResolver = $resolver; |
||
264 | return $this; |
||
265 | } |
||
266 | |||
267 | /** |
||
268 | * @return bool |
||
269 | */ |
||
270 | public function isSetter() { |
||
273 | |||
274 | /** |
||
275 | * @return string |
||
276 | */ |
||
277 | public function getUsage() |
||
281 | |||
282 | /** |
||
283 | * @param string $usage |
||
284 | */ |
||
285 | public function setUsage($usage) |
||
289 | |||
290 | /** |
||
291 | * @return bool |
||
292 | */ |
||
293 | public function isGetter() { |
||
296 | |||
297 | /** |
||
298 | * @return int |
||
299 | */ |
||
300 | public function getVisibility() |
||
304 | |||
305 | /** |
||
306 | * @param int $visibility |
||
307 | * @return $this |
||
308 | */ |
||
309 | public function setVisibility($visibility) |
||
314 | |||
315 | /** |
||
316 | * @return int |
||
317 | */ |
||
318 | public function getState() |
||
322 | |||
323 | /** |
||
324 | * @param int $state |
||
325 | * @return ReflectedMethod |
||
326 | */ |
||
327 | public function setState($state) |
||
332 | /** |
||
333 | * @param ReflectedAnonymousClass $class |
||
334 | * @return $this |
||
335 | */ |
||
336 | public function pushAnonymousClass(ReflectedAnonymousClass $class) { |
||
340 | |||
341 | /** |
||
342 | * @return array |
||
343 | */ |
||
344 | public function getAnonymousClasses() |
||
348 | |||
349 | /** |
||
350 | * @param string $namespace |
||
351 | * @return ReflectedMethod |
||
352 | */ |
||
353 | public function setNamespace($namespace) |
||
358 | |||
359 | /** |
||
360 | * @return string |
||
361 | */ |
||
362 | public function getNamespace() |
||
366 | |||
367 | /** |
||
368 | * @param $class |
||
369 | * @return $this |
||
370 | */ |
||
371 | public function pushInstanciedClass($class) { |
||
375 | |||
376 | /** |
||
377 | * @return array |
||
378 | */ |
||
379 | public function getInstanciedClasses() |
||
387 | |||
388 | /** |
||
389 | * @param $call |
||
390 | * @return $this |
||
391 | */ |
||
392 | public function pushInternalCall($call) |
||
397 | |||
398 | /** |
||
399 | * @return array |
||
400 | */ |
||
401 | public function getInternalCalls() |
||
405 | |||
406 | /** |
||
407 | * @param $call |
||
408 | * @return $this |
||
409 | */ |
||
410 | public function pushExternalCall($call) |
||
415 | |||
416 | /** |
||
417 | * @return array |
||
418 | */ |
||
419 | public function getExternalCalls() |
||
423 | |||
424 | |||
425 | |||
426 | }; |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..