private function resolveControllerParameters(
        array $reflectionParameters,
        array $pathVars,
        CompiledRoute $route,
        bool $acceptObjectParameters
    ) : array {
        $resolvedParameters = [];

        // Match the route variables to the method parameters
        foreach ($reflectionParameters as $parameter) {
            if ($acceptObjectParameters && $parameter->getClass() !== null) {
                $className = $parameter->getClass()->getName();
                $resolvedParameters[$parameter->getPosition()] = $this->dependencyResolver->resolve($className);
            } elseif (isset($pathVars[$parameter->getName()])) {
                // There is a value set in the route
                $resolvedParameters[$parameter->getPosition()] = $pathVars[$parameter->getName()];
            } elseif (($defaultValue = $route->getDefaultValue($parameter->getName())) !== null) {
                // There was a default value set in the route
                $resolvedParameters[$parameter->getPosition()] = $defaultValue;
            } elseif (!$parameter->isDefaultValueAvailable()) {
                // There is no value/default value for this variable
                throw new RouteException(
                    "No value set for parameter {$parameter->getName()}"
                );
            }
        }

        return $resolvedParameters;
    }
private function resolveControllerParameters(
        array $reflectionParameters,
        array $pathVars,
        CompiledRoute $route,
        bool $acceptObjectParameters
    ) : array {
        $resolvedParameters = [];

        // Match the route variables to the method parameters
        foreach ($reflectionParameters as $parameter) {
            if ($acceptObjectParameters && $parameter->getClass() !== null) {
                $className = $parameter->getClass()->getName();
                $resolvedParameters[$parameter->getPosition()] = $this->dependencyResolver->resolve($className);
            } elseif (isset($pathVars[$parameter->getName()])) {
                // There is a value set in the route
                $resolvedParameters[$parameter->getPosition()] = $pathVars[$parameter->getName()];
            } elseif (($defaultValue = $route->getDefaultValue($parameter->getName())) !== null) {
                // There was a default value set in the route
                $resolvedParameters[$parameter->getPosition()] = $defaultValue;
            } elseif (!$parameter->isDefaultValueAvailable()) {
                // There is no value/default value for this variable
                throw new RouteException(
                    "No value set for parameter {$parameter->getName()}"
                );
            }
        }

        return $resolvedParameters;
    }
private function resolveControllerParameters ( array $ reflectionParameters , array $ pathVars , CompiledRoute $ route , bool $ acceptObjectParameters ) : array { $ resolvedParameters = [ ] ; // Match the route variables to the method parameters foreach ( $ reflectionParameters as $ parameter ) { if ( $ acceptObjectParameters && $ parameter -> getClass ( ) !== null ) { $ className = $ parameter -> getClass ( ) -> getName ( ) ; $ resolvedParameters [ $ parameter -> getPosition ( ) ] = $ this -> dependencyResolver -> resolve ( $ className ) ; } elseif ( isset ( $ pathVars [ $ parameter -> getName ( ) ] ) ) { // There is a value set in the route $ resolvedParameters [ $ parameter -> getPosition ( ) ] = $ pathVars [ $ parameter -> getName ( ) ] ; } elseif ( ( $ defaultValue = $ route -> getDefaultValue ( $ parameter -> getName ( ) ) ) !== null ) { // There was a default value set in the route $ resolvedParameters [ $ parameter -> getPosition ( ) ] = $ defaultValue ; } elseif ( ! $ parameter -> isDefaultValueAvailable ( ) ) { // There is no value/default value for this variable throw new RouteException ( "No value set for parameter {$parameter->getName()}" ) ; } } return $ resolvedParameters ; }
Gets the resolved parameters for a controller

@param ReflectionParameter[] $reflectionParameters The reflection parameters
@param array $pathVars The route path variables
@param CompiledRoute $route The route whose parameters we're resolving
@param bool $acceptObjectParameters Whether or not we'll accept objects as parameters
@return array The mapping of parameter names to their resolved values
@throws RouteException Thrown if the parameters could not be resolved
Gets the resolved parameters for a controller