From 0430722e66ddd461d6b1272484ef81ba81eee966 Mon Sep 17 00:00:00 2001 From: PrinsFrank <25006490+PrinsFrank@users.noreply.github.com> Date: Fri, 28 Oct 2022 09:11:55 +0200 Subject: [PATCH] Fix output inconsistencies when aliases are being used and '0 installs, 0 updates 0 removals' was being shown when any alias was present compared to 'Nothing to install, update or remove' when no alias is being used. (#11159) --- src/Composer/Installer.php | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 4c3062e9f..ee12fab89 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -751,22 +751,20 @@ class Installer $localRepoTransaction = new LocalRepoTransaction($lockedRepository, $localRepo); $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::PRE_OPERATIONS_EXEC, $this->devMode, $this->executeOperations, $localRepoTransaction); - if (!$localRepoTransaction->getOperations()) { - $this->io->writeError('Nothing to install, update or remove'); + $installs = $updates = $uninstalls = []; + foreach ($localRepoTransaction->getOperations() as $operation) { + if ($operation instanceof InstallOperation) { + $installs[] = $operation->getPackage()->getPrettyName().':'.$operation->getPackage()->getFullPrettyVersion(); + } elseif ($operation instanceof UpdateOperation) { + $updates[] = $operation->getTargetPackage()->getPrettyName().':'.$operation->getTargetPackage()->getFullPrettyVersion(); + } elseif ($operation instanceof UninstallOperation) { + $uninstalls[] = $operation->getPackage()->getPrettyName(); + } } - if ($localRepoTransaction->getOperations()) { - $installs = $updates = $uninstalls = []; - foreach ($localRepoTransaction->getOperations() as $operation) { - if ($operation instanceof InstallOperation) { - $installs[] = $operation->getPackage()->getPrettyName().':'.$operation->getPackage()->getFullPrettyVersion(); - } elseif ($operation instanceof UpdateOperation) { - $updates[] = $operation->getTargetPackage()->getPrettyName().':'.$operation->getTargetPackage()->getFullPrettyVersion(); - } elseif ($operation instanceof UninstallOperation) { - $uninstalls[] = $operation->getPackage()->getPrettyName(); - } - } - + if ($installs === [] && $updates === [] && $uninstalls === []) { + $this->io->writeError('Nothing to install, update or remove'); + } else { $this->io->writeError(sprintf( "Package operations: %d install%s, %d update%s, %d removal%s", count($installs),