@@ -195,7 +195,22 @@ public static function resolvePhpDocBlockForMethod(
195
195
array $ newPositionalParameterNames ,
196
196
): self
197
197
{
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
+
199
214
foreach ($ classReflection ->getTraits (true ) as $ traitReflection ) {
200
215
if (!$ traitReflection ->hasNativeMethod ($ methodName )) {
201
216
continue ;
@@ -210,23 +225,21 @@ public static function resolvePhpDocBlockForMethod(
210
225
continue ;
211
226
}
212
227
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 ();
227
232
}
228
233
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
+ );
230
243
}
231
244
232
245
return new self (
0 commit comments