@@ -95,7 +95,7 @@ function processStubFile(string $stubFile, Context $context, bool $includeOnly =
9595        if  (!$ fileInfo  = $ context ->parsedFiles [$ stubFile ] ?? null ) {
9696            initPhpParser ();
9797            $ stubContent  = $ stubCode  ?? file_get_contents ($ stubFile );
98-             $ fileInfo  = parseStubFile ($ stubContent );
98+             $ fileInfo  = FileInfo:: parseStubFile ($ stubContent );
9999            $ context ->parsedFiles [$ stubFile ] = $ fileInfo ;
100100
101101            foreach  ($ fileInfo ->dependencies  as  $ dependency ) {
@@ -4295,7 +4295,27 @@ public function getLegacyVersion(): FileInfo {
42954295        return  $ legacyFileInfo ;
42964296    }
42974297
4298-     public  function  handleStatements (array  $ stmts , PrettyPrinterAbstract   $ prettyPrinter ): void  {
4298+     public  static  function  parseStubFile (string  $ code ): FileInfo   {
4299+         $ parser  = new  PhpParser \Parser \Php7 (new  PhpParser \Lexer \Emulative ());
4300+         $ nodeTraverser  = new  PhpParser \NodeTraverser ;
4301+         $ nodeTraverser ->addVisitor (new  PhpParser \NodeVisitor \NameResolver );
4302+         $ prettyPrinter  = new  class  extends  Standard {
4303+             protected  function  pName_FullyQualified (Name \FullyQualified   $ node ): string  {
4304+                 return  implode ('\\' , $ node ->getParts ());
4305+             }
4306+         };
4307+     
4308+         $ stmts  = $ parser ->parse ($ code );
4309+         $ nodeTraverser ->traverse ($ stmts );
4310+     
4311+         $ fileTags  = DocCommentTag::parseDocComments (getFileDocComments ($ stmts ));
4312+         $ fileInfo  = new  FileInfo ($ fileTags );
4313+     
4314+         $ fileInfo ->handleStatements ($ stmts , $ prettyPrinter );
4315+         return  $ fileInfo ;
4316+     }
4317+ 
4318+     private  function  handleStatements (array  $ stmts , PrettyPrinterAbstract   $ prettyPrinter ): void  {
42994319        $ conds  = [];
43004320        foreach  ($ stmts  as  $ stmt ) {
43014321            $ cond  = self ::handlePreprocessorConditions ($ conds , $ stmt );
@@ -5031,26 +5051,6 @@ function getFileDocComments(array $stmts): array {
50315051    );
50325052}
50335053
5034- function  parseStubFile (string  $ code ): FileInfo   {
5035-     $ parser  = new  PhpParser \Parser \Php7 (new  PhpParser \Lexer \Emulative ());
5036-     $ nodeTraverser  = new  PhpParser \NodeTraverser ;
5037-     $ nodeTraverser ->addVisitor (new  PhpParser \NodeVisitor \NameResolver );
5038-     $ prettyPrinter  = new  class  extends  Standard {
5039-         protected  function  pName_FullyQualified (Name \FullyQualified   $ node ): string  {
5040-             return  implode ('\\' , $ node ->getParts ());
5041-         }
5042-     };
5043- 
5044-     $ stmts  = $ parser ->parse ($ code );
5045-     $ nodeTraverser ->traverse ($ stmts );
5046- 
5047-     $ fileTags  = DocCommentTag::parseDocComments (getFileDocComments ($ stmts ));
5048-     $ fileInfo  = new  FileInfo ($ fileTags );
5049- 
5050-     $ fileInfo ->handleStatements ($ stmts , $ prettyPrinter );
5051-     return  $ fileInfo ;
5052- }
5053- 
50545054/** 
50555055 * @template T 
50565056 * @param iterable<T> $infos 
0 commit comments