@@ -112,6 +112,7 @@ public function appendRequestRules(array $controllersInfo)
112
112
$ method = $ controllerInfo ['method ' ];
113
113
$ reflectionMethod = new ReflectionMethod ($ controller , $ method );
114
114
$ params = $ reflectionMethod ->getParameters ();
115
+ $ customRules = $ this ->customParamsDocComment ($ reflectionMethod ->getDocComment ());
115
116
116
117
foreach ($ params as $ param ) {
117
118
if (!$ param ->getType ()) {
@@ -141,6 +142,11 @@ public function appendRequestRules(array $controllersInfo)
141
142
}
142
143
$ controllersInfo [$ index ]['docBlock ' ] = $ this ->lrdDocComment ($ reflectionMethod ->getDocComment ());
143
144
}
145
+
146
+ $ controllersInfo [$ index ]['rules ' ] = array_merge (
147
+ $ controllersInfo [$ index ]['rules ' ] ?? [],
148
+ $ customRules ,
149
+ );
144
150
}
145
151
}
146
152
return $ controllersInfo ;
@@ -231,4 +237,23 @@ public function rulesByRegex($requestClassName)
231
237
232
238
return $ rules ;
233
239
}
240
+
241
+ private function customParamsDocComment ($ docComment ): array
242
+ {
243
+ $ params = [];
244
+
245
+ foreach (explode ("\n" , $ docComment ) as $ comment ) {
246
+ if ( Str::contains ($ comment , '@QAparam ' ) ) {
247
+ $ comment = trim (Str::replace (['@QAparam ' , '* ' ], '' , $ comment ));
248
+
249
+ $ comment = explode (' ' , $ comment );
250
+
251
+ if (count ($ comment ) > 0 ) {
252
+ $ params [$ comment [0 ]] = array_values (array_filter ($ comment , fn ($ item ) => $ item != $ comment [0 ]));
253
+ }
254
+ }
255
+ }
256
+
257
+ return $ params ;
258
+ }
234
259
}
0 commit comments