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 @@ -62,8 +62,7 @@ public function extractMethodBodies(string $className): array
6262 {
6363 $ nodeFinder = new NodeFinder ;
6464 $ classNode = $ nodeFinder ->findFirst ($ this ->statements , function (Node $ node ) use ($ className ) {
65- return ($ node instanceof Node \Stmt \Class_ || $ node instanceof Node \Stmt \Trait_)
66- && $ node ->namespacedName ->toString () === $ className ;
65+ return $ node instanceof Node \Stmt \ClassLike && $ node ->namespacedName ->toString () === $ className ;
6766 });
6867
6968 $ 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