File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -130,7 +130,11 @@ public function appendRequestRules(array $controllersInfo)
130130 try {
131131 $ controllersInfo [$ index ]['rules ' ] = $ this ->flattenRules ($ requestClass ->rules ());
132132 } catch (Exception $ e ) {
133- $ controllersInfo [$ index ]['rules ' ] = $ this ->rulesByRegex ($ requestClassName );
133+ // disabled. This only works when the rules are defined as 'required|integer' and that too in single line
134+ // doesn't work well when the same rule is defined as array ['required', 'integer'] or in multiple lines such as
135+ // If your rules are not populated using this library, then fix your rule to only throw validation errors and not throw exceptions
136+ // such as 404, 500 inside the request class.
137+ // $controllersInfo[$index]['rules'] = $this->rulesByRegex($requestClassName);
134138 }
135139 $ controllersInfo [$ index ]['docBlock ' ] = $ this ->lrdDocComment ($ reflectionMethod ->getDocComment ());
136140 }
@@ -196,6 +200,7 @@ public function rulesByRegex($requestClassName)
196200 $ data = new ReflectionMethod ($ requestClassName , 'rules ' );
197201 $ lines = file ($ data ->getFileName ());
198202 $ rules = [];
203+
199204 for ($ i = $ data ->getStartLine () - 1 ; $ i <= $ data ->getEndLine () - 1 ; $ i ++) {
200205 preg_match_all ("/(?:'| \").*?(?:'| \")/ " , $ lines [$ i ], $ matches );
201206 $ rules [] = $ matches ;
You can’t perform that action at this time.
0 commit comments