Parses the typehints out of input and return the dependencies based on it as array.

@author Benjamin Carl <opensource@clickalicious.de>

@return array Containing the dependencies build from typehints

@throws Doozr_Di_Exception
501653
public function parse()
    {
        // check if all requirements are fulfilled
        if (!$this->requirementsFulfilled()) {
            throw new Doozr_Di_Exception(
                'Error parsing constructor. Requirements not fulfilled. Please set input to parse constructor from.'
            );
        }

        // prepare input for parser
        $this->prepareInput();

        // if called from outside we maybe need a new instance of reflection
        if (!class_exists($this->input['className']) && !$this->input['reflection']) {
            throw new Doozr_Di_Exception(
                'Could not parse constructor! Please define at least a "file" which contains the className '.
                'or an existing ReflectionClass instance'
            );
        }

        // get reflection if not already passed to this method
        if (!$this->input['reflection']) {
            $reflectionClass = new ReflectionClass($this->input['className']);
        }

        // get filename of className
        if (!isset($this->input['file'])) {
            $this->input['file'] = $reflectionClass->getFileName();
        }

        // read the file as array
        $sourcecode = file($this->input['file']);

        // return the result
        return $this->parseTypehints($reflectionClass, $sourcecode);
    }
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;
	}
812062
protected function init_dependency_type( $type ) {
		$array = [ ];
		$data  = $this->getConfigKey( $type );
		foreach ( $data as $dependency ) {
			$handle           = array_key_exists( 'handle',
				$dependency ) ? $dependency['handle'] : '';
			$array[ $handle ] = $dependency;
		}
		return $array;
	}
383183
private List<CompilerInput> getDepthFirstDependenciesOf(
      CompilerInput rootInput,
      Set<CompilerInput> unreachedInputs,
      Map<String, CompilerInput> inputsByProvide) {
    List<CompilerInput> orderedInputs = new ArrayList<>();
    if (!unreachedInputs.remove(rootInput)) {
      return orderedInputs;
    }

    for (String importedNamespace : rootInput.getRequiredSymbols()) {
      CompilerInput dependency = null;
      if (inputsByProvide.containsKey(importedNamespace)
          && unreachedInputs.contains(inputsByProvide.get(importedNamespace))) {
        dependency = inputsByProvide.get(importedNamespace);
      }

      if (dependency != null) {
        orderedInputs.addAll(
            getDepthFirstDependenciesOf(dependency, unreachedInputs, inputsByProvide));
      }
    }

    orderedInputs.add(rootInput);
    return orderedInputs;
  }
1109301
public function getDependencies(): array
    {
        $dependencies = [];
        foreach ($this->config['dependencies'] as $dependency) {
            $dependencies[] = $this->wire($dependency);
        }

        return $dependencies;
    }
227093
public DependencyId[] getDependencyIds(){
		DependencyId[] depIds = new DependencyId[configEntry.dependencyIds.length];
		for ( int i=0; i<configEntry.dependencyIds.length; i++ ){
			depIds[i] = new DependencyId(configEntry.dependencyIds[i]);
		}
		return depIds;
	}
1007918
protected function getDependencies()
    {
        if (null === $this->dependencies) {
            if (file_exists(sprintf('%s/dependencies.json', $this->paths->getThemeConfigDir()))) {
                $depsContent = file_get_contents(sprintf('%s/dependencies.json', $this->paths->getThemeConfigDir()));
            } else {
                $depsContent = file_get_contents(sprintf('%s/dependencies.json', $this->paths->getBaseConfigDir()));
            }
            $this->dependencies = json_decode($depsContent, true);
        }

        return $this->dependencies;
    }
163949
public Set<SourceFile> getDependencies() {

		Set<SourceFile> sourceFiles = new TreeSet<SourceFile>();

		// Include all of the standard dependencies.
		for (Template t : dependencies.values()) {
			sourceFiles.add(t.sourceFile);
		}

		// Add the files that were looked-up but not found as well as the files
		// included via the file_contents() function.
		sourceFiles.addAll(otherDependencies);

		return Collections.unmodifiableSet(sourceFiles);
	}
229736
public function getRequiredPackages()
    {
        $packages = [];

        $content = $this->getFileContents('composer.json');

        foreach (['require', 'require-dev'] as $key) {
            if (!isset($content[$key])) {
                continue;
            }

            foreach ($content[$key] as $name => $version) {
                if (!strstr($name, '/')) {
                    continue;
                }

                $packages[$name] = [
                    'name' => $name,
                    'version' => $version,
                    'devDependency' => $key === 'require-dev',
                ];
            }
        }

        if (empty($packages)) {
            throw new LogicException('We couldn\'t find any required packages.');
        }

        return $packages;
    }
1320696
public function getDependsInfo()
    {
        $dependsInfo = $this->getCachedValue('dependsInfo');
        if ($dependsInfo === false) {

            $data = $this->dataProvider->getData();

            $dependsInfo = array();

            foreach ($this->getPackageSortOrder() as $packageId => $order) {
                if (!isset($data[$packageId])) {
                    continue;
                }

                $provides = $this->getProvidesForPackage($packageId);
                foreach ($provides as $file => $fileInfo) {
                    if (!isset($dependsInfo[$file])) {
                        $dependsInfo[$file] = array();
                    }
                    if (isset($fileInfo['Depends'])) {
                        $dependsInfo[$file] = array_merge(
                            $dependsInfo[$file],
                            $fileInfo['Depends']
                        );
                    }
                    // TODO: some day we could treat optional-depends
                    // differently
                    if (isset($fileInfo['OptionalDepends'])) {
                        $dependsInfo[$file] = array_merge(
                            $dependsInfo[$file],
                            $fileInfo['OptionalDepends']
                        );
                    }
                }
            }

            $this->setCachedValue('dependsInfo', $dependsInfo);
        }

        return $dependsInfo;
    }
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;
    }
993962
private function orderInstallersByDependencies()
    {
        $sequenceForClasses = [];

        // If installers were already ordered by number then we need
        // to remove classes which are not instances of OrderedInstallerInterface
        // in case installers implementing DependentInstallerInterface exist.
        // This is because, in that case, the method orderInstallersByDependencies
        // will handle all installers which are not instances of
        // OrderedInstallerInterface
        if ($this->orderInstallersByNumber) {
            $count = count($this->orderedInstallers);

            for ($i = 0; $i < $count; ++$i) {
                if (!($this->orderedInstallers[$i] instanceof OrderedInstallerInterface)) {
                    unset($this->orderedInstallers[$i]);
                }
            }
        }

        // First we determine which classes has dependencies and which don't
        foreach ($this->installers as $installer) {
            $installerClass = get_class($installer);

            if ($installer instanceof OrderedInstallerInterface) {
                continue;
            } elseif ($installer instanceof DependentInstallerInterface) {
                $dependenciesClasses = $installer->getDependencies();

                $this->validateDependencies($dependenciesClasses);

                if (!is_array($dependenciesClasses) || empty($dependenciesClasses)) {
                    throw new \InvalidArgumentException(sprintf(
                        'Method "%s" in class "%s" must return an array of classes which are '.
                            'dependencies for the installer, and it must be NOT empty.',
                        'getDependencies',
                        $installerClass
                    ));
                }

                if (in_array($installerClass, $dependenciesClasses)) {
                    throw new \InvalidArgumentException(sprintf(
                        'Class "%s" can\'t have itself as a dependency',
                        $installerClass
                    ));
                }

                // We mark this class as unsequenced
                $sequenceForClasses[$installerClass] = -1;
            } else {
                // This class has no dependencies, so we assign 0
                $sequenceForClasses[$installerClass] = 0;
            }
        }

        // Now we order installers by sequence
        $sequence = 1;
        $lastCount = -1;

        while (($count = count($unsequencedClasses = $this->getUnsequencedClasses($sequenceForClasses))) > 0
                && $count !== $lastCount) {
            foreach ($unsequencedClasses as $key => $class) {
                /** @var DependentInstallerInterface $installer */
                $installer = $this->installers[$class];
                $dependencies = $installer->getDependencies();
                $unsequencedDependencies = $this->getUnsequencedClasses($sequenceForClasses, $dependencies);

                if (count($unsequencedDependencies) === 0) {
                    $sequenceForClasses[$class] = $sequence++;
                }
            }

            $lastCount = $count;
        }

        $orderedInstallers = [];

        // If there are installers unsequenced left and they couldn't be sequenced,
        // it means we have a circular reference
        if ($count > 0) {
            $msg = 'Classes "%s" have produced a circular reference exception. ';
            $msg .= 'An example of this problem would be the following: Class C has class B as its dependency. ';
            $msg .= 'Then, class B has class A has its dependency. Finally, class A has class C as its dependency. ';
            $msg .= 'This case would produce a circular reference exception.';

            throw new \RuntimeException(sprintf($msg, implode(',', $unsequencedClasses)));
        } else {
            // We order the classes by sequence
            asort($sequenceForClasses);

            foreach ($sequenceForClasses as $class => $sequence) {
                // If installers were ordered
                $orderedInstallers[] = $this->installers[$class];
            }
        }

        $this->orderedInstallers = array_merge($this->orderedInstallers, $orderedInstallers);
    }
699846
public function getDependencyPhpExtensions()
    {
        if (is_array($this->_dependencyPhpExtensions)) return $this->_dependencyPhpExtensions;
        $this->_dependencyPhpExtensions = array();
        if (!isset($this->_packageXml->dependencies->required->extension)) {
            return $this->_dependencyPhpExtensions;
        }
        foreach($this->_packageXml->dependencies->required->extension as $_package) {
            $this->_dependencyPhpExtensions[] = array(
                'name'    => (string)$_package->name,
                'min'     => (string)$_package->min,
                'max'     => (string)$_package->max,
            );
        }
        return $this->_dependencyPhpExtensions;
    }
62777
public String jsComponentDependencies() {

        List<CmsSetupComponent> components = CmsCollectionsGenericWrapper.list(m_components.elementList());
        Map<String, List<String>> componentDependencies = buildDepsForAllComponents();

        StringBuffer jsCode = new StringBuffer(1024);
        jsCode.append("\t// an array holding the dependent components for the n-th component\n");
        jsCode.append("\tvar componentDependencies = new Array(");
        jsCode.append(components.size());
        jsCode.append(");\n");
        for (int i = 0; i < components.size(); i++) {
            CmsSetupComponent component = components.get(i);
            List<String> dependencies = componentDependencies.get(component.getId());
            jsCode.append("\tcomponentDependencies[" + i + "] = new Array(");
            if (dependencies != null) {
                for (int j = 0; j < dependencies.size(); j++) {
                    jsCode.append("\"" + dependencies.get(j) + "\"");
                    if (j < (dependencies.size() - 1)) {
                        jsCode.append(", ");
                    }
                }
            }
            jsCode.append(");\n");
        }
        jsCode.append("\n\n");
        return jsCode.toString();
    }
825081
public List<TypedDependency> getStanfordTypedDependencies(DependencyForm form) {
        List<TypedDependency> dependencies = new ArrayList<TypedDependency>();
        if (this.nodes == null)
        	nodes = getStanfordTreeGraphNodes(form);

        List<AgigaTypedDependency> agigaDeps = getAgigaDeps(form);
        for (AgigaTypedDependency agigaDep : agigaDeps) {
            // Add one, since the tokens are zero-indexed but the TreeGraphNodes are one-indexed
            TreeGraphNode gov = nodes.get(agigaDep.getGovIdx() + 1);
            TreeGraphNode dep = nodes.get(agigaDep.getDepIdx() + 1);
            // Create the typed dependency
            TypedDependency typedDep = new TypedDependency(GrammaticalRelation.valueOf(agigaDep.getType()), gov, dep);
            dependencies.add(typedDep);
        }
        return dependencies;
    }
241467
public static List<DependencyInfo> readDependencies(InputStream in) throws IOException {
        try (InputStreamReader inputStreamReader = new InputStreamReader(in, UTF_8);
             BufferedReader br = new BufferedReader(inputStreamReader);
             JsonReader reader = new JsonReader(br)) {
            return getDependencies(reader);
        } catch (IOException ex) {
            logger.error("Failed to read dependencies: {}", ex.getMessage());
        }
        return null;
    }
1212201
protected function resolveDependencies(array $dependencies)
    {
        $results = [];

        foreach ($dependencies as $dependency) {
            // If this dependency has a override for this particular build we will use
            // that instead as the value. Otherwise, we will continue with this run
            // of resolutions and let reflection attempt to determine the result.
            if ($this->hasParameterOverride($dependency)) {
                $results[] = $this->getParameterOverride($dependency);

                continue;
            }

            // 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 will just bomb out with an error since we have no-where to go.
            $results[] = is_null($dependency->getClass())
                            ? $this->resolvePrimitive($dependency)
                            : $this->resolveClass($dependency);
        }

        return $results;
    }