function ShowCommand::printVersions
Prints all available versions of this package and highlights the installed one if any.
Parameters
array<string, string> $versions:
1 call to ShowCommand::printVersions()
- ShowCommand::printMeta in vendor/
composer/ composer/ src/ Composer/ Command/ ShowCommand.php - Prints package metadata.
File
-
vendor/
composer/ composer/ src/ Composer/ Command/ ShowCommand.php, line 956
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 printVersions(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo) : void {
$versions = array_keys($versions);
$versions = Semver::rsort($versions);
// highlight installed version
if ($installedPackages = $installedRepo->findPackages($package->getName())) {
foreach ($installedPackages as $installedPackage) {
$installedVersion = $installedPackage->getPrettyVersion();
$key = array_search($installedVersion, $versions);
if (false !== $key) {
$versions[$key] = '<info>* ' . $installedVersion . '</info>';
}
}
}
$versions = implode(', ', $versions);
$this->getIO()
->write('<info>versions</info> : ' . $versions);
}