@@ -231,14 +231,17 @@ public function appendRequestRules(Collection $docs): Collection
231
231
continue ;
232
232
}
233
233
234
- $ reflectionMethod = new ReflectionMethod ($ doc ->getControllerFullPath (), $ doc ->getMethod ());
234
+ $ controllerReflectionMethod = new ReflectionMethod ($ doc ->getControllerFullPath (), $ doc ->getMethod ());
235
235
236
- $ docComment = $ this ->getDocComment ($ reflectionMethod );
236
+ $ controllerMethodDocComment = $ this ->getDocComment ($ controllerReflectionMethod );
237
237
238
- $ customRules = $ this ->customParamsDocComment ( $ docComment );
239
- $ doc -> setResponses ( $ this ->customResponsesDocComment ( $ docComment ) );
238
+ $ controllerMethodLrdComment = $ this ->lrdDocComment ( $ controllerMethodDocComment );
239
+ $ controllerMethodDocRules = $ this ->customParamsDocComment ( $ controllerMethodDocComment );
240
240
241
- foreach ($ reflectionMethod ->getParameters () as $ param ) {
241
+ $ doc ->setResponses ($ this ->customResponsesDocComment ($ controllerMethodDocComment ));
242
+
243
+ $ lrdDocComments = [];
244
+ foreach ($ controllerReflectionMethod ->getParameters () as $ param ) {
242
245
/** @var \ReflectionNamedType|\ReflectionUnionType|\ReflectionIntersectionType|null $namedType */
243
246
$ namedType = $ param ->getType ();
244
247
if (!$ namedType ) {
@@ -261,18 +264,29 @@ public function appendRequestRules(Collection $docs): Collection
261
264
262
265
try {
263
266
$ doc ->mergeRules ($ this ->flattenRules ($ requestObject ->$ requestMethod ()));
267
+ $ requestReflectionMethod = new ReflectionMethod ($ requestObject , $ requestMethod );
264
268
} catch (Throwable $ e ) {
265
269
$ doc ->mergeRules ($ this ->rulesByRegex ($ requestClassName , $ requestMethod ));
270
+ $ requestReflectionMethod = new ReflectionMethod ($ requestClassName , $ requestMethod );
266
271
}
272
+
273
+ $ requestMethodDocComment = $ this ->getDocComment ($ requestReflectionMethod );
274
+
275
+ $ requestMethodLrdComment = $ this ->lrdDocComment ($ requestMethodDocComment );
276
+ $ requestMethodDocRules = $ this ->customParamsDocComment ($ requestMethodDocComment );
277
+
278
+ $ lrdDocComments [] = $ requestMethodLrdComment ;
279
+ $ doc ->mergeRules ($ requestMethodDocRules );
267
280
}
268
281
} catch (Throwable $ e ) {
269
282
// Do nothing.
270
283
}
271
-
272
- $ doc ->mergeRules ($ customRules );
273
284
}
274
285
275
- $ doc ->setDocBlock ($ this ->lrdDocComment ($ docComment ));
286
+ $ lrdDocComments [] = $ controllerMethodLrdComment ;
287
+ $ lrdDocComments = array_filter ($ lrdDocComments , fn ($ s ) => $ s !== '' );
288
+ $ doc ->setDocBlock (join ("\n" , $ lrdDocComments ));
289
+ $ doc ->mergeRules ($ controllerMethodDocRules );
276
290
}
277
291
return $ docs ;
278
292
}
0 commit comments