prefer strings for install handling when possible

main
Steve Buzonas 9 years ago
parent 124739d055
commit 73c1f8c0e0

@ -113,18 +113,22 @@ class Config
if (in_array($key, array('github-oauth', 'http-basic')) && isset($this->config[$key])) { if (in_array($key, array('github-oauth', 'http-basic')) && isset($this->config[$key])) {
$this->config[$key] = array_merge($this->config[$key], $val); $this->config[$key] = array_merge($this->config[$key], $val);
} elseif ('preferred-install' === $key && isset($this->config[$key])) { } elseif ('preferred-install' === $key && isset($this->config[$key])) {
if (is_string($val)) { if (is_array($val) || is_array($this->config[$key])) {
$val = array('*' => $val); if (is_string($val)) {
} $val = array('*' => $val);
if (is_string($this->config[$key])) { }
$this->config[$key] = array('*' => $this->config[$key]); if (is_string($this->config[$key])) {
} $this->config[$key] = array('*' => $this->config[$key]);
$this->config[$key] = array_merge($this->config[$key], $val); }
// the full match pattern needs to be last $this->config[$key] = array_merge($this->config[$key], $val);
if (isset($this->config[$key]['*'])) { // the full match pattern needs to be last
$wildcard = $this->config[$key]['*']; if (isset($this->config[$key]['*'])) {
unset($this->config[$key]['*']); $wildcard = $this->config[$key]['*'];
$this->config[$key]['*'] = $wildcard; unset($this->config[$key]['*']);
$this->config[$key]['*'] = $wildcard;
}
} else {
$this->config[$key] = $val;
} }
} else { } else {
$this->config[$key] = $val; $this->config[$key] = $val;

@ -116,8 +116,9 @@ class ConfigTest extends \PHPUnit_Framework_TestCase
{ {
$config = new Config(false); $config = new Config(false);
$config->merge(array('config' => array('preferred-install' => 'source'))); $config->merge(array('config' => array('preferred-install' => 'source')));
$config->merge(array('config' => array('preferred-install' => 'dist')));
$this->assertEquals(array('*' => 'source'), $config->get('preferred-install')); $this->assertEquals('dist', $config->get('preferred-install'));
} }
public function testMergePreferredInstall() public function testMergePreferredInstall()

Loading…
Cancel
Save