@@ -195,7 +195,22 @@ public static function resolvePhpDocBlockForMethod(
195195 array $ newPositionalParameterNames ,
196196 ): self
197197 {
198- $ parentReflections = self ::getParentReflections ($ classReflection );
198+ $ docBlocksFromParents = [];
199+ foreach (self ::getParentReflections ($ classReflection ) as $ parentReflection ) {
200+ $ oneResult = self ::resolveMethodPhpDocBlockFromClass (
201+ $ parentReflection ,
202+ $ methodName ,
203+ $ explicit ?? $ docComment !== null ,
204+ $ newPositionalParameterNames ,
205+ );
206+
207+ if ($ oneResult === null ) { // Null if it is private or from a wrong trait.
208+ continue ;
209+ }
210+
211+ $ docBlocksFromParents [] = $ oneResult ;
212+ }
213+
199214 foreach ($ classReflection ->getTraits (true ) as $ traitReflection ) {
200215 if (!$ traitReflection ->hasNativeMethod ($ methodName )) {
201216 continue ;
@@ -210,23 +225,21 @@ public static function resolvePhpDocBlockForMethod(
210225 continue ;
211226 }
212227
213- $ parentReflections [] = $ traitReflection ;
214- }
215-
216- $ docBlocksFromParents = [];
217- foreach ($ parentReflections as $ parentReflection ) {
218- $ oneResult = self ::resolveMethodPhpDocBlockFromClass (
219- $ parentReflection ,
220- $ methodName ,
221- $ explicit ?? $ docComment !== null ,
222- $ newPositionalParameterNames ,
223- );
224-
225- if ($ oneResult === null ) { // Null if it is private or from a wrong trait.
226- continue ;
228+ $ methodVariant = $ traitMethod ->getOnlyVariant ();
229+ $ positionalMethodParameterNames = [];
230+ foreach ($ methodVariant ->getParameters () as $ methodParameter ) {
231+ $ positionalMethodParameterNames [] = $ methodParameter ->getName ();
227232 }
228233
229- $ docBlocksFromParents [] = $ oneResult ;
234+ $ docBlocksFromParents [] = new self (
235+ $ traitMethod ->getDocComment () ?? ResolvedPhpDocBlock::EMPTY_DOC_STRING ,
236+ $ classReflection ->getFileName (),
237+ $ classReflection ,
238+ $ traitReflection ->getName (),
239+ $ explicit ?? $ traitMethod ->getDocComment () !== null ,
240+ self ::remapParameterNames ($ newPositionalParameterNames , $ positionalMethodParameterNames ),
241+ [],
242+ );
230243 }
231244
232245 return new self (
0 commit comments