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

Breadcrumb

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

function ShowCommand::generatePackageTree

Generate the package tree

Return value

array<string, array<int, array<string, mixed[]|string>>|string|null>

1 call to ShowCommand::generatePackageTree()
ShowCommand::execute in vendor/composer/composer/src/Composer/Command/ShowCommand.php
Executes the current command.

File

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

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 generatePackageTree(PackageInterface $package, InstalledRepository $installedRepo, RepositoryInterface $remoteRepos) : array {
    $requires = $package->getRequires();
    ksort($requires);
    $children = [];
    foreach ($requires as $requireName => $require) {
        $packagesInTree = [
            $package->getName(),
            $requireName,
        ];
        $treeChildDesc = [
            'name' => $requireName,
            'version' => $require->getPrettyConstraint(),
        ];
        $deepChildren = $this->addTree($requireName, $require, $installedRepo, $remoteRepos, $packagesInTree);
        if ($deepChildren) {
            $treeChildDesc['requires'] = $deepChildren;
        }
        $children[] = $treeChildDesc;
    }
    $tree = [
        'name' => $package->getPrettyName(),
        'version' => $package->getPrettyVersion(),
        'description' => $package instanceof CompletePackageInterface ? $package->getDescription() : '',
    ];
    if ($children) {
        $tree['requires'] = $children;
    }
    return $tree;
}

API Navigation

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