Skip to content

Commit abf3534

Browse files
commented and regexp based rules disabled
1 parent 4de850d commit abf3534

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/LaravelRequestDocs.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff 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;

0 commit comments

Comments
 (0)