File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -29,17 +29,29 @@ public function parse(string $content): ParseResult
29
29
30
30
$ functionLikes = $ nodeFinder ->findInstanceOf ($ stmts , FunctionLike::class);
31
31
32
- $ functions = array_map (function (FunctionLike $ function ) use ($ nodeFinder ) {
32
+ $ functions = $ this ->collectParseResultPerFunctionLike ($ functionLikes );
33
+
34
+ return new ParseResult ($ functions );
35
+ }
36
+
37
+ /**
38
+ * @param list<FunctionLike> $functionLikes
39
+ * @return list<Func>
40
+ */
41
+ private function collectParseResultPerFunctionLike (array $ functionLikes ): array
42
+ {
43
+ $ nodeFinder = new NodeFinder ();
44
+
45
+ return array_map (function (FunctionLike $ function ) use ($ nodeFinder ) {
33
46
$ functionIdentifier = $ function ->name ->name ?? $ function ->getType () . '@ ' . $ function ->getStartLine ();
34
47
35
48
$ func = new Func ($ functionIdentifier );
49
+
36
50
$ variables = $ nodeFinder ->findInstanceOf ($ function , Variable::class);
37
51
foreach ($ variables as $ variable ) {
38
52
$ func ->addVariable (new VarReference ($ variable ->name , $ variable ->getLine ()));
39
53
}
40
54
return $ func ;
41
55
}, $ functionLikes );
42
-
43
- return new ParseResult ($ functions );
44
56
}
45
57
}
You can’t perform that action at this time.
0 commit comments