8
8
* with this source code in the file LICENSE.
9
9
*/
10
10
11
- namespace PhpDeal \Contract \Fetcher \ParentClass ;
11
+ namespace PhpDeal \Contract \Fetcher \Parent ;
12
12
13
13
use ReflectionClass ;
14
14
@@ -26,9 +26,9 @@ public function getConditions(ReflectionClass $class, $methodName)
26
26
{
27
27
$ annotations = [];
28
28
$ parentMethods = [];
29
- while (( $ class = $ class -> getParentClass ()) && $ class -> hasMethod ( $ methodName )) {
30
- $ parentMethods [] = $ class -> getMethod ( $ methodName );
31
- }
29
+
30
+ $ this -> getParentClassMethods ( $ class , $ methodName, $ parentMethods );
31
+ $ this -> getInterfacesMethods ( $ class , $ methodName , $ parentMethods );
32
32
33
33
foreach ($ parentMethods as $ parentMethod ) {
34
34
$ annotations = array_merge ($ annotations , $ this ->annotationReader ->getMethodAnnotations ($ parentMethod ));
@@ -37,4 +37,32 @@ public function getConditions(ReflectionClass $class, $methodName)
37
37
38
38
return $ contracts ;
39
39
}
40
+
41
+ /**
42
+ * @param ReflectionClass $class
43
+ * @param string $methodName
44
+ * @param array $parentMethods
45
+ */
46
+ private function getParentClassMethods (ReflectionClass $ class , $ methodName , &$ parentMethods )
47
+ {
48
+ while (($ class = $ class ->getParentClass ()) && $ class ->hasMethod ($ methodName )) {
49
+ $ parentMethods [] = $ class ->getMethod ($ methodName );
50
+ }
51
+ }
52
+
53
+ /**
54
+ * @param ReflectionClass $class
55
+ * @param string $methodName
56
+ * @param array $parentMethods
57
+ */
58
+ private function getInterfacesMethods (ReflectionClass $ class , $ methodName , &$ parentMethods )
59
+ {
60
+ $ interfaces = $ class ->getInterfaces ();
61
+
62
+ foreach ($ interfaces as $ interface ) {
63
+ if ($ interface ->hasMethod ($ methodName )) {
64
+ $ parentMethods [] = $ interface ->getMethod ($ methodName );
65
+ }
66
+ }
67
+ }
40
68
}
0 commit comments