Skip to content

Commit d1820b5

Browse files
committed
Merge branch '2.8' into 3.2
* 2.8: [SecurityBundle] only pass relevant user provider [Intl] Make tests pass after the ICU data update [Intl] Update ICU data to 58.2 do not register the test listener twice [DependencyInjection] removed dead code. [Yaml] Stop replacing NULLs when merging [WebServerBundle] fixed html attribute escape
2 parents 5247d5c + d1ef72c commit d1820b5

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

Parser.php

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,7 @@ public function parse($value, $flags = 0)
185185
throw new ParseException('YAML merge keys used with a scalar value instead of an array.', $this->getRealCurrentLineNb() + 1, $this->currentLine);
186186
}
187187

188-
foreach ($refValue as $key => $value) {
189-
if (!isset($data[$key])) {
190-
$data[$key] = $value;
191-
}
192-
}
188+
$data += $refValue; // array union
193189
} else {
194190
if (isset($values['value']) && $values['value'] !== '') {
195191
$value = $values['value'];
@@ -211,20 +207,12 @@ public function parse($value, $flags = 0)
211207
throw new ParseException('Merge items must be arrays.', $this->getRealCurrentLineNb() + 1, $parsedItem);
212208
}
213209

214-
foreach ($parsedItem as $key => $value) {
215-
if (!isset($data[$key])) {
216-
$data[$key] = $value;
217-
}
218-
}
210+
$data += $parsedItem; // array union
219211
}
220212
} else {
221213
// If the value associated with the key is a single mapping node, each of its key/value pairs is inserted into the
222214
// current mapping, unless the key already exists in it.
223-
foreach ($parsed as $key => $value) {
224-
if (!isset($data[$key])) {
225-
$data[$key] = $value;
226-
}
227-
}
215+
$data += $parsed; // array union
228216
}
229217
}
230218
} elseif (isset($values['value']) && preg_match('#^&(?P<ref>[^ ]+) *(?P<value>.*)#u', $values['value'], $matches)) {

Tests/Fixtures/sfMergeKey.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ yaml: |
1010
a: Steve
1111
b: Clark
1212
c: Brian
13+
e: notnull
1314
bar:
1415
a: before
1516
d: other
17+
e: ~
1618
<<: *foo
1719
b: new
1820
x: Oren
@@ -42,12 +44,12 @@ yaml: |
4244
<<: *nestedref
4345
php: |
4446
array(
45-
'foo' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian'),
46-
'bar' => array('a' => 'before', 'd' => 'other', 'b' => 'new', 'c' => array('foo' => 'bar', 'bar' => 'foo'), 'x' => 'Oren'),
47+
'foo' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull'),
48+
'bar' => array('a' => 'before', 'd' => 'other', 'e' => null, 'b' => 'new', 'c' => array('foo' => 'bar', 'bar' => 'foo'), 'x' => 'Oren'),
4749
'foo2' => array('a' => 'Ballmer'),
4850
'ding' => array('fi', 'fei', 'fo', 'fam'),
49-
'check' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'fi', 'fei', 'fo', 'fam', 'isit' => 'tested'),
50-
'head' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'fi', 'fei', 'fo', 'fam'),
51+
'check' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam', 'isit' => 'tested'),
52+
'head' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam'),
5153
'taz' => array('a' => 'Steve', 'w' => array('p' => 1234)),
5254
'nested' => array('a' => 'Steve', 'w' => array('p' => 12345), 'd' => 'Doug', 'z' => array('p' => 12345))
5355
)

0 commit comments

Comments
 (0)