Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ShowCommand.php

function ShowCommand::displayTree

Display a package tree

Parameters

array<string, array<int, array<string, mixed[]|string>>|string|null>|string $package:

array<int, string|mixed[]> $packagesInTree:

1 call to ShowCommand::displayTree()
ShowCommand::displayPackageTree in vendor/composer/composer/src/Composer/Command/ShowCommand.php
Display the tree

File

vendor/composer/composer/src/Composer/Command/ShowCommand.php, line 1326

Class

ShowCommand
@author Robert Schönthal <seroscho@googlemail.com> @author Jordi Boggiano <j.boggiano@seld.be> @author Jérémy Romey <jeremyFreeAgent> @author Mihai Plasoianu <mihai@plasoianu.de>

Namespace

Composer\Command

Code

protected function displayTree($package, array $packagesInTree, string $previousTreeBar = '├', int $level = 1) : void {
    $previousTreeBar = str_replace('├', '│', $previousTreeBar);
    if (is_array($package) && 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];
            assert(is_string($require['name']));
            assert(is_string($require['version']));
            $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);
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal