function ShowCommand::addTree
Display a package tree
Parameters
string[] $packagesInTree:
Return value
array<int, array<string, array<int, array<string, string>>|string>>
1 call to ShowCommand::addTree()
- ShowCommand::generatePackageTree in vendor/
composer/ composer/ src/ Composer/ Command/ ShowCommand.php - Generate the package tree
File
-
vendor/
composer/ composer/ src/ Composer/ Command/ ShowCommand.php, line 1380
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\CommandCode
protected function addTree(string $name, Link $link, InstalledRepository $installedRepo, RepositoryInterface $remoteRepos, array $packagesInTree) : array {
$children = [];
[
$package,
] = $this->getPackage($installedRepo, $remoteRepos, $name, $link->getPrettyConstraint() === 'self.version' ? $link->getConstraint() : $link->getPrettyConstraint());
if (is_object($package)) {
$requires = $package->getRequires();
ksort($requires);
foreach ($requires as $requireName => $require) {
$currentTree = $packagesInTree;
$treeChildDesc = [
'name' => $requireName,
'version' => $require->getPrettyConstraint(),
];
if (!in_array($requireName, $currentTree, true)) {
$currentTree[] = $requireName;
$deepChildren = $this->addTree($requireName, $require, $installedRepo, $remoteRepos, $currentTree);
if ($deepChildren) {
$treeChildDesc['requires'] = $deepChildren;
}
}
$children[] = $treeChildDesc;
}
}
return $children;
}