From 07c3a63fa32db09427e6c69328eede9e560a139e Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 16 Aug 2022 11:35:17 +0200 Subject: [PATCH] Fix phpstan error --- src/Composer/Command/BaseCommand.php | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/Composer/Command/BaseCommand.php b/src/Composer/Command/BaseCommand.php index 901c7f35e..4e920cfc3 100644 --- a/src/Composer/Command/BaseCommand.php +++ b/src/Composer/Command/BaseCommand.php @@ -244,22 +244,19 @@ abstract class BaseCommand extends Command } $envOptions = [ - 'COMPOSER_NO_DEV' => 'no-dev', - 'COMPOSER_PREFER_STABLE' => 'prefer-stable', - 'COMPOSER_PREFER_LOWEST' => 'prefer-lowest', + 'COMPOSER_NO_DEV' => ['no-dev', 'update-no-dev'], + 'COMPOSER_PREFER_STABLE' => ['prefer-stable'], + 'COMPOSER_PREFER_LOWEST' => ['prefer-lowest'], ]; - foreach ($envOptions as $envName => $optionName) { - if (true === $input->hasOption($optionName)) { - if (false === $input->getOption($optionName) && (bool) Platform::getEnv($envName)) { - $input->setOption($optionName, true); + foreach ($envOptions as $envName => $optionNames) { + foreach ($optionNames as $optionName) { + if (true === $input->hasOption($optionName)) { + if (false === $input->getOption($optionName) && (bool) Platform::getEnv($envName)) { + $input->setOption($optionName, true); + } } } } - if (true == $input->hasOption('update-no-dev')) { - if (true !== $input->getOption('update-no-dev') && true == Platform::getEnv('COMPOSER_NO_DEV')) { - $input->setOption('update-no-dev', true); - } - } if (true === $input->hasOption('ignore-platform-reqs')) { if (!$input->getOption('ignore-platform-reqs') && (bool) Platform::getEnv('COMPOSER_IGNORE_PLATFORM_REQS')) {