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])) {
$this->config[$key] = array_merge($this->config[$key], $val);
} elseif ('preferred-install' === $key && isset($this->config[$key])) {
if (is_string($val)) {
$val = array('*' => $val);
}
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
if (isset($this->config[$key]['*'])) {
$wildcard = $this->config[$key]['*'];
unset($this->config[$key]['*']);
$this->config[$key]['*'] = $wildcard;
if (is_array($val) || is_array($this->config[$key])) {
if (is_string($val)) {
$val = array('*' => $val);
}
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
if (isset($this->config[$key]['*'])) {
$wildcard = $this->config[$key]['*'];
unset($this->config[$key]['*']);
$this->config[$key]['*'] = $wildcard;
}
} else {
$this->config[$key] = $val;
}
} else {
$this->config[$key] = $val;

@ -116,8 +116,9 @@ class ConfigTest extends \PHPUnit_Framework_TestCase
{
$config = new Config(false);
$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()

Loading…
Cancel
Save