src/Composer/Command/ShowCommand.php
protected function displayTree(
        $package,
        array $packagesInTree,
        $previousTreeBar = '├',
        $level = 1
    ) {
        $previousTreeBar = str_replace('├', '│', $previousTreeBar);
        if (isset($package['requires'])) {
            $requires = $package['requires'];
            $treeBar = $previousTreeBar . '  ├';
            $i = 0;
            $total = count($requires);
            foreach ($requires as $require) {
                $currentTree = $packagesInTree;
                $i++;
                if ($i === $total) {
                    $treeBar = $previousTreeBar . '  └';
                }
                $colorIdent = $level % count($this->colors);
                $color = $this->colors[$colorIdent];

                $circularWarn = in_array(
                    $require['name'],
                    $currentTree,
                    true
                ) ? '(circular dependency aborted here)' : '';
                $info = rtrim(sprintf(
                    '%s──<%s>%s</%s> %s %s',
                    $treeBar,
                    $color,
                    $require['name'],
                    $color,
                    $require['version'],
                    $circularWarn
                ));
                $this->writeTreeLine($info);

                $treeBar = str_replace('└', ' ', $treeBar);

                $currentTree[] = $require['name'];
                $this->displayTree($require, $currentTree, $treeBar, $level + 1);
            }
        }
    }
protected function displayTree(
        $package,
        array $packagesInTree,
        $previousTreeBar = '├',
        $level = 1
    ) {
        $previousTreeBar = str_replace('├', '│', $previousTreeBar);
        if (isset($package['requires'])) {
            $requires = $package['requires'];
            $treeBar = $previousTreeBar . '  ├';
            $i = 0;
            $total = count($requires);
            foreach ($requires as $require) {
                $currentTree = $packagesInTree;
                $i++;
                if ($i === $total) {
                    $treeBar = $previousTreeBar . '  └';
                }
                $colorIdent = $level % count($this->colors);
                $color = $this->colors[$colorIdent];

                $circularWarn = in_array(
                    $require['name'],
                    $currentTree,
                    true
                ) ? '(circular dependency aborted here)' : '';
                $info = rtrim(sprintf(
                    '%s──<%s>%s</%s> %s %s',
                    $treeBar,
                    $color,
                    $require['name'],
                    $color,
                    $require['version'],
                    $circularWarn
                ));
                $this->writeTreeLine($info);

                $treeBar = str_replace('└', ' ', $treeBar);

                $currentTree[] = $require['name'];
                $this->displayTree($require, $currentTree, $treeBar, $level + 1);
            }
        }
    }
protected function displayTree ( $ package , array $ packagesInTree , $ previousTreeBar = '├', $ level = 1 ) { $ previousTreeBar = str_replace ( '├',  ' ', $p r v iousTreeBar); if ( isset ( $ package [ 'requires' ] ) ) { $ requires = $ package [ 'requires' ] ; $ treeBar = $ previousTreeBar . '  ├'; $ i = 0 ; $ total = count ( $ requires ) ; foreach ( $ requires as $ require ) { $ currentTree = $ packagesInTree ; $ i ++ ; if ( $ i === $ total ) { $ treeBar = $ previousTreeBar . '  └'; } $ colorIdent = $ level % count ( $ this -> colors ) ; $ color = $ this -> colors [ $ colorIdent ] ; $ circularWarn = in_array ( $ require [ 'name' ] , $ currentTree , true ) ? '(circular dependency aborted here)' : '' ; $ info = rtrim ( sprintf ( '%s──<%s>%s</%s> %s %s', $ treeBar , $ color , $ require [ 'name' ] , $ color , $ require [ 'version' ] , $ circularWarn ) ) ; $ this -> writeTreeLine ( $ info ) ; $ treeBar = str_replace ( '└',  ' ',  $ r eeBar); $ currentTree [ ] = $ require [ 'name' ] ; $ this -> displayTree ( $ require , $ currentTree , $ treeBar , $ level + 1 ) ; } } }
Display a package tree

@param PackageInterface|string $package
@param array                   $packagesInTree
@param string                  $previousTreeBar
@param int                     $level
Display a package tree