@@ -193,7 +193,22 @@ public static function resolvePhpDocBlockForMethod(
193193 array $ newPositionalParameterNames ,
194194 ): self
195195 {
196- $ parentReflections = self ::getParentReflections ($ classReflection );
196+ $ docBlocksFromParents = [];
197+ foreach (self ::getParentReflections ($ classReflection ) as $ parentReflection ) {
198+ $ oneResult = self ::resolveMethodPhpDocBlockFromClass (
199+ $ parentReflection ,
200+ $ methodName ,
201+ $ explicit ?? $ docComment !== null ,
202+ $ newPositionalParameterNames ,
203+ );
204+
205+ if ($ oneResult === null ) { // Null if it is private or from a wrong trait.
206+ continue ;
207+ }
208+
209+ $ docBlocksFromParents [] = $ oneResult ;
210+ }
211+
197212 foreach ($ classReflection ->getTraits (true ) as $ traitReflection ) {
198213 if (!$ traitReflection ->hasNativeMethod ($ methodName )) {
199214 continue ;
@@ -208,23 +223,21 @@ public static function resolvePhpDocBlockForMethod(
208223 continue ;
209224 }
210225
211- $ parentReflections [] = $ traitReflection ;
212- }
213-
214- $ docBlocksFromParents = [];
215- foreach ($ parentReflections as $ parentReflection ) {
216- $ oneResult = self ::resolveMethodPhpDocBlockFromClass (
217- $ parentReflection ,
218- $ methodName ,
219- $ explicit ?? $ docComment !== null ,
220- $ newPositionalParameterNames ,
221- );
222-
223- if ($ oneResult === null ) { // Null if it is private or from a wrong trait.
224- continue ;
226+ $ methodVariant = $ traitMethod ->getOnlyVariant ();
227+ $ positionalMethodParameterNames = [];
228+ foreach ($ methodVariant ->getParameters () as $ methodParameter ) {
229+ $ positionalMethodParameterNames [] = $ methodParameter ->getName ();
225230 }
226231
227- $ docBlocksFromParents [] = $ oneResult ;
232+ $ docBlocksFromParents [] = new self (
233+ $ traitMethod ->getDocComment () ?? ResolvedPhpDocBlock::EMPTY_DOC_STRING ,
234+ $ classReflection ->getFileName (),
235+ $ classReflection ,
236+ $ traitReflection ->getName (),
237+ $ explicit ?? $ traitMethod ->getDocComment () !== null ,
238+ self ::remapParameterNames ($ newPositionalParameterNames , $ positionalMethodParameterNames ),
239+ [],
240+ );
228241 }
229242
230243 return new self (
0 commit comments