File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,17 +29,29 @@ public function parse(string $content): ParseResult
2929
3030 $ functionLikes = $ nodeFinder ->findInstanceOf ($ stmts , FunctionLike::class);
3131
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 ) {
3346 $ functionIdentifier = $ function ->name ->name ?? $ function ->getType () . '@ ' . $ function ->getStartLine ();
3447
3548 $ func = new Func ($ functionIdentifier );
49+
3650 $ variables = $ nodeFinder ->findInstanceOf ($ function , Variable::class);
3751 foreach ($ variables as $ variable ) {
3852 $ func ->addVariable (new VarReference ($ variable ->name , $ variable ->getLine ()));
3953 }
4054 return $ func ;
4155 }, $ functionLikes );
42-
43- return new ParseResult ($ functions );
4456 }
4557}
You can’t perform that action at this time.
0 commit comments