This method is used to find out the arguments required for
the constructor or any method and returns array of arguments.

@param array $dependencies
@param array $arguments
@return array
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;
    }
1068051
private function assembleConstructorArgs()
    {
        $params = $this->getConstructorArgs();
        $args = [];
        $givenParams = array_keys($this->parameters);
        foreach ($params as $param) {
            if (in_array($param->getName(), $givenParams)) {
                $args[] = $this->parameters[$param->getName()];
            } else {
                $paramClass = $param->getClass();
                if ($paramClass == null) {
                    throw new \Exception('Missing constructor argument '.$param->getName());
                }
                $paramClass = $paramClass->getName();
                foreach ($this->dependencies as $dependency) {
                    if ($dependency->isInstanceOf($paramClass)) {
                        $args[] = $dependency->getInstance();
                        break;
                    }
                }
            }
        }
        return $args;
    }
1272618
protected function resolveDependencies( array $dependencies )
	{
		$results = [];

		foreach( $dependencies as $dependency ) {
			// If the class is null, the dependency is a string or some other primitive type
			$results[] = !is_null( $class = $dependency->getClass() )
				? $this->resolveClass( $dependency )
				: null;
		}

		return $results;
	}
61819
public function setDependencies(array $dependencies)
    {
        $this->dependencies = [];

        foreach ($dependencies as $dependency) {
            if (!($dependency instanceof ModuleInterface)) {
                throw new InvalidParamException('Dependency must implement ModuleInterface');
            }

            $this->dependencies[] = $dependency;
        }

        return $this;
    }
156229
private function getDefinitionsFromArguments(array $arguments)
    {
        $definitions = array();
        foreach ($arguments as $argument) {
            if (is_array($argument)) {
                $definitions = array_merge($definitions, $this->getDefinitionsFromArguments($argument));
            } elseif ($argument instanceof Definition) {
                $definitions = array_merge(
                    $definitions,
                    $this->getInlinedDefinitions($argument),
                    array($argument)
                );
            }
        }

        return $definitions;
    }
623806
public static function prepare_for_javascript($dependencies) {
        $result = [];
        foreach ($dependencies as $d) {
            if (!isset($result[$d->dependenton])) {
                $result[$d->dependenton] = [];
            }
            if (!isset($result[$d->dependenton][$d->condition])) {
                $result[$d->dependenton][$d->condition] = [];
            }
            if (!isset($result[$d->dependenton][$d->condition][$d->value])) {
                $result[$d->dependenton][$d->condition][$d->value] = [];
            }
            $result[$d->dependenton][$d->condition][$d->value][] = $d->settingname;
        }
        return $result;
    }
310195
private function getDependencies(array $results)
    {
        $dependencies = [];
        $doubles = [];

        foreach ($results as $name => $result) {
            $type = $this->recursive ? Dependency::PROHIBITS : Dependency::DEPENDS;
            $dependency = Dependency::create($name, $type, $result);
            $unique = (string) $dependency->getLink();
            if (isset($doubles[$unique])) {
                continue;
            }
            $doubles[$unique] = true;
            $dependencies[] = $dependency;
        }

        return $dependencies;
    }
169554
public static String[] getArrayOfVersions(Map< String, Dependency> dependencies) {
        List<String> versionList = new LinkedList<String>();

        for (Dependency dependency : dependencies.values()) {
            versionList.add(dependency.getVersion());
        }

        return versionList.toArray(new String[versionList.size()]);
    }
874829
public function setDependencies($dependencies)
    {
        if(!is_array($dependencies))
            $dependencies = array($dependencies);

        $this->setProperty('dependencies', $dependencies);

        return $this;
	}
37415
private static function getArguments(array $arguments = [])
    {
        $args = [];

        foreach ($arguments as $argument) {
            $args[] = $argument instanceof self ? $argument->getMoney() : $argument;
        }

        return $args;
    }
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;
    }
949214
protected function buildUrlRequirements(array &$arguments)
    {
        $url = [];
        foreach ($this->requirements as $key => $regex) {
            $this->assertArgumentRequirement($key, $regex, $arguments);

            if (array_key_exists($key, $arguments) && isset($this->builders['segments']['{' . $key . '}'])) {
                $this->assertArgumentValue($key, $regex, $arguments[$key]);
                $url['{' . $key . '}'] = str_replace('{value}', $this->strip($arguments[$key]), $this->builders['segments']['{' . $key . '}']);
            } else {
                $url['{' . $key . '}'] = substr($this->requirements[$key], -1) == '+' && isset($this->arguments[$key]) ? $this->arguments[$key] : null;
            }

            unset($arguments[$key]);
        }

        return $url;
    }
469193
public function dispatchRequirements($dependencies, $parameters) {
		$dispatches = [];

		foreach ($dependencies as $dependency) {
			list($name, $instance) = $this->extractDependency($dependency, $parameters);

			$dispatches[$name] = $instance;
		}

		return $dispatches;
	}
493280
protected function getDependencies(\ReflectionMethod $method)
    {
        $dependencies = array();

        foreach ($method->getParameters() as $param) {
            $dependency = $param->getClass();

            if (is_null($dependency)) {
                if ($param->isOptional()) {
                    $dependencies[] = $param->getDefaultValue();
                    continue;
                }
            } else {
                $dependencies[] = $this->resolve($dependency->name);
                continue;
            }

            throw new \InvalidArgumentException('Could not resolve ' . $param->getName());
        }

        return $dependencies;
    }
241924
protected function checkDependency($dependencies = null)
    {
        $errors = array();

        if (is_null($dependencies)) $dependencies = array();

        $i = 0;
        $clean = true;
        foreach ($dependencies as $module => $version)
        {
            if ($module == $this->systemName)
            {
                if (!$this->sysVersionDependency($version))
                    $clean = false;

                continue;
            }

            $depModule = ModuleModel::where('module_name', $module)->first();
            if (!$depModule)
            {
                $this->errors->add("module_dependency_$i", "Module $module with version $version not installed");
                $clean = false;
            }
            else
            {
                $depVersion = $depModule->module_version;
                $needVersion = $version;

                $depVersion = new Version($depVersion);
                $needVersion = new Version($needVersion);

                if (!$depVersion->isPartOf($needVersion))
                {
                    $this->errors->add("module_dependency_$i", 'Module '.$module.' v'.$needVersion->getVersion().' must install, but '.$depVersion->getVersion().' installed.');
                    $clean = false;
                }
            }
            $i++;
        }

        if(!$clean)
            return false;

        return true;
    }
374810
protected function applyDependencies($sources, \Traversable $dependencies, callable $insert)
    {
        foreach ($dependencies as $query => $subDependencies) {
            $joinedCode = '';
            foreach ($subDependencies as $file) {
                $joinedCode .= $insert($file);
            }
            $sources = str_replace($query, $joinedCode, $sources);
        }

        return $sources;
    }
1146579
public function call($callback, $arguments = [])
    {
        $dependencies = $this->getMethodDependencies($callback, $arguments);

        return call_user_func_array($callback, $dependencies);
    }