From 46cc3875982a32383f610273e2d6dbd7d34f8268 Mon Sep 17 00:00:00 2001 From: username Date: Sat, 29 Aug 2020 21:12:07 +0200 Subject: [PATCH 01/11] Split workflows --- src/Composer/Command/ShowCommand.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php index 635d56bf3..e988cd2f5 100644 --- a/src/Composer/Command/ShowCommand.php +++ b/src/Composer/Command/ShowCommand.php @@ -423,7 +423,9 @@ EOT $packageIsIgnored = \in_array($package->getPrettyName(), $ignoredPackages, true); if ($input->getOption('outdated') && ($packageIsUpToDate || $packageIsIgnored)) { continue; - } elseif ($input->getOption('outdated') || $input->getOption('strict')) { + } + + if ($input->getOption('outdated') || $input->getOption('strict')) { $hasOutdatedPackages = true; } From 3f09ae07370a446ba2f3fb405d21187831a15c5a Mon Sep 17 00:00:00 2001 From: username Date: Sat, 29 Aug 2020 21:13:54 +0200 Subject: [PATCH 02/11] Simplify duplicate case --- src/Composer/Command/ShowCommand.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php index e988cd2f5..68a8fa69f 100644 --- a/src/Composer/Command/ShowCommand.php +++ b/src/Composer/Command/ShowCommand.php @@ -681,11 +681,7 @@ EOT foreach ($package->getAutoload() as $type => $autoloads) { $io->write('' . $type . ''); - if ($type === 'psr-0') { - foreach ($autoloads as $name => $path) { - $io->write(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.'))); - } - } elseif ($type === 'psr-4') { + if ($type === 'psr-0' || $type === 'psr-4') { foreach ($autoloads as $name => $path) { $io->write(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.'))); } From 459e2473c8a8a84318256128223cd53b72168c29 Mon Sep 17 00:00:00 2001 From: username Date: Sat, 29 Aug 2020 21:15:15 +0200 Subject: [PATCH 03/11] Remove unused variable --- src/Composer/Command/StatusCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Command/StatusCommand.php b/src/Composer/Command/StatusCommand.php index e4de749f1..45affa9e5 100644 --- a/src/Composer/Command/StatusCommand.php +++ b/src/Composer/Command/StatusCommand.php @@ -121,7 +121,7 @@ EOT } if ($downloader instanceof VcsCapableDownloaderInterface) { - if ($currentRef = $downloader->getVcsReference($package, $targetDir)) { + if ($downloader->getVcsReference($package, $targetDir)) { switch ($package->getInstallationSource()) { case 'source': $previousRef = $package->getSourceReference(); From e719be501ecf30944fd62b172b2ef1811d42fbbf Mon Sep 17 00:00:00 2001 From: username Date: Sat, 29 Aug 2020 21:15:52 +0200 Subject: [PATCH 04/11] Remove unnecessary method call --- src/Composer/Command/SuggestsCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Command/SuggestsCommand.php b/src/Composer/Command/SuggestsCommand.php index d874d1d19..cb1f4e9a6 100644 --- a/src/Composer/Command/SuggestsCommand.php +++ b/src/Composer/Command/SuggestsCommand.php @@ -83,7 +83,7 @@ EOT // Determine output mode, default is by-package $mode = SuggestedPackagesReporter::MODE_BY_PACKAGE; - $io = $this->getIO(); + // if by-suggestion is given we override the default if ($input->getOption('by-suggestion')) { $mode = SuggestedPackagesReporter::MODE_BY_SUGGESTION; From 18009af023071abc7d179e6280661fadee390e53 Mon Sep 17 00:00:00 2001 From: username Date: Sat, 29 Aug 2020 21:16:58 +0200 Subject: [PATCH 05/11] Inline variable --- src/Composer/Command/ValidateCommand.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Composer/Command/ValidateCommand.php b/src/Composer/Command/ValidateCommand.php index 1c76d678d..128064f8e 100644 --- a/src/Composer/Command/ValidateCommand.php +++ b/src/Composer/Command/ValidateCommand.php @@ -122,9 +122,8 @@ EOT $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'validate', $input, $output); $eventCode = $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent); - $exitCode = max($eventCode, $exitCode); - return $exitCode; + return max($eventCode, $exitCode); } private function outputResult($io, $name, &$errors, &$warnings, $checkPublish = false, $publishErrors = array(), $checkLock = false, $lockErrors = array(), $printSchemaUrl = false) From 17ae93bc9c5b1fb9f0d94bd8e1b1ec1e0f5bf0bf Mon Sep 17 00:00:00 2001 From: username Date: Sat, 29 Aug 2020 21:18:31 +0200 Subject: [PATCH 06/11] Remove unnecessary method call --- src/Composer/Command/CheckPlatformReqsCommand.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Composer/Command/CheckPlatformReqsCommand.php b/src/Composer/Command/CheckPlatformReqsCommand.php index c80884444..12b491786 100644 --- a/src/Composer/Command/CheckPlatformReqsCommand.php +++ b/src/Composer/Command/CheckPlatformReqsCommand.php @@ -51,7 +51,6 @@ EOT $requires = array(); if ($input->getOption('no-dev')) { $installedRepo = $composer->getLocker()->getLockedRepository(!$input->getOption('no-dev')); - $dependencies = $installedRepo->getPackages(); } else { $installedRepo = $composer->getRepositoryManager()->getLocalRepository(); // fallback to lockfile if installed repo is empty From abedc0dc4250d3c48a55ee3547e5c8ae357c1a3a Mon Sep 17 00:00:00 2001 From: username Date: Sat, 29 Aug 2020 21:19:20 +0200 Subject: [PATCH 07/11] Sort conditions by cost --- src/Composer/Command/ConfigCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Command/ConfigCommand.php b/src/Composer/Command/ConfigCommand.php index 099e5c872..518bb7ff3 100644 --- a/src/Composer/Command/ConfigCommand.php +++ b/src/Composer/Command/ConfigCommand.php @@ -291,7 +291,7 @@ EOT $value = $data; } elseif (isset($data['config'][$settingKey])) { $value = $this->config->get($settingKey, $input->getOption('absolute') ? 0 : Config::RELATIVE_PATHS); - } elseif (in_array($settingKey, $properties, true) && isset($rawData[$settingKey])) { + } elseif (isset($rawData[$settingKey]) && in_array($settingKey, $properties, true)) { $value = $rawData[$settingKey]; } else { throw new \RuntimeException($settingKey.' is not defined'); From 98462292c07d08c196e3ddcdaa99ca81913b24bc Mon Sep 17 00:00:00 2001 From: username Date: Sat, 29 Aug 2020 21:19:52 +0200 Subject: [PATCH 08/11] Sort conditions by cost --- src/Composer/Command/ConfigCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Command/ConfigCommand.php b/src/Composer/Command/ConfigCommand.php index 518bb7ff3..f4ae9c72a 100644 --- a/src/Composer/Command/ConfigCommand.php +++ b/src/Composer/Command/ConfigCommand.php @@ -474,7 +474,7 @@ EOT ), ); - if ($input->getOption('unset') && (isset($uniqueConfigValues[$settingKey]) || isset($multiConfigValues[$settingKey]))) { + if ((isset($uniqueConfigValues[$settingKey]) || isset($multiConfigValues[$settingKey])) && $input->getOption('unset')) { if ($settingKey === 'disable-tls' && $this->config->get('disable-tls')) { $this->getIO()->writeError('You are now running Composer with SSL/TLS protection enabled.'); } From 113adbcd8724d6cfc1d47a0a1486ccd4a37a8a95 Mon Sep 17 00:00:00 2001 From: username Date: Sat, 29 Aug 2020 21:20:30 +0200 Subject: [PATCH 09/11] Sort conditions by cost --- src/Composer/Command/ConfigCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Command/ConfigCommand.php b/src/Composer/Command/ConfigCommand.php index f4ae9c72a..69692c0e2 100644 --- a/src/Composer/Command/ConfigCommand.php +++ b/src/Composer/Command/ConfigCommand.php @@ -568,7 +568,7 @@ EOT if ($input->getOption('global') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]) || substr($settingKey, 0, 6) === 'extra.')) { throw new \InvalidArgumentException('The '.$settingKey.' property can not be set in the global config.json file. Use `composer global config` to apply changes to the global composer.json'); } - if ($input->getOption('unset') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]))) { + if ((isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey])) && $input->getOption('unset')) { $this->configSource->removeProperty($settingKey); return 0; From fc87caf63974e347dd208d00ffb0be942b4cc198 Mon Sep 17 00:00:00 2001 From: username Date: Sat, 29 Aug 2020 21:21:15 +0200 Subject: [PATCH 10/11] Provide correct parameter data type --- src/Composer/Command/ConfigCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Command/ConfigCommand.php b/src/Composer/Command/ConfigCommand.php index 69692c0e2..159bb719b 100644 --- a/src/Composer/Command/ConfigCommand.php +++ b/src/Composer/Command/ConfigCommand.php @@ -605,7 +605,7 @@ EOT $value = strtolower($values[0]); if (true === $booleanValidator($value)) { if (false === $booleanNormalizer($value)) { - $this->configSource->addRepository($matches[1], false); + $this->configSource->addRepository($matches[1], []); return 0; } From b8ebc7be5f80821d7bf8679f299a526700fab79d Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 7 Sep 2020 16:24:15 +0200 Subject: [PATCH 11/11] Revert a few changes to ConfigCommand --- src/Composer/Command/ConfigCommand.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Composer/Command/ConfigCommand.php b/src/Composer/Command/ConfigCommand.php index 159bb719b..518bb7ff3 100644 --- a/src/Composer/Command/ConfigCommand.php +++ b/src/Composer/Command/ConfigCommand.php @@ -474,7 +474,7 @@ EOT ), ); - if ((isset($uniqueConfigValues[$settingKey]) || isset($multiConfigValues[$settingKey])) && $input->getOption('unset')) { + if ($input->getOption('unset') && (isset($uniqueConfigValues[$settingKey]) || isset($multiConfigValues[$settingKey]))) { if ($settingKey === 'disable-tls' && $this->config->get('disable-tls')) { $this->getIO()->writeError('You are now running Composer with SSL/TLS protection enabled.'); } @@ -568,7 +568,7 @@ EOT if ($input->getOption('global') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]) || substr($settingKey, 0, 6) === 'extra.')) { throw new \InvalidArgumentException('The '.$settingKey.' property can not be set in the global config.json file. Use `composer global config` to apply changes to the global composer.json'); } - if ((isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey])) && $input->getOption('unset')) { + if ($input->getOption('unset') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]))) { $this->configSource->removeProperty($settingKey); return 0; @@ -605,7 +605,7 @@ EOT $value = strtolower($values[0]); if (true === $booleanValidator($value)) { if (false === $booleanNormalizer($value)) { - $this->configSource->addRepository($matches[1], []); + $this->configSource->addRepository($matches[1], false); return 0; }