Returns the type (if any) + name of a function parameter.

@param \ReflectionParameter $parameter

@return string
423664
private static function getParameterName(\ReflectionParameter $parameter) : string
    {
        $parameterType = '';

        if (null !== $type = $parameter->getType()) {
            $parameterType = (string) $type . ' ';
        }

        return $parameterType . '$' . $parameter->getName();
    }
57113
protected static function getReturnType(\ReflectionMethod $method) : string
    {
        if ($method->getReturnType()->isBuiltin()) {
            return (string)$method->getReturnType();
        } else {
            $type = (string)$method->getReturnType();
            return '\\' . ($type === 'self' ? $method->getDeclaringClass()->getName() : $type);
        }
    }
2689
protected function arguments(\ReflectionFunctionAbstract $reflection, $parameters = array())
    {
        $arguments = array();

        foreach ($reflection->getParameters() as $key => $parameter)
        {
            $name = $parameter->getName();

            if ($class = $parameter->getClass())
            {
                $name = $class->getName();
            }

            if (isset($parameters[$name]))
            {
                if ($parameter->isDefaultValueAvailable())
                {
                    $arguments[$name] = $parameter->getDefaultValue();
                }

                if ($parameters[$name])
                {
                    $arguments[$name] = $parameters[$name];
                }

                continue;
            }

            $arguments[$name] = $this->instance($name);
        }

        return $arguments;
    }
485468
private function getName(ReflectionMethod $method, \ReflectionParameter $parameter) : string
    {
        $named = $method->getAnnotation(Named::class);
        if (! $named instanceof Named) {
            return Name::ANY;
        }
        parse_str($named->value, $names);
        $paramName = $parameter->getName();
        if (isset($names[$paramName])) {
            return $names[$paramName];
        }

        return Name::ANY;
    }
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();
	}
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);
    }
310012
protected function getParameter(\ReflectionParameter $parameter)
    {
        if ($parameter->isOptional()) {
            return $parameter->getDefaultValue();
        }

        $type = (string)$parameter->getType();
        return $this->get($type);
    }
796617
private function getParameterNamesForParentCall(array $parameters)
    {
        return array_map(
            function (\ReflectionParameter $parameter) {
                $name = '';

                if ($parameter->isVariadic()) {
                    $name .= '...';
                }

                $name .= '$' . $parameter->getName();

                return $name;
            },
            $parameters
        );
    }
1301907
public function getParameterTypes(\ReflectionParameter $parameter) : array
    {
        $name = $parameter->getName();
        $function = $parameter->getDeclaringFunction();
        $types = $this->getFunctionParameterTypes($function);

        return isset($types[$name]) ? $types[$name] : [];
    }
1276198
protected function get($parameter, $default=null) {
		return isset($this->parameters[$parameter]) ? $this->parameters[$parameter] : $default;
	}
52740
public function getValueBy(ParameterInterface $parameter)
    {
        if ($this->isExistBy($parameter) === false) {
            throw new NoBindParameterException('No parameter: ' . (string) $parameter);
        }

        return $this->parameters[$parameter->getHash()];
    }
855068
protected function checkParamType(SmdParameter $parameter, $type)
    {
        switch (true) {
            case $type instanceof Date:
                $parameter->typeFormat = $type->getFormat();
                $parameter->typeAdditional = (string)$type;

                if (empty($parameter->types)) {
                    $parameter->types = ['string'];
                }
                break;

            case $type instanceof Enum:
                if ($type->hasVariants()) {
                    $parameter->typeVariants = $type->getVariants();
                    $parameter->typeAdditional = (string)$type;
                } else {
                    $parameter->typeAdditional = $type->getVariantsType();
                }

                if (empty($parameter->types)) {
                    $parameter->types = [$type->getRealType()];
                }

                break;

            case $type instanceof Object_:
                $parameter->types = ['object'];
                if ($type->getClassName() !== null) {
                    $parameter->typeAdditional = $type->getClassName();
                }
                break;

            case $type instanceof Array_:
                $parameter->array = true;
                $parameter = $this->checkParamType($parameter, $type->getValueType());
                break;

            default:
                $parameter->types = [(string)$type];
        }

        return $parameter;
    }
1191073
private function getType(\ReflectionParameter $parameter, \ReflectionFunctionAbstract $function)
    {
        if (!$type = $parameter->getType()) {
            return;
        }
        $name = $type->getName();
        $lcName = strtolower($name);

        if ('self' !== $lcName && 'parent' !== $lcName) {
            return $name;
        }
        if (!$function instanceof \ReflectionMethod) {
            return;
        }
        if ('self' === $lcName) {
            return $function->getDeclaringClass()->name;
        }
        if ($parent = $function->getDeclaringClass()->getParentClass()) {
            return $parent->name;
        }
    }
371240
private static function matchType(\ReflectionParameter $parameter, $value) : bool
    {
        if ($class = $parameter->getClass()) {
            return \is_object($value) && $class->isInstance($value);
        }

        if ($parameter->isArray()) {
            return \is_array($value);
        }

        if ($parameter->isCallable()) {
            return \is_callable($value);
        }

        if (!$type = $parameter->getType()) {
            return true;
        }

        switch ($type->getName()) {
            case 'bool': return \is_bool($value);
            case 'float': return \is_float($value);
            case 'int': return \is_int($value);
            case 'string': return \is_string($value);
            case 'iterable': return \is_iterable($value);
        }

        return true;
    }
394054
private function detectBindingName(\ReflectionParameter $param, $default = null)
    {
        $annotations = annotationsOf($param);
        if ($annotations->contain('List')) {
            return $annotations->firstNamed('List')->getValue();
        }

        if ($annotations->contain('Map')) {
            return $annotations->firstNamed('Map')->getValue();
        }

        if ($annotations->contain('Named')) {
            return $annotations->firstNamed('Named')->getName();
        }

        if ($annotations->contain('Property')) {
            return $annotations->firstNamed('Property')->getValue();
        }

        return $default;
    }
369826
protected function transformDependency(ReflectionParameter $parameter, $parameters)
    {
        if (is_null($class = $parameter->getClass())) {
            return;
        }

        // The parameter references a class.
        else if (! $class->isSubclassOf(Model::class)) {
            return $this->container->make($class->name);
        }

        $identifier = Arr::first($parameters, function ($parameterKey) use ($parameter)
        {
            return $parameterKey === $parameter->name;
        });

        if (! is_null($identifier)) {
            $instance = $class->newInstance();

            return call_user_func(array($instance, 'find'), $identifier);
        }
    }
321241
protected function getReflectionParameterName(\ReflectionParameter $parameter)
    {
        // parameter is a class
        if ($class = $parameter->getClass()) {
            return $class->getName() . ' \$' . $parameter->getName();
        }

        return $parameter->getName();
    }