@ -463,13 +463,19 @@ EOT
$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])) {
return $this->handleSingleValue($settingKey, $uniqueConfigValues[$settingKey], $values, 'addConfigSetting');
$this->handleSingleValue($settingKey, $uniqueConfigValues[$settingKey], $values, 'addConfigSetting');
return 0;
}
if (isset($multiConfigValues[$settingKey])) {
return $this->handleMultiValue($settingKey, $multiConfigValues[$settingKey], $values, 'addConfigSetting');
$this->handleMultiValue($settingKey, $multiConfigValues[$settingKey], $values, 'addConfigSetting');
return 0;
}
// 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');
}
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])) {
return $this->handleSingleValue($settingKey, $uniqueProps[$settingKey], $values, 'addProperty');
$this->handleSingleValue($settingKey, $uniqueProps[$settingKey], $values, 'addProperty');
return 0;
}
if (isset($multiProps[$settingKey])) {
return $this->handleMultiValue($settingKey, $multiProps[$settingKey], $values, 'addProperty');
$this->handleMultiValue($settingKey, $multiProps[$settingKey], $values, 'addProperty');
return 0;
}
// handle repositories
if (preg_match('/^repos?(?:itories)?\.(.+)/', $settingKey, $matches)) {
if ($input->getOption('unset')) {
return $this->configSource->removeRepository($matches[1]);
$this->configSource->removeRepository($matches[1]);
return 0;
}
if (2 === count($values)) {
return $this->configSource->addRepository($matches[1], array(
$this->configSource->addRepository($matches[1], array(
'type' => $values[0],
'url' => $values[1],
));
return 0;
}
if (1 === count($values)) {
$value = strtolower($values[0]);
if (true === $booleanValidator($value)) {
if (false === $booleanNormalizer($value)) {
return $this->configSource->addRepository($matches[1], false);
$this->configSource->addRepository($matches[1], false);
return 0;
}
} else {
$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
if (preg_match('/^extra\.(.+)/', $settingKey, $matches)) {
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
if (preg_match('/^platform\.(.+)/', $settingKey, $matches)) {
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')) {
return $this->configSource->removeConfigSetting($settingKey);
$this->configSource->removeConfigSetting($settingKey);
return 0;
}
// handle auth
@ -595,7 +624,7 @@ EOT
$this->authConfigSource->removeConfigSetting($matches[1].'.'.$matches[2]);
$this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
return;
return 0 ;
}
if ($matches[1] === 'bitbucket-oauth') {
@ -618,16 +647,20 @@ EOT
$this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], array('username' => $values[0], 'password' => $values[1]));
}
return;
return 0 ;
}
// handle script
if (preg_match('/^scripts\.(.+)/', $settingKey, $matches)) {
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');