From a03efa2fda39b4c924993631a8f139dd856fcb73 Mon Sep 17 00:00:00 2001 From: Arjan Date: Sat, 7 Oct 2017 16:45:15 +0200 Subject: [PATCH] Composer init - abandoned package warning Added warning for abandoned packages in case more than one package is found for require / require-dev in composer init. --- src/Composer/Command/InitCommand.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Composer/Command/InitCommand.php b/src/Composer/Command/InitCommand.php index aa7213060..4fdd7eab0 100644 --- a/src/Composer/Command/InitCommand.php +++ b/src/Composer/Command/InitCommand.php @@ -391,7 +391,17 @@ EOT $exactMatch = null; $choices = array(); foreach ($matches as $position => $foundPackage) { - $choices[] = sprintf(' %5s %s', "[$position]", $foundPackage['name']); + $abandoned = ''; + if (isset($foundPackage['abandoned'])) { + if (is_string($foundPackage['abandoned'])) { + $replacement = sprintf('Use %s instead', $foundPackage['abandoned']); + } else { + $replacement = 'No replacement was suggested'; + } + $abandoned = sprintf('Abandoned. %s.', $replacement); + } + + $choices[] = sprintf(' %5s %s %s',"[$position]", $foundPackage['name'], $abandoned); if ($foundPackage['name'] === $package) { $exactMatch = true; break;