8000 bug #17129 [Config] Fix array sort on normalization in edge case (rom… · symfony/symfony@f24690e · GitHub
[go: up one dir, main page]

Skip to content

Commit f24690e

Browse files
committed
bug #17129 [Config] Fix array sort on normalization in edge case (romainneutron)
This PR was merged into the 2.3 branch. Discussion ---------- [Config] Fix array sort on normalization in edge case | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | N/A | License | MIT | Doc PR | N/A Commits ------- eca41a8 [Config] Fix array sort on normalization in edge case
2 parents 38d4354 + eca41a8 commit f24690e

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/Symfony/Component/Config/Definition/ArrayNode.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,17 @@ protected function preNormalize($value)
7575
return $value;
7676
}
7777

78+
$normalized = array();
79+
7880
foreach ($value as $k => $v) {
7981
if (false !== strpos($k, '-') && false === strpos($k, '_') && !array_key_exists($normalizedKey = str_replace('-', '_', $k), $value)) {
80-
$value[$normalizedKey] = $v;
81-
unset($value[$k]);
82+
$normalized[$normalizedKey] = $v;
83+
} else {
84+
$normalized[$k] = $v;
8285
}
8386
}
8487

85-
return $value;
88+
return $normalized;
8689
}
8790

8891
/**

src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ public function getPreNormalizationTests()
7474
array('foo-bar_moo' => 'foo'),
7575
array('foo-bar_moo' => 'foo'),
7676
),
77+
array(
78+
array('anything-with-dash-and-no-underscore' => 'first', 'no_dash' => 'second'),
79+
array('anything_with_dash_and_no_underscore' => 'first', 'no_dash' => 'second'),
80+
),
7781
array(
7882
array('foo-bar' => null, 'foo_bar' => 'foo'),
7983
array('foo-bar' => null, 'foo_bar' => 'foo'),

0 commit comments

Comments
 (0)
0