diff --git a/src/Composer/Command/ConfigCommand.php b/src/Composer/Command/ConfigCommand.php index 03f090231..3025742bc 100644 --- a/src/Composer/Command/ConfigCommand.php +++ b/src/Composer/Command/ConfigCommand.php @@ -248,20 +248,23 @@ EOT return $this->configSource->addConfigSetting('github-oauth.'.$matches[1], $values[0]); } + $booleanValidator = function ($val) { return in_array($val, array('true', 'false', '1', '0'), true); }; + $booleanNormalizer = function ($val) { return $val !== 'false' && (bool) $val; }; + // handle config values $uniqueConfigValues = array( 'process-timeout' => array('is_numeric', 'intval'), 'use-include-path' => array( - function ($val) { return in_array($val, array('true', 'false', '1', '0'), true); }, - function ($val) { return $val !== 'false' && (bool) $val; } + $booleanValidator, + $booleanNormalizer ), 'prefer-source' => array( - function ($val) { return in_array($val, array('true', 'false', '1', '0'), true); }, - function ($val) { return $val !== 'false' && (bool) $val; } + $booleanValidator, + $booleanNormalizer ), 'notify-on-install' => array( - function ($val) { return in_array($val, array('true', 'false', '1', '0'), true); }, - function ($val) { return $val !== 'false' && (bool) $val; } + $booleanValidator, + $booleanNormalizer ), 'vendor-dir' => array('is_string', function ($val) { return $val; }), 'bin-dir' => array('is_string', function ($val) { return $val; }),