Command::execute() should always return an integer.

main
Alexander M. Turek 5 years ago
parent 9e2485aa4d
commit 146aa4938f

@ -42,5 +42,7 @@ EOT
See https://getcomposer.org/ for more information.</comment> See https://getcomposer.org/ for more information.</comment>
EOT EOT
); );
return 0;
} }
} }

@ -62,7 +62,7 @@ class BaseDependencyCommand extends BaseCommand
* @param InputInterface $input * @param InputInterface $input
* @param OutputInterface $output * @param OutputInterface $output
* @param bool $inverted Whether to invert matching process (why-not vs why behaviour) * @param bool $inverted Whether to invert matching process (why-not vs why behaviour)
* @return int|null Exit code of the operation. * @return int Exit code of the operation.
*/ */
protected function doExecute(InputInterface $input, OutputInterface $output, $inverted = false) protected function doExecute(InputInterface $input, OutputInterface $output, $inverted = false)
{ {

@ -70,5 +70,7 @@ EOT
} }
$io->writeError('<info>All caches cleared.</info>'); $io->writeError('<info>All caches cleared.</info>');
return 0;
} }
} }

@ -463,13 +463,19 @@ EOT
$this->getIO()->writeError('<info>You are now running Composer with SSL/TLS protection enabled.</info>'); $this->getIO()->writeError('<info>You are now running Composer with SSL/TLS protection enabled.</info>');
} }
return $this->configSource->removeConfigSetting($settingKey); $this->configSource->removeConfigSetting($settingKey);
return 0;
} }
if (isset($uniqueConfigValues[$settingKey])) { if (isset($uniqueConfigValues[$settingKey])) {
return $this->handleSingleValue($settingKey, $uniqueConfigValues[$settingKey], $values, 'addConfigSetting'); $this->handleSingleValue($settingKey, $uniqueConfigValues[$settingKey], $values, 'addConfigSetting');
return 0;
} }
if (isset($multiConfigValues[$settingKey])) { if (isset($multiConfigValues[$settingKey])) {
return $this->handleMultiValue($settingKey, $multiConfigValues[$settingKey], $values, 'addConfigSetting'); $this->handleMultiValue($settingKey, $multiConfigValues[$settingKey], $values, 'addConfigSetting');
return 0;
} }
// handle properties // handle properties
@ -530,38 +536,51 @@ EOT
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'); 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 ($input->getOption('unset') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]))) {
return $this->configSource->removeProperty($settingKey); $this->configSource->removeProperty($settingKey);
return 0;
} }
if (isset($uniqueProps[$settingKey])) { if (isset($uniqueProps[$settingKey])) {
return $this->handleSingleValue($settingKey, $uniqueProps[$settingKey], $values, 'addProperty'); $this->handleSingleValue($settingKey, $uniqueProps[$settingKey], $values, 'addProperty');
return 0;
} }
if (isset($multiProps[$settingKey])) { if (isset($multiProps[$settingKey])) {
return $this->handleMultiValue($settingKey, $multiProps[$settingKey], $values, 'addProperty'); $this->handleMultiValue($settingKey, $multiProps[$settingKey], $values, 'addProperty');
return 0;
} }
// handle repositories // handle repositories
if (preg_match('/^repos?(?:itories)?\.(.+)/', $settingKey, $matches)) { if (preg_match('/^repos?(?:itories)?\.(.+)/', $settingKey, $matches)) {
if ($input->getOption('unset')) { if ($input->getOption('unset')) {
return $this->configSource->removeRepository($matches[1]); $this->configSource->removeRepository($matches[1]);
return 0;
} }
if (2 === count($values)) { if (2 === count($values)) {
return $this->configSource->addRepository($matches[1], array( $this->configSource->addRepository($matches[1], array(
'type' => $values[0], 'type' => $values[0],
'url' => $values[1], 'url' => $values[1],
)); ));
return 0;
} }
if (1 === count($values)) { if (1 === count($values)) {
$value = strtolower($values[0]); $value = strtolower($values[0]);
if (true === $booleanValidator($value)) { if (true === $booleanValidator($value)) {
if (false === $booleanNormalizer($value)) { if (false === $booleanNormalizer($value)) {
return $this->configSource->addRepository($matches[1], false); $this->configSource->addRepository($matches[1], false);
return 0;
} }
} else { } else {
$value = JsonFile::parseJson($values[0]); $value = JsonFile::parseJson($values[0]);
$this->configSource->addRepository($matches[1], $value);
return $this->configSource->addRepository($matches[1], $value); return 0;
} }
} }
@ -571,22 +590,32 @@ EOT
// handle extra // handle extra
if (preg_match('/^extra\.(.+)/', $settingKey, $matches)) { if (preg_match('/^extra\.(.+)/', $settingKey, $matches)) {
if ($input->getOption('unset')) { if ($input->getOption('unset')) {
return $this->configSource->removeProperty($settingKey); $this->configSource->removeProperty($settingKey);
return 0;
} }
return $this->configSource->addProperty($settingKey, $values[0]); $this->configSource->addProperty($settingKey, $values[0]);
return 0;
} }
// handle platform // handle platform
if (preg_match('/^platform\.(.+)/', $settingKey, $matches)) { if (preg_match('/^platform\.(.+)/', $settingKey, $matches)) {
if ($input->getOption('unset')) { if ($input->getOption('unset')) {
return $this->configSource->removeConfigSetting($settingKey); $this->configSource->removeConfigSetting($settingKey);
return 0;
} }
return $this->configSource->addConfigSetting($settingKey, $values[0]); $this->configSource->addConfigSetting($settingKey, $values[0]);
return 0;
} }
if ($settingKey === 'platform' && $input->getOption('unset')) { if ($settingKey === 'platform' && $input->getOption('unset')) {
return $this->configSource->removeConfigSetting($settingKey); $this->configSource->removeConfigSetting($settingKey);
return 0;
} }
// handle auth // handle auth
@ -595,7 +624,7 @@ EOT
$this->authConfigSource->removeConfigSetting($matches[1].'.'.$matches[2]); $this->authConfigSource->removeConfigSetting($matches[1].'.'.$matches[2]);
$this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]); $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
return; return 0;
} }
if ($matches[1] === 'bitbucket-oauth') { if ($matches[1] === 'bitbucket-oauth') {
@ -618,16 +647,20 @@ EOT
$this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], array('username' => $values[0], 'password' => $values[1])); $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], array('username' => $values[0], 'password' => $values[1]));
} }
return; return 0;
} }
// handle script // handle script
if (preg_match('/^scripts\.(.+)/', $settingKey, $matches)) { if (preg_match('/^scripts\.(.+)/', $settingKey, $matches)) {
if ($input->getOption('unset')) { if ($input->getOption('unset')) {
return $this->configSource->removeProperty($settingKey); $this->configSource->removeProperty($settingKey);
return 0;
} }
return $this->configSource->addProperty($settingKey, count($values) > 1 ? $values : $values[0]); $this->configSource->addProperty($settingKey, count($values) > 1 ? $values : $values[0]);
return 0;
} }
throw new \InvalidArgumentException('Setting '.$settingKey.' does not exist or is not supported by this command'); throw new \InvalidArgumentException('Setting '.$settingKey.' does not exist or is not supported by this command');

@ -48,7 +48,7 @@ EOT
* *
* @param InputInterface $input * @param InputInterface $input
* @param OutputInterface $output * @param OutputInterface $output
* @return int|null * @return int
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {

@ -84,5 +84,7 @@ EOT
} else { } else {
$this->getIO()->overwriteError('<info>Generated autoload files containing '. $numberOfClasses .' classes</info>'); $this->getIO()->overwriteError('<info>Generated autoload files containing '. $numberOfClasses .' classes</info>');
} }
return 0;
} }
} }

@ -152,6 +152,8 @@ EOT
if ($input->isInteractive() && $this->hasDependencies($options) && $io->askConfirmation($question, true)) { if ($input->isInteractive() && $this->hasDependencies($options) && $io->askConfirmation($question, true)) {
$this->installDependencies($output); $this->installDependencies($output);
} }
return 0;
} }
/** /**

@ -110,6 +110,8 @@ EOT
default: default:
throw new \RuntimeException(sprintf('Unsupported format "%s". See help for supported formats.', $format)); throw new \RuntimeException(sprintf('Unsupported format "%s". See help for supported formats.', $format));
} }
return 0;
} }
/** /**

@ -48,7 +48,7 @@ EOT
* *
* @param InputInterface $input * @param InputInterface $input
* @param OutputInterface $output * @param OutputInterface $output
* @return int|null * @return int
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {

@ -79,5 +79,7 @@ EOT
foreach ($results as $result) { foreach ($results as $result) {
$io->write($result['name'] . (isset($result['description']) ? ' '. $result['description'] : '')); $io->write($result['name'] . (isset($result['description']) ? ' '. $result['description'] : ''));
} }
return 0;
} }
} }

@ -254,6 +254,8 @@ TAGSPUBKEY
} else { } else {
$io->writeError('<warning>A backup of the current version could not be written to '.$backupFile.', no rollback possible</warning>'); $io->writeError('<warning>A backup of the current version could not be written to '.$backupFile.', no rollback possible</warning>');
} }
return 0;
} }
protected function fetchKeys(IOInterface $io, Config $config) protected function fetchKeys(IOInterface $io, Config $config)

@ -61,7 +61,7 @@ EOT
/** /**
* @param InputInterface $input * @param InputInterface $input
* @param OutputInterface $output * @param OutputInterface $output
* @return int|null * @return int
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {

@ -118,7 +118,7 @@ EOT
$io->write(sprintf('<info>%s</info>', $suggestion)); $io->write(sprintf('<info>%s</info>', $suggestion));
} }
return; return 0;
} }
// Grouped by package // Grouped by package
@ -148,5 +148,7 @@ EOT
$io->write(''); $io->write('');
} }
} }
return 0;
} }
} }

Loading…
Cancel
Save