@@ -117,6 +117,7 @@ public function appendRequestRules(array $controllersInfo)
117
117
$ method = $ controllerInfo ['method ' ];
118
118
$ reflectionMethod = new ReflectionMethod ($ controller , $ method );
119
119
$ params = $ reflectionMethod ->getParameters ();
120
+ $ customRules = $ this ->customParamsDocComment ($ reflectionMethod ->getDocComment ());
120
121
121
122
foreach ($ params as $ param ) {
122
123
if (!$ param ->getType ()) {
@@ -144,8 +145,14 @@ public function appendRequestRules(array $controllersInfo)
144
145
throw $ e ;
145
146
}
146
147
}
147
- $ controllersInfo [$ index ]['docBlock ' ] = $ this ->lrdDocComment ($ reflectionMethod ->getDocComment ());
148
148
}
149
+
150
+ $ controllersInfo [$ index ]['docBlock ' ] = $ this ->lrdDocComment ($ reflectionMethod ->getDocComment ());
151
+
152
+ $ controllersInfo [$ index ]['rules ' ] = array_merge (
153
+ $ controllersInfo [$ index ]['rules ' ] ?? [],
154
+ $ customRules ,
155
+ );
149
156
}
150
157
}
151
158
return $ controllersInfo ;
@@ -236,4 +243,23 @@ public function rulesByRegex($requestClassName)
236
243
237
244
return $ rules ;
238
245
}
246
+
247
+ private function customParamsDocComment ($ docComment ): array
248
+ {
249
+ $ params = [];
250
+
251
+ foreach (explode ("\n" , $ docComment ) as $ comment ) {
252
+ if ( Str::contains ($ comment , '@QAparam ' ) ) {
253
+ $ comment = trim (Str::replace (['@QAparam ' , '* ' ], '' , $ comment ));
254
+
255
+ $ comment = explode (' ' , $ comment );
256
+
257
+ if (count ($ comment ) > 0 ) {
258
+ $ params [$ comment [0 ]] = array_values (array_filter ($ comment , fn ($ item ) => $ item != $ comment [0 ]));
259
+ }
260
+ }
261
+ }
262
+
263
+ return $ params ;
264
+ }
239
265
}
0 commit comments