From f70b3b01522394e918c764b33d8f56b6803da552 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 9 Apr 2020 16:25:10 +0200 Subject: [PATCH] Avoid warning about --2 usage when no channel is requested --- src/Composer/Command/SelfUpdateCommand.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Composer/Command/SelfUpdateCommand.php b/src/Composer/Command/SelfUpdateCommand.php index daaab2b97..9984f1547 100644 --- a/src/Composer/Command/SelfUpdateCommand.php +++ b/src/Composer/Command/SelfUpdateCommand.php @@ -84,8 +84,10 @@ EOT $versionsUtil = new Versions($config, $remoteFilesystem); // switch channel if requested + $requestedChannel = null; foreach (Versions::CHANNELS as $channel) { if ($input->getOption($channel)) { + $requestedChannel = $channel; $versionsUtil->setChannel($channel); break; } @@ -130,8 +132,8 @@ EOT $latestVersion = $latest['version']; $updateVersion = $input->getArgument('version') ?: $latestVersion; - if (is_numeric($channel) && substr($latestStable['version'], 0, 1) !== $channel) { - $io->writeError('Warning: You forced the install of '.$latestVersion.' via --'.$channel.', but '.$latestStable['version'].' is the latest stable version. Updating to it via composer self-update --stable is recommended.'); + if ($requestedChannel && is_numeric($requestedChannel) && substr($latestStable['version'], 0, 1) !== $requestedChannel) { + $io->writeError('Warning: You forced the install of '.$latestVersion.' via --'.$requestedChannel.', but '.$latestStable['version'].' is the latest stable version. Updating to it via composer self-update --stable is recommended.'); } if (preg_match('{^[0-9a-f]{40}$}', $updateVersion) && $updateVersion !== $latestVersion) {