[Config] Fix array sort on normalization in edge case
This commit is contained in:
parent
45a006046d
commit
eca41a8fbf
@ -75,14 +75,17 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
|||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$normalized = array();
|
||||||
|
|
||||||
foreach ($value as $k => $v) {
|
foreach ($value as $k => $v) {
|
||||||
if (false !== strpos($k, '-') && false === strpos($k, '_') && !array_key_exists($normalizedKey = str_replace('-', '_', $k), $value)) {
|
if (false !== strpos($k, '-') && false === strpos($k, '_') && !array_key_exists($normalizedKey = str_replace('-', '_', $k), $value)) {
|
||||||
$value[$normalizedKey] = $v;
|
$normalized[$normalizedKey] = $v;
|
||||||
unset($value[$k]);
|
} else {
|
||||||
|
$normalized[$k] = $v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $normalized;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -74,6 +74,10 @@ class ArrayNodeTest extends \PHPUnit_Framework_TestCase
|
|||||||
array('foo-bar_moo' => 'foo'),
|
array('foo-bar_moo' => 'foo'),
|
||||||
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(
|
||||||
array('foo-bar' => null, 'foo_bar' => 'foo'),
|
array('foo-bar' => null, 'foo_bar' => 'foo'),
|
||||||
array('foo-bar' => null, 'foo_bar' => 'foo'),
|
array('foo-bar' => null, 'foo_bar' => 'foo'),
|
||||||
|
Reference in New Issue
Block a user