private function resolveParameter(ReflectionParameter $parameter, ContainerInterface $container, $requestedName)
    {
        if ($parameter->isArray()) {
            return [];
        }

        if (! $parameter->getClass()) {
            if (! $parameter->isDefaultValueAvailable()) {
                throw new ServiceNotFoundException(sprintf(
                    'Unable to create service "%s"; unable to resolve parameter "%s" '
                    . 'to a class, interface, or array type',
                    $requestedName,
                    $parameter->getName()
                ));
            }

            return $parameter->getDefaultValue();
        }

        $type = $parameter->getClass()->getName();
        $type = isset($this->aliases[$type]) ? $this->aliases[$type] : $type;

        if ($container->has($type)) {
            return $container->get($type);
        }

        if (! $parameter->isOptional()) {
            throw new ServiceNotFoundException(sprintf(
                'Unable to create service "%s"; unable to resolve parameter "%s" using type hint "%s"',
                $requestedName,
                $parameter->getName(),
                $type
            ));
        }

        // Type not available in container, but the value is optional and has a
        // default defined.
        return $parameter->getDefaultValue();
    }
private function resolveParameter(ReflectionParameter $parameter, ContainerInterface $container, $requestedName)
    {
        if ($parameter->isArray()) {
            return [];
        }

        if (! $parameter->getClass()) {
            if (! $parameter->isDefaultValueAvailable()) {
                throw new ServiceNotFoundException(sprintf(
                    'Unable to create service "%s"; unable to resolve parameter "%s" '
                    . 'to a class, interface, or array type',
                    $requestedName,
                    $parameter->getName()
                ));
            }

            return $parameter->getDefaultValue();
        }

        $type = $parameter->getClass()->getName();
        $type = isset($this->aliases[$type]) ? $this->aliases[$type] : $type;

        if ($container->has($type)) {
            return $container->get($type);
        }

        if (! $parameter->isOptional()) {
            throw new ServiceNotFoundException(sprintf(
                'Unable to create service "%s"; unable to resolve parameter "%s" using type hint "%s"',
                $requestedName,
                $parameter->getName(),
                $type
            ));
        }

        // Type not available in container, but the value is optional and has a
        // default defined.
        return $parameter->getDefaultValue();
    }
private function resolveParameter ( ReflectionParameter $ parameter , ContainerInterface $ container , $ requestedName ) { if ( $ parameter -> isArray ( ) ) { return [ ] ; } if ( ! $ parameter -> getClass ( ) ) { if ( ! $ parameter -> isDefaultValueAvailable ( ) ) { throw new ServiceNotFoundException ( sprintf ( 'Unable to create service "%s"; unable to resolve parameter "%s" ' . 'to a class, interface, or array type' , $ requestedName , $ parameter -> getName ( ) ) ) ; } return $ parameter -> getDefaultValue ( ) ; } $ type = $ parameter -> getClass ( ) -> getName ( ) ; $ type = isset ( $ this -> aliases [ $ type ] ) ? $ this -> aliases [ $ type ] : $ type ; if ( $ container -> has ( $ type ) ) { return $ container -> get ( $ type ) ; } if ( ! $ parameter -> isOptional ( ) ) { throw new ServiceNotFoundException ( sprintf ( 'Unable to create service "%s"; unable to resolve parameter "%s" using type hint "%s"' , $ requestedName , $ parameter -> getName ( ) , $ type ) ) ; } // Type not available in container, but the value is optional and has a // default defined. return $ parameter -> getDefaultValue ( ) ; }
Logic common to all parameter resolution.

@param ReflectionParameter $parameter
@param ContainerInterface $container
@param string $requestedName
@return mixed
@throws ServiceNotFoundException If type-hinted parameter cannot be
resolved to a service in the container.
Logic common to all parameter resolution .