Attempt to transform the given parameter into a class instance.

@param  \ReflectionParameter $parameter
@param  array $parameters
@param  array $originalParameters
@return mixed
162524
protected function transformDependency( ReflectionParameter $parameter, $parameters, $originalParameters )
	{
		$class = $parameter->getClass();

		// If the parameter has a type-hinted class, we will check to see if it is already in
		// the list of parameters. If it is we will just skip it as it is probably a model
		// binding and we do not want to mess with those; otherwise, we resolve it here.
		if ( $class && !$this->alreadyInParameters( $class->name, $parameters ) )
			return UniversalBuilder::resolveClass( $class->name );
	}
1276198
protected function get($parameter, $default=null) {
		return isset($this->parameters[$parameter]) ? $this->parameters[$parameter] : $default;
	}
468607
public function invoke($type, $parameters = null)
    {
        $class = $this->getClass($type);
        $name  = $this->normalizeType($type);

        $params = func_get_args();
        array_shift($params);

        $reflector = new \ReflectionClass($class);
        $instance  = $reflector->newInstanceArgs($params);

        if (empty($params)) {
            parent::__set($name, $instance);
        }

        return (clone $instance);
    }
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;
        }
    }
382408
private static function compareParameterClasses(\ReflectionParameter $a, \ReflectionParameter $b) : int
    {
        $a = $a->getClass();
        $b = $b->getClass();

        if ($a && $b) {
            return $a->isSubclassOf($b->name) ? -1 : (int) $b->isSubclassOf($a->name);
        }

        return (int) !$a - (int) !$b;
    }
1091764
public function handle(\ReflectionParameter $parameter)
    {
        $class = $parameter->getDeclaringClass();
        $className = $class->implementsInterface(WeavedInterface::class) ? $class->getParentClass()->getName() : $class->name;
        $method = $parameter->getDeclaringFunction()->name;
        $msg = sprintf('$%s in %s::%s()', $parameter->name, $className, $method);

        throw new ParameterException($msg, Code::BAD_REQUEST);
    }
591997
public function addParameters(Parameter ...$parameters): MutableQuery
    {
        $cloned = clone $this;

        $activeParameters = iterator_to_array($this->parameters);
        $activeParameters = array_merge($activeParameters, $parameters);

        $cloned->parameters = new ParameterCollection(...$activeParameters);

        return $cloned;
    }
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);
    }
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;
    }
768969
protected function replaceDefaults(array $parameters)
	{
		foreach ($parameters as $key => &$value)
		{
			$value = isset($value) ? $value : array_get($this->defaults, $key);
		}

		return $parameters;
	}
155143
public function setParameter($name, $parameter)
  {
    if ($this->isLocked()) {
      return $this->getObj()->setParameter($name, $parameter)->setLocked();
    } else {
      return parent::setParameter($name, $parameter);
    }
  }
1071614
public function getParameter($parameter, $default = null)
    {
        $value = $this->hasParameter($parameter) ? $this->container->getParameter($parameter) : null;

        return !is_null($value) ? $value : $default;
    }
1364471
public function addParameter(Parameter $parameter)
    {
        if (array_key_exists($parameter->getName(), $this->definitions)) {
            throw new \Exception(sprintf('Parameter with name \'%s\' already exists!', $parameter->getName()));
        }

        $this->definitions[$parameter->getName()] = $parameter;

        if ($parameter->getIsRequired()) {
            $this->required[] = $parameter->getName();
        }

        return $this;
    }
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 '';
        }
    }
1291403
private function makeParameters(array $parameters): array
    {
        return array_map(function (ReflectionParameter $parameter) {
            $class = $parameter->getClass();

            if ($class instanceof ReflectionClass) {
                return $this->make($class->getName());
            }

            if ($parameter->isDefaultValueAvailable()) {
                return $parameter->getDefaultValue();
            }

            return null;
        }, $parameters);
    }
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);
        }
    }
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);
    }