解决没有类的构造函数

@param  ReflectionParameter $parameter

@return
171842
protected function resolveNonClass(ReflectionParameter $parameter)
    {
        if ($parameter->isDefaultValueAvailable()) {
            return $parameter->getDefaultValue();
        }
        $message = "Unresolvable dependency resolving [$parameter] in class {$parameter->getDeclaringClass()->getName()}";
        throw new \Exception($message);
    }
247499
protected function resolvePrimitive(ReflectionParameter $parameter)
    {
        if ($parameter->isDefaultValueAvailable()) {
            return $parameter->getDefaultValue();
        }

        return $this->unresolvablePrimitive($parameter);
    }
878145
protected function parameterAllowsGuests($parameter)
    {
        return ($parameter->getClass() && $parameter->allowsNull()) ||
               ($parameter->isDefaultValueAvailable() && is_null($parameter->getDefaultValue()));
    }
230121
public function get(string $parameter, $default = null)
    {
        if (false === $this->container->hasParameter($parameter)) {
            return $default;
        }

        if (null === $value = $this->container->getParameter($parameter)) {
            return $default;
        }

        return $value;
    }
705016
public function getParameter($parameter)
    {
        if ($this->hasParameter($parameter)) {
            return ArrayUtils::get($this->parameters, $parameter);
        }

        if (array_key_exists($parameter, $this->mapping) && ArrayUtils::has($this->parameters, $this->mapping[$parameter])) {
            return ArrayUtils::get($this->parameters, $this->mapping[$parameter]);
        }

        //otherwise let's go default
        $defaults = [];
        foreach ($this->defaultConfigs as $default) {
            $defaults = array_merge($default, $defaults);
        }

        if (array_key_exists($parameter, $defaults)) {
            return ArrayUtils::get($defaults, $parameter);
        }

        if (array_key_exists($parameter, $this->mapping) && ArrayUtils::has($defaults, $this->mapping[$parameter])) {
            return ArrayUtils::get($defaults, $this->mapping[$parameter]);
        }

        return null;
    }
1105260
protected function getDeclaringFunction(ReflectionParameter $parameter): string
	{
		$declaringFunction = $parameter->getDeclaringFunction();

		if($declaringFunction->isClosure())
		{
			return 'Closure';
		}

		if(($class = $parameter->getDeclaringClass()) === null)
		{
			return $declaringFunction->getName();
		}

		return $class->getName() . '::' . $declaringFunction->getName();
	}
89033
protected static function getParameter($parameter)
    {
        if (is_bool($parameter)) {
            if (!$parameter) {
                return '0 (boolean)';
            }

            return '1 (boolean)';
        }

        if (is_string($parameter)) {
            if (!$parameter) {
                return '(empty string))';
            }
        }

        return print_r($parameter, true);
    }
1221996
public function addParameter(Parameter $parameter) {
        $parameters = $this->getParameters();
        $parameters[] = $parameter;
        $this->setParameters($parameters);
    }
866599
private function determineParamValue(\ReflectionParameter $parameter)
    {
        $class = $parameter->getClass();

        if (!empty($class)) {
            // If this is a object we may be able to map it to something in our context
            $className = $class->getName();

            // Determine strong type-based link
            if (isset($this->instances[$className])) {
                return $this->instances[$className];
            }

            // Determine weak type-based link
            if (isset($this->weakLinks[$className])) {
                $lowerClassName = $this->weakLinks[$className];
                return $this->instances[$lowerClassName];
            }
        } else {
            // If this is a primitive type, attempt to determine it by its name
            $varName = $parameter->getName();

            if (isset($this->variablesByName[$varName])) {
                return $this->variablesByName[$varName];
            }
        }

        // We were unable to determine a suitable value based on this context. Pass back its default value if possible.
        if ($parameter->isDefaultValueAvailable()) {
            return $parameter->getDefaultValue();
        }

        // As a final fallback we will primitive pass NULL and let the function deal with it.
        return null;
    }
1086540
private function extractClassName(ReflectionParameter $reflectionParameter)
    {
        if (isset($reflectionParameter->getClass()->name)) {
            return $reflectionParameter->getClass()->name;
        }
        return '';
    }
424195
public function getParameter($parameter)
    {
        $param_array = $this->getParameters();

        if (!empty($param_array) && array_key_exists($parameter, $param_array)) {
            return $param_array[$parameter];
        } else {
            throw new \Exception('UNKNOWN_PARAMETER');
        }
    }
1043462
protected function handleUnresolvedArgument(\ReflectionParameter $parameter) {
    $class = $parameter->getDeclaringClass();
    $function = $parameter->getDeclaringFunction();
    if ($class && !$function->isClosure()) {
      $function_name = $class->getName() . '::' . $function->getName();
    }
    else {
      $function_name = $function->getName();
    }
    throw new \RuntimeException(sprintf('Callable "%s" requires a value for the "$%s" argument.', $function_name, $parameter->getName()));
  }
274309
private function getParameterType(\ReflectionParameter $parameter)
    {
        if ( ! $parameter->hasType()) {
            return null;
        }

        return $this->formatType($parameter->getType(), $parameter->getDeclaringFunction(), $parameter);
    }
37823
public function make($abstract, array $parameters = [])
    {
        if ($this->offsetExists($abstract)) {
            return $this->offsetGet($abstract);
        }

        if (!class_exists($abstract)) {
            throw new RuntimeException("Can not make an undefined class [$abstract]");
        }

        $reflector = new ReflectionClass($abstract);

        // 检测是否可实例化
        if (!$reflector->isInstantiable()) {
            throw new RuntimeException("The class [$abstract] is not instantiable.");
        }

        $instance = $reflector->newInstanceArgs($parameters);

        $this->offsetSet($abstract, $instance);

        return $instance;
    }
633486
protected static function getParameterTypeHint(\ReflectionParameter $parameter) : string
    {
        if ($parameter->getClass()) {
            if (
                $parameter->allowsNull()
                && version_compare(PHP_VERSION, '7.1.0', '>=')) {
                return '?\\' . $parameter->getClass()->getName();
            }

            return '\\' . $parameter->getClass()->getName();
        } elseif ($parameter->hasType()) {
            $type = $parameter->getType();

            if (
                $type->allowsNull()
                && $type->__toString()[0] !== '?'
                && version_compare(PHP_VERSION, '7.1.0', '>=')) {
                return '?' . $type->__toString();
            }

            return $type->__toString();
        } else {
            return '';
        }
    }
291893
public static function unresolvedParameter(\ReflectionParameter $parameter) : UnresolvedValueException
    {
        $message = 'The parameter "%s" from function "%s" could not be resolved';
        $message = sprintf($message, self::getParameterName($parameter), self::getFunctionName($parameter));

        return new self($message);
    }
480677
public function getParameter(\ReflectionParameter $parameter, array $args = [])
    {
        $class = $parameter->getClass();

        if ($class && $this->has($class->name)) {
            return $this->get($class->name);
        }

        if ($class && array_key_exists($class->name, $args)) {
            return $args[$class->name];
        }

        if (array_key_exists($parameter->name, $args)) {
            return $args[$parameter->name];
        }

        throw new NotFoundException("Unresolvable " . ($class ? $class->name : $parameter->name));
    }