@@ -193,7 +193,22 @@ public static function resolvePhpDocBlockForMethod(
193
193
array $ newPositionalParameterNames ,
194
194
): self
195
195
{
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
+
197
212
foreach ($ classReflection ->getTraits (true ) as $ traitReflection ) {
198
213
if (!$ traitReflection ->hasNativeMethod ($ methodName )) {
199
214
continue ;
@@ -208,23 +223,21 @@ public static function resolvePhpDocBlockForMethod(
208
223
continue ;
209
224
}
210
225
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 ();
225
230
}
226
231
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
+ );
228
241
}
229
242
230
243
return new self (
0 commit comments