From 1704466b74a0fb5d8e3b4dbb2db3a84cea702847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20B=C3=B6sing?= <2189546+boesing@users.noreply.github.com> Date: Thu, 3 Feb 2022 21:34:54 +0100 Subject: [PATCH] Add abandoned flag to show/outdated commands package lists (#10485) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To synchronize `abandoned` information with JSON APIs and the `composer.json` information of a package, we should return the following types: `bool|non-empty-string`. This will either state if a package is abandoned and, if there is a replacement declared, what replacement package should be used instead. Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com> --- src/Composer/Command/ShowCommand.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php index 5f89c0d86..27ff3d422 100644 --- a/src/Composer/Command/ShowCommand.php +++ b/src/Composer/Command/ShowCommand.php @@ -461,8 +461,10 @@ EOT $packageViewData['path'] = strtok(realpath($composer->getInstallationManager()->getInstallPath($package)), "\r\n"); } + $packageIsAbandoned = false; if ($latestPackage instanceof CompletePackageInterface && $latestPackage->isAbandoned()) { - $replacement = is_string($latestPackage->getReplacementPackage()) + $replacementPackageName = $latestPackage->getReplacementPackage(); + $replacement = $replacementPackageName !== null ? 'Use ' . $latestPackage->getReplacementPackage() . ' instead' : 'No replacement was suggested'; $packageWarning = sprintf( @@ -471,7 +473,10 @@ EOT $replacement ); $packageViewData['warning'] = $packageWarning; + $packageIsAbandoned = $replacementPackageName ?? true; } + + $packageViewData['abandoned'] = $packageIsAbandoned; } else { $packageViewData['name'] = $package; $nameLength = max($nameLength, strlen($package));