Helper method to get the type of a reflection paramter
@param \ReflectionParameter $parameter
@return NULL|\ReflectionType|string
321241
protected function getReflectionParameterName(\ReflectionParameter $parameter)
    {
        // parameter is a class
        if ($class = $parameter->getClass()) {
            return $class->getName() . ' \$' . $parameter->getName();
        }

        return $parameter->getName();
    }
642631
public static function fromReflection(ReflectionParameter $reflectionParameter)
    {
        $param = new static($reflectionParameter->getName());

        if ($reflectionParameter->isArray() === true) {
            $param->setType('array');
        } else {
            $typeClass = $reflectionParameter->getClass();
            if ($typeClass !== null) {
                $param->setType('\\' . $typeClass->getName());
            }
        }

        if ($reflectionParameter->isOptional() === true) {
            $param->setDefaultValue($reflectionParameter->getDefaultValue());

            if ($reflectionParameter->isDefaultValueConstant() === true) {
                $defaultValueConstantName = $reflectionParameter->getDefaultValueConstantName();

                $declaringFunction = $reflectionParameter->getDeclaringFunction();
                if ($declaringFunction instanceof \ReflectionMethod) {
                    $ns = $declaringFunction->getDeclaringClass()->getNamespaceName();
                } else {
                    $ns = $declaringFunction->getNamespaceName();
                }

                if ($ns !== '' && strpos($defaultValueConstantName, $ns) === 0) {
                    $defaultValueConstantName = substr($defaultValueConstantName, strlen($ns) + 1);
                } elseif (strpos($defaultValueConstantName, '\\') !== false) {
                    $defaultValueConstantName = '\\' . $defaultValueConstantName;
                }

                $param->setDefaultValueConstantName($defaultValueConstantName);
            }
        }

        $param->setPassByReference($reflectionParameter->isPassedByReference());

        return $param;
    }
705435
private function getEmptyListOfParamsOf(\ReflectionMethod $method)
    {
        $numberOfMethodParams = count($method->getParameters());
        if ($numberOfMethodParams > 0) { //for older php
            $orderedParamList = array_fill(0, $numberOfMethodParams, null);
        } else {
            $orderedParamList = [];
        }
        
        return $orderedParamList;
    }
270849
public function filterByParameter($parameter)
    {
        $callback = function (BindingInterface $binding, $key) use ($parameter) {
            return $binding->getParameter() == $parameter;
        };

        return $this->filter($callback);
    }
255968
public function getType($parameter='')
	{
		$parameterType = null;
		switch (gettype($parameter)) {
			case 'string':
				$parameterType = 's';
				break;
			case 'numeric':
			case 'integer':
				$parameterType = 'i';
				break;
			case 'double':
				$parameterType = 'd';
				break;
			default:
				$parameterType = null;
				break;
		}

		return $parameterType;
	}
767130
public function getParameter($parameter)
    {
        return $this->container->hasParameter($parameter) ? $this->container->getParameter($parameter) : null;
    }
702045
public function get($parameter = null) {

        if ( empty($parameter) ) {

            $return = $this->parameters;

        } else if ( array_key_exists($parameter, $this->parameters) ) {

            $return = $this->parameters[$parameter];

        } else {

            $return = null;

        }

        return $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);
    }
1088559
protected static function resolveValue($parameter): string
    {
        if ($parameter instanceof ParameterInterface) {
            return self::resolveValue($parameter->getValue());
        }

        switch (gettype($parameter)) {
            case 'boolean':
                return $parameter ? 'true' : 'false';

            case 'integer':
                return strval($parameter + 0);

            case 'NULL':
                return 'NULL';

            case 'double':
                return sprintf('%F', $parameter);

            case 'string':
                return "'" . addcslashes($parameter, "'") . "'";

            case 'object':
                if (method_exists($parameter, '__toString')) {
                    return "'" . addcslashes((string)$parameter, "'") . "'";
                }

                if ($parameter instanceof \DateTime) {
                    //Let's process dates different way
                    return "'" . $parameter->format(\DateTime::ISO8601) . "'";
                }
        }

        return '[UNRESOLVED]';
    }
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);
    }
295666
private function isVariadic(\ReflectionParameter $parameter)
    {
        if ($parameter->name == "...") {
            // This is a variadic C-implementation before PHP-5.6.
            return true;
        }
        if (method_exists($parameter, "isVariadic")) {
            return $parameter->isVariadic();
        }
        return false;
    }
545456
public function interfaceInjection($reflectionParam)
    {
        $constructorArgs = null;
        /*
         | Check if constructor dependency is Interface or not.
         | if interface we will check definition for the interface
         | and inject into controller constructor
         */
        if (!$reflectionParam->IsInstantiable() && $reflectionParam->isInterface()) {
            $aliases = $this->definition['definition.config']['register.alias'];
            $interface = Inflector::getClassName($reflectionParam->getName());

            if (array_key_exists($interface, $aliases)) {
                $constructorArgs = $this->container->makeInstance($aliases[$interface]);
            }
        }

        return $constructorArgs;
    }
28967
public function getDependency(\ReflectionParameter $parameter, \ReflectionClass $reflected)
    {
        if ($parameter->isArray() || !$parameter->getClass()) {

            if ($parameter->isArray()) {
                return 'array';
            }

            return null;
        }

        $class = $parameter->getClass()->name;

        if ($class == 'Closure') {
            return null;
        }

        $reflected = new \ReflectionClass($class);

        if ($this->provider->hasBinding($reflected->name)) {
            return $this->provider->getBinding($reflected->name);
        } else {
            // TODO: inspect this
            return $reflected->name;
        }
    }
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;
    }
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;
    }
202242
public static function getParameterType(\ReflectionParameter $param): ?string
    {
        if (!$param->hasType()) {
            return null;
        }

        $type = $param->getType();

        if ($type === null || $type->isBuiltin()) {
            return null;
        }

        $type = $type->getName();
        $lower = \strtolower($type);

        if ($lower === 'self') {
            return $param->getDeclaringClass()->getName();
        }

        if ($lower === 'parent' && ($parent = $param->getDeclaringClass()->getParentClass())) {
            return $parent->getName();
        }

        return $type;
    }
1021732
private static function supportedType(\ReflectionParameter $parameter): bool
    {
        /** @var \ReflectionType $reflectionType */
        $reflectionType     = $parameter->getType();
        $reflectionTypeName = $reflectionType->getName();

        return (true === \class_exists($reflectionTypeName) || true === \interface_exists($reflectionTypeName)) &&
            false === \is_a($reflectionTypeName, ServiceBusContext::class, true) &&
            false === \is_a($reflectionTypeName, \Throwable::class, true);
    }