| @@ 20-53 (lines=34) @@ | ||
| 17 | { |
|
| 18 | use ParamHelpers; |
|
| 19 | ||
| 20 | public function __invoke(Route $route, ReflectionClass $controller, ReflectionMethod $method, array $routeRules, array $context = []) |
|
| 21 | { |
|
| 22 | foreach ($method->getParameters() as $param) { |
|
| 23 | $paramType = $param->getType(); |
|
| 24 | if ($paramType === null) { |
|
| 25 | continue; |
|
| 26 | } |
|
| 27 | ||
| 28 | $parameterClassName = version_compare(phpversion(), '7.1.0', '<') |
|
| 29 | ? $paramType->__toString() |
|
| 30 | : $paramType->getName(); |
|
| 31 | ||
| 32 | try { |
|
| 33 | $parameterClass = new ReflectionClass($parameterClassName); |
|
| 34 | } catch (\ReflectionException $e) { |
|
| 35 | continue; |
|
| 36 | } |
|
| 37 | ||
| 38 | // If there's a FormRequest, we check there for @bodyParam tags. |
|
| 39 | if (class_exists(LaravelFormRequest::class) && $parameterClass->isSubclassOf(LaravelFormRequest::class) |
|
| 40 | || class_exists(DingoFormRequest::class) && $parameterClass->isSubclassOf(DingoFormRequest::class)) { |
|
| 41 | $formRequestDocBlock = new DocBlock($parameterClass->getDocComment()); |
|
| 42 | $bodyParametersFromDocBlock = $this->getBodyParametersFromDocBlock($formRequestDocBlock->getTags()); |
|
| 43 | ||
| 44 | if (count($bodyParametersFromDocBlock)) { |
|
| 45 | return $bodyParametersFromDocBlock; |
|
| 46 | } |
|
| 47 | } |
|
| 48 | } |
|
| 49 | ||
| 50 | $methodDocBlock = RouteDocBlocker::getDocBlocksFromRoute($route)['method']; |
|
| 51 | ||
| 52 | return $this->getBodyParametersFromDocBlock($methodDocBlock->getTags()); |
|
| 53 | } |
|
| 54 | ||
| 55 | private function getBodyParametersFromDocBlock($tags) |
|
| 56 | { |
|
| @@ 20-53 (lines=34) @@ | ||
| 17 | { |
|
| 18 | use ParamHelpers; |
|
| 19 | ||
| 20 | public function __invoke(Route $route, ReflectionClass $controller, ReflectionMethod $method, array $routeRules, array $context = []) |
|
| 21 | { |
|
| 22 | foreach ($method->getParameters() as $param) { |
|
| 23 | $paramType = $param->getType(); |
|
| 24 | if ($paramType === null) { |
|
| 25 | continue; |
|
| 26 | } |
|
| 27 | ||
| 28 | $parameterClassName = version_compare(phpversion(), '7.1.0', '<') |
|
| 29 | ? $paramType->__toString() |
|
| 30 | : $paramType->getName(); |
|
| 31 | ||
| 32 | try { |
|
| 33 | $parameterClass = new ReflectionClass($parameterClassName); |
|
| 34 | } catch (\ReflectionException $e) { |
|
| 35 | continue; |
|
| 36 | } |
|
| 37 | ||
| 38 | // If there's a FormRequest, we check there for @queryParam tags. |
|
| 39 | if (class_exists(LaravelFormRequest::class) && $parameterClass->isSubclassOf(LaravelFormRequest::class) |
|
| 40 | || class_exists(DingoFormRequest::class) && $parameterClass->isSubclassOf(DingoFormRequest::class)) { |
|
| 41 | $formRequestDocBlock = new DocBlock($parameterClass->getDocComment()); |
|
| 42 | $queryParametersFromDocBlock = $this->getqueryParametersFromDocBlock($formRequestDocBlock->getTags()); |
|
| 43 | ||
| 44 | if (count($queryParametersFromDocBlock)) { |
|
| 45 | return $queryParametersFromDocBlock; |
|
| 46 | } |
|
| 47 | } |
|
| 48 | } |
|
| 49 | ||
| 50 | $methodDocBlock = RouteDocBlocker::getDocBlocksFromRoute($route)['method']; |
|
| 51 | ||
| 52 | return $this->getqueryParametersFromDocBlock($methodDocBlock->getTags()); |
|
| 53 | } |
|
| 54 | ||
| 55 | private function getQueryParametersFromDocBlock($tags) |
|
| 56 | { |
|