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
6666 $ nodeFinder = new NodeFinder ;
6767 $ classNode = $ nodeFinder ->findFirst (
6868 $ 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 ,
7170 );
7271
7372 $ res = [];
Original file line number Diff line number Diff line change @@ -35,6 +35,17 @@ abstract class Another
3535 echo 123;
3636 }
3737}
38+
39+ enum Color
40+ {
41+ case Red;
42+ case Blue;
43+
44+ public function getName(): string
45+ {
46+ return $this->name;
47+ }
48+ }
3849 ' );
3950
4051$ bodies = $ extractor ->extractMethodBodies ('NS\Undefined ' );
@@ -45,3 +56,8 @@ Assert::same([
4556 'bar1 ' => "\$a = 10; \necho 123; " ,
4657 'bar2 ' => 'echo "hello"; ' ,
4758], $ 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