CS
This commit is contained in:
parent
eb3e310b0a
commit
9566ee3ead
1 changed files with 6 additions and 6 deletions
|
@ -20,14 +20,14 @@ class RouteValidator
|
|||
*/
|
||||
public static function resolve(object $controller, string $action, array $params): array
|
||||
{
|
||||
$reflection = new ReflectionMethod($controller, $action);
|
||||
$reflection = new ReflectionMethod($controller, $action);
|
||||
$methodParameters = $reflection->getParameters();
|
||||
$validatedParams = [];
|
||||
$validatedParams = [];
|
||||
|
||||
foreach ($methodParameters as $methodParameter) {
|
||||
$paramName = $methodParameter->getName();
|
||||
$paramType = $methodParameter->getType();
|
||||
$isOptional = $methodParameter->isOptional();
|
||||
$paramName = $methodParameter->getName();
|
||||
$paramType = $methodParameter->getType();
|
||||
$isOptional = $methodParameter->isOptional();
|
||||
$defaultValue = $isOptional ? $methodParameter->getDefaultValue() : null;
|
||||
|
||||
if (!array_key_exists($paramName, $params)) {
|
||||
|
@ -38,7 +38,7 @@ class RouteValidator
|
|||
throw new NotFoundHttpException(sprintf("Missing parameter '%s' for action '%s'", $paramName, $action));
|
||||
}
|
||||
|
||||
$value = $params[$paramName];
|
||||
$value = $params[$paramName];
|
||||
$validatedParams[$paramName] = self::validateType($paramName, $value, $paramType, $action);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue