Get the dependency for the given call parameter.

@param  \Illuminate\Container\Container  $container
@param  \ReflectionParameter  $parameter
@param  array  $parameters
@param  array  $dependencies
@return void
357393
protected static function addDependencyForCallParameter($container, $parameter,
                                                            array &$parameters, &$dependencies)
    {
        if (array_key_exists($parameter->name, $parameters)) {
            $dependencies[] = $parameters[$parameter->name];

            unset($parameters[$parameter->name]);
        } elseif ($parameter->getClass() && array_key_exists($parameter->getClass()->name, $parameters)) {
            $dependencies[] = $parameters[$parameter->getClass()->name];

            unset($parameters[$parameter->getClass()->name]);
        } elseif ($parameter->getClass()) {
            $dependencies[] = $container->make($parameter->getClass()->name);
        } elseif ($parameter->isDefaultValueAvailable()) {
            $dependencies[] = $parameter->getDefaultValue();
        }
    }
1280448
private function getArgumentByName(\ReflectionParameter $parameter, $parameters)
    {
        foreach ($parameters as $name => $item) {
            $paramName = $parameter->getName();
            if ($name === $paramName) {
                return $item;
            }
        }

        return null;
    }
828975
public function resolveMethodDependencies(array $parameters, ReflectionFunctionAbstract $reflector)
	{
		foreach ($reflector->getParameters() as $key => $parameter)
		{
			// 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.
			$class = $parameter->getClass();

			if ($class && ! $this->alreadyInParameters($class->name, $parameters))
			{
				array_splice(
					$parameters, $key, 0, [$this->container->make($class->name)]
				);
			}
		}

		return $parameters;
	}
891093
public function getDependencyInstance($dependencyName){
        if(isset($this->dependencies[$dependencyName])){
            return $this->loadDependency($dependencyName, $this->dependencies[$dependencyName]);
        }
        return null;
    }
507417
private function resolverClass($dependency, $arguments)
    {
        list($resolveClass, $reflectionParam) = $this->injector->getReflectionParam($dependency);

        // Application and Container cannot be injected into controller currently
        // since Application constructor is protected
        if ($reflectionParam->IsInstantiable()) {
            return $this->makeInstance($resolveClass, $arguments);
        }

        return $this->injector->interfaceInjection($reflectionParam);
    }
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 );
	}
674934
protected function transformDependency(ReflectionParameter $parameter, $parameters)
    {
        $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 (! is_null($class) && ! $this->alreadyInParameters($className = $class->name, $parameters)) {
            return $parameter->isDefaultValueAvailable()
                ? $parameter->getDefaultValue()
                : $this->container->make($className);
        }
    }
220148
public function dependsOn($dependencies)
    {
        if (is_array($dependencies)) {
            $this->dependencies = array_merge(
                $dependencies,
                $this->dependencies
            );
        } elseif (is_string($dependencies)) {
            $this->dependencies[] = $dependencies;
        } else {
            throw new LackOfCoffeeException(
                'Dependencies can either be an array of strings or a string'
            );
        }

        return $this;
    }
878414
protected function resolveClass(ReflectionParameter $parameter)
	{
		try
		{
			return $this->make($parameter->getClass()->name);
		}

		// If we can not resolve the class instance, we will check to see if the value
		// is optional, and if it is we will return the optional parameter value as
		// the value of the dependency, similarly to how we do this with scalars.
		catch (BindingResolutionException $e)
		{
			if ($parameter->isOptional())
			{
				return $parameter->getDefaultValue();
			}
			else
			{
				throw $e;
			}
		}
	}
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;
    }
1059988
protected function getDependencies($parameters)
	{
		$dependencies = array();

		foreach ($parameters as $parameter)
		{
			$dependency = $parameter->getClass();

			// If the class is null, it means the dependency is a string or some other
			// primitive type which we can not resolve since it is not a class and
			// we'll just bomb out with an error since we have no-where to go.
			if (is_null($dependency))
			{
				$dependencies[] = $this->resolveNonClass($parameter);
			}
			else
			{
				$dependencies[] = $this->resolveClass($parameter);
			}
		}

		return (array) $dependencies;
	}
946414
private function getDependencies(array $args, array &$arguments)
    {
        $objects = [];
        foreach ($arguments as $k => $v) {
            if (is_object($v)) {
                $objects[$k] = $v;
            }
        }

        $unShift = [];
        $args    = array_reverse($args);

        foreach ($args as $v) {
            $hasDefault = is_array($v);
            $dependency = $hasDefault ? $v[0] : $v;

            if ($objects) {
                $find = false;
                foreach ($objects as $k => $ins) {
                    if (! $ins instanceof $dependency) {
                        continue;
                    }

                    array_unshift($unShift, $ins);
                    unset($arguments[$k], $objects[$k]);

                    $find = true;
                    break;
                }

                if ($find) {
                    continue;
                }
            }

            $alias = $this->getDependencyAlias($dependency);
            if (! $alias) {
                if ($hasDefault) {
                    array_unshift($unShift, null);

                    continue;
                }

                throw new ContainerException("Unresolvable dependency resolving [{$dependency}]");
            }

            array_unshift($unShift, $this->get($alias));
        }
        unset($instance, $objects);

        $arguments = array_merge($unShift, $arguments);
        unset($unShift);
    }
1062730
function dependencyItems( $dependencySection, $parameters = false )
    {
        if ( !in_array( $dependencySection,
                        array( 'provides', 'requires',
                               'obsoletes', 'conflicts' ) ) )
            return false;

        if ( $parameters === false )
        {
            return $this->Parameters['dependencies'][$dependencySection];
        }

        $matches = array();
        $dependencyItems = $this->Parameters['dependencies'][$dependencySection];
        foreach ( $dependencyItems as $dependencyItem )
        {
            $found = true;

            foreach ( $parameters as $paramName => $paramValue )
            {
                if ( !isset( $dependencyItem[$paramName] ) ||
                     $dependencyItem[$paramName] != $paramValue )
                {
                    $found = false;
                    break;
                }
            }

            if ( $found )
                $matches[] = $dependencyItem;
        }

        return $matches;
    }
430415
protected function createMethodArgument(array $dependencies, array $arguments = []) : array
    {
        $args = [];
        foreach ($dependencies as $dependency) {
            if (!is_null($dependency->getClass())) {
                $args[] = $this->resolverClass($dependency, $arguments);
            } else {
                // Check if construct has default value then we will simply assign it into array
                // and continue for next argument
                if ($dependency->isDefaultValueAvailable()) {
                    $args[] = $this->injector->checkIfConstructorHasDefaultArgs($dependency, $arguments);
                    continue;
                }
                //Check if parameters are optional then we will set the default value
                $args[] = $this->injector->isOptionalArgs($dependency);
            }
        }

        return $args;
    }
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);
    }
863554
private function resolveClassParameter(
        \ReflectionClass $class,
        \ReflectionParameter $dependency
    ) {
        try {
            return $this->get($class->getName());
        } catch (\InvalidArgumentException $e) {
            if (!$dependency->isDefaultValueAvailable()) {
                throw $e;
            }
        }

        return $dependency->getDefaultValue();
    }
1123646
private function resolvePrimitiveParameter(\ReflectionParameter $dependency)
    {
        if ($dependency->isDefaultValueAvailable()) {
            return $dependency->getDefaultValue();
        }

        $class         = $dependency->getDeclaringClass()->getName();
        $method        = $dependency->getDeclaringFunction()->getName();
        $parameterName = $dependency->getName();

        throw new \OutOfBoundsException("Parameter {$parameterName} is not supplied for {$class}::{$method}.");
    }