File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -66,8 +66,7 @@ public function extractMethodBodies(string $className): array
66
66
$ nodeFinder = new NodeFinder ;
67
67
$ classNode = $ nodeFinder ->findFirst (
68
68
$ this ->statements ,
69
- fn (Node $ node ) => ($ node instanceof Node \Stmt \Class_ || $ node instanceof Node \Stmt \Trait_)
70
- && $ node ->namespacedName ->toString () === $ className ,
69
+ fn (Node $ node ) => $ node instanceof Node \Stmt \ClassLike && $ node ->namespacedName ->toString () === $ className ,
71
70
);
72
71
73
72
$ res = [];
Original file line number Diff line number Diff line change @@ -35,6 +35,17 @@ abstract class Another
35
35
echo 123;
36
36
}
37
37
}
38
+
39
+ enum Color
40
+ {
41
+ case Red;
42
+ case Blue;
43
+
44
+ public function getName(): string
45
+ {
46
+ return $this->name;
47
+ }
48
+ }
38
49
' );
39
50
40
51
$ bodies = $ extractor ->extractMethodBodies ('NS\Undefined ' );
@@ -45,3 +56,8 @@ Assert::same([
45
56
'bar1 ' => "\$a = 10; \necho 123; " ,
46
57
'bar2 ' => 'echo "hello"; ' ,
47
58
], $ bodies );
59
+
60
+ $ bodies = $ extractor ->extractMethodBodies ('NS\Color ' );
61
+ Assert::same ([
62
+ 'getName ' => 'return $this->name; ' ,
63
+ ], $ bodies );
You can’t perform that action at this time.
0 commit comments