[Config] Fix array sort on normalization in edge case

This commit is contained in:
Romain Neutron 2015-12-24 14:08:20 +01:00
parent 45a006046d
commit eca41a8fbf
2 changed files with 10 additions and 3 deletions

View File

@ -75,14 +75,17 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
return $value;
}
$normalized = array();
foreach ($value as $k => $v) {
if (false !== strpos($k, '-') && false === strpos($k, '_') && !array_key_exists($normalizedKey = str_replace('-', '_', $k), $value)) {
$value[$normalizedKey] = $v;
unset($value[$k]);
$normalized[$normalizedKey] = $v;
} else {
$normalized[$k] = $v;
}
}
return $value;
return $normalized;
}
/**

View File

@ -74,6 +74,10 @@ class ArrayNodeTest extends \PHPUnit_Framework_TestCase
array('foo-bar_moo' => 'foo'),
array('foo-bar_moo' => 'foo'),
),
array(
array('anything-with-dash-and-no-underscore' => 'first', 'no_dash' => 'second'),
array('anything_with_dash_and_no_underscore' => 'first', 'no_dash' => 'second'),
),
array(
array('foo-bar' => null, 'foo_bar' => 'foo'),
array('foo-bar' => null, 'foo_bar' => 'foo'),