@@ -140,22 +140,52 @@ public function getExprFromValue($value): Node\Expr
140140    /** 
141141     * @return Node\Stmt\ClassMethod[] 
142142     */ 
143-     public  function  getAllMethodsFromStmts (array  $ stmtsarray 
143+     public  function  getAllMethodsFromStmts (array  $ stmts,  bool   $ withTrait  =  false ): array 
144144    {
145145        $ methods
146146        foreach  ($ stmtsas  $ namespace
147147            if  (! $ namespaceinstanceof  Node \Stmt \Namespace_) {
148148                continue ;
149149            }
150150
151+             /** @var string[] $uses */ 
152+             $ uses
153+ 
151154            foreach  ($ namespacestmts  as  $ class
152-                 if  (! $ classinstanceof  Node \Stmt \Class_ && ! $ classinstanceof  Node \Stmt \Interface_) {
155+                 if  ($ classinstanceof  Node \Stmt \Use_) {
156+                     foreach  ($ classuses  as  $ use
157+                         $ uses$ usename ->getLast ()] = $ usename ->toString ();
158+                     }
159+                     continue ;
160+                 }
161+ 
162+                 if  (! $ classinstanceof  Node \Stmt \Class_ && ! $ classinstanceof  Node \Stmt \Interface_ && ! $ classinstanceof  Node \Stmt \Trait_) {
153163                    continue ;
154164                }
155165
156166                foreach  ($ classgetMethods () as  $ method
157167                    $ methods$ method
158168                }
169+ 
170+                 if  ($ withTrait
171+                     foreach  ($ classstmts  as  $ stmt
172+                         if  ($ stmtinstanceof  Node \Stmt \TraitUse) {
173+                             foreach  ($ stmttraits  as  $ trait
174+                                 if  (isset ($ uses$ traitgetFirst ()])) {
175+                                     $ traitName$ uses$ traitgetFirst ()] . substr ($ traittoString (), strlen ($ traitgetFirst ()));
176+                                 } else  {
177+                                     if  (count ($ traitgetParts ()) == 1 ) {
178+                                         $ traitName$ namespacename ->toString () . '\\'  . $ traittoString ();
179+                                     } else  {
180+                                         $ traitName$ traittoString ();
181+                                     }
182+                                 }
183+                                 $ traitNodes$ this parser ->parse (file_get_contents ((new  ReflectionClass ($ traitNamegetFileName ()));
184+                                 $ methodsarray_merge ($ methods$ this getAllMethodsFromStmts ($ traitNodestrue ));
185+                             }
186+                         }
187+                     }
188+                 }
159189            }
160190        }
161191
0 commit comments