1 | <?php |
||
17 | class MethodConditionWithInheritDocFetcher extends Fetcher |
||
18 | { |
||
19 | /** |
||
20 | * @param ReflectionClass $class |
||
21 | * @param Reader $reader |
||
22 | * @param string $methodName |
||
23 | * @param array $contracts |
||
24 | * @return array |
||
25 | */ |
||
26 | 19 | public function getConditions(ReflectionClass $class, Reader $reader, $methodName, array $contracts = []) |
|
34 | |||
35 | /** |
||
36 | * @param ReflectionClass $class |
||
37 | * @param Reader $reader |
||
38 | * @param string $methodName |
||
39 | * @param array $contracts |
||
40 | * @return array |
||
41 | */ |
||
42 | 4 | private function getConditionsWithInheritDoc(ReflectionClass $class, Reader $reader, $methodName, array $contracts) |
|
43 | { |
||
44 | 4 | $parentClass = $class->getParentClass(); |
|
45 | 4 | if (!$parentClass) { |
|
46 | return $contracts; |
||
47 | } |
||
48 | |||
49 | 4 | $parentMethod = $parentClass->getMethod($methodName); |
|
50 | 4 | $annotations = $reader->getMethodAnnotations($parentMethod); |
|
51 | 4 | $contractAnnotations = $this->getContractAnnotations($annotations); |
|
52 | 4 | $contracts = array_merge($contracts, $contractAnnotations); |
|
53 | |||
54 | 4 | if ($this->hasInheritDoc($parentMethod)) { |
|
55 | 4 | return $this->getConditionsWithInheritDoc($parentClass, $reader, $methodName, $contracts); |
|
56 | } |
||
57 | |||
58 | 4 | return $contracts; |
|
59 | } |
||
60 | |||
61 | /** |
||
62 | * @param ReflectionMethod $method |
||
63 | * @return bool |
||
64 | */ |
||
65 | 19 | private function hasInheritDoc(ReflectionMethod $method) |
|
69 | } |
||
70 |