1
0
Fork 0

Fixed querying of default config values, and fix source display for them, and fix bools to show as bools, fixes #11302

pull/11398/head
Jordi Boggiano 2023-03-21 11:07:57 +01:00
parent 5c3d8f35db
commit 91b7b0ff3b
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 19 additions and 2 deletions

View File

@ -274,8 +274,21 @@ EOT
// show the value if no value is provided
if ([] === $input->getArgument('setting-value') && !$input->getOption('unset')) {
$properties = self::CONFIGURABLE_PACKAGE_PROPERTIES;
$propertiesDefaults = [
'type' => 'library',
'description' => '',
'homepage' => '',
'minimum-stability' => 'stable',
'prefer-stable' => false,
'keywords' => [],
'license' => [],
'suggest' => [],
'extra' => [],
];
$rawData = $this->configFile->read();
$data = $this->config->all();
$source = $this->config->getSourceOfValue($settingKey);
if (Preg::isMatch('/^repos?(?:itories)?(?:\.(.+))?/', $settingKey, $matches)) {
if (!isset($matches[1]) || $matches[1] === '') {
$value = $data['repositories'] ?? [];
@ -313,17 +326,21 @@ EOT
$value = $this->config->get($settingKey, $input->getOption('absolute') ? 0 : Config::RELATIVE_PATHS);
} elseif (isset($rawData[$settingKey]) && in_array($settingKey, $properties, true)) {
$value = $rawData[$settingKey];
$source = $this->configFile->getPath();
} elseif (isset($propertiesDefaults[$settingKey])) {
$value = $propertiesDefaults[$settingKey];
$source = 'defaults';
} else {
throw new \RuntimeException($settingKey.' is not defined');
}
if (is_array($value)) {
if (is_array($value) || is_bool($value)) {
$value = JsonFile::encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
}
$sourceOfConfigValue = '';
if ($input->getOption('source')) {
$sourceOfConfigValue = ' (' . $this->config->getSourceOfValue($settingKey) . ')';
$sourceOfConfigValue = ' (' . $source . ')';
}
$this->getIO()->write($value . $sourceOfConfigValue, true, IOInterface::QUIET);