Puli\Manager\Conflict\DependencyGraph::sortModulesDFS PHP Method

sortModulesDFS() private method

The resulting array is sorted such that all predecessors of the module come before the module (and their predecessors before them, and so on).
private sortModulesDFS ( string $currentName, array &$namesToSort, array &$output )
$currentName string The current module name to sort.
$namesToSort array The module names yet to be sorted.
$output array The output array.
    private function sortModulesDFS($currentName, array &$namesToSort, array &$output)
    {
        unset($namesToSort[$currentName]);
        // Before adding the module itself to the path, add all predecessors.
        // Do so recursively, then we make sure that each module is visited
        // in the path before any of its successors.
        foreach ($this->dependencies[$currentName] as $predecessor => $_) {
            // The module was already processed. Either the module is on the
            // path already, then we're good. Otherwise, we have a cycle.
            // However, addEdge() guarantees that the graph is cycle-free.
            if (isset($namesToSort[$predecessor])) {
                $this->sortModulesDFS($predecessor, $namesToSort, $output);
            }
        }
        $output[] = $currentName;
    }