function ShowCommand::printPackages
Parameters
array<array{name: string, direct-dependency?: bool, version?: string, latest?: string, latest-status?: string, description?: string|null, path?: string|null, source?: string|null, homepage?: string|null, warning?: string, abandoned?: bool|string}> $packages:
1 call to ShowCommand::printPackages()
- 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 720
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
private function printPackages(IOInterface $io, array $packages, string $indent, bool $writeVersion, bool $writeLatest, bool $writeDescription, int $width, int $versionLength, int $nameLength, int $latestLength, bool $writeReleaseDate, int $releaseDateLength) : void {
$padName = $writeVersion || $writeLatest || $writeReleaseDate || $writeDescription;
$padVersion = $writeLatest || $writeReleaseDate || $writeDescription;
$padLatest = $writeDescription || $writeReleaseDate;
$padReleaseDate = $writeDescription;
foreach ($packages as $package) {
$link = $package['source'] ?? $package['homepage'] ?? '';
if ($link !== '') {
$io->write($indent . '<href=' . OutputFormatter::escape($link) . '>' . $package['name'] . '</>' . str_repeat(' ', $padName ? $nameLength - strlen($package['name']) : 0), false);
}
else {
$io->write($indent . str_pad($package['name'], $padName ? $nameLength : 0, ' '), false);
}
if (isset($package['version']) && $writeVersion) {
$io->write(' ' . str_pad($package['version'], $padVersion ? $versionLength : 0, ' '), false);
}
if (isset($package['latest']) && isset($package['latest-status']) && $writeLatest) {
$latestVersion = $package['latest'];
$updateStatus = $package['latest-status'];
$style = $this->updateStatusToVersionStyle($updateStatus);
if (!$io->isDecorated()) {
$latestVersion = str_replace([
'up-to-date',
'semver-safe-update',
'update-possible',
], [
'=',
'!',
'~',
], $updateStatus) . ' ' . $latestVersion;
}
$io->write(' <' . $style . '>' . str_pad($latestVersion, $padLatest ? $latestLength : 0, ' ') . '</' . $style . '>', false);
if ($writeReleaseDate && isset($package['release-age'])) {
$io->write(' ' . str_pad($package['release-age'], $padReleaseDate ? $releaseDateLength : 0, ' '), false);
}
}
if (isset($package['description']) && $writeDescription) {
$description = strtok($package['description'], "\r\n");
$remaining = $width - $nameLength - $versionLength - $releaseDateLength - 4;
if ($writeLatest) {
$remaining -= $latestLength;
}
if (strlen($description) > $remaining) {
$description = substr($description, 0, $remaining - 3) . '...';
}
$io->write(' ' . $description, false);
}
if (array_key_exists('path', $package)) {
$io->write(' ' . (is_string($package['path']) ? $package['path'] : 'null'), false);
}
$io->write('');
if (isset($package['warning'])) {
$io->write('<warning>' . $package['warning'] . '</warning>');
}
}
}