@@ -246,7 +246,7 @@ private function doParse($value, $flags)
246
246
$ key = (string ) $ key ;
247
247
}
248
248
249
- if ('<< ' === $ key ) {
249
+ if ('<< ' === $ key && (! isset ( $ values [ ' value ' ]) || ! self :: preg_match ( ' #^&(?P<ref>[^ ]+)#u ' , $ values [ ' value ' ], $ refMatches )) ) {
250
250
$ mergeNode = true ;
251
251
$ allowOverwrite = true ;
252
252
if (isset ($ values ['value ' ][0 ]) && '* ' === $ values ['value ' ][0 ]) {
@@ -303,15 +303,15 @@ private function doParse($value, $flags)
303
303
$ data += $ parsed ; // array union
304
304
}
305
305
}
306
- } elseif (isset ($ values ['value ' ]) && self ::preg_match ('#^&(?P<ref>[^ ]++) *+(?P<value>.*)#u ' , $ values ['value ' ], $ matches )) {
306
+ } elseif (' << ' !== $ key && isset ($ values ['value ' ]) && self ::preg_match ('#^&(?P<ref>[^ ]++) *+(?P<value>.*)#u ' , $ values ['value ' ], $ matches )) {
307
307
$ isRef = $ matches ['ref ' ];
308
308
$ values ['value ' ] = $ matches ['value ' ];
309
309
}
310
310
311
311
$ subTag = null ;
312
312
if ($ mergeNode ) {
313
313
// Merge keys
314
- } elseif (!isset ($ values ['value ' ]) || '' === $ values ['value ' ] || 0 === strpos ($ values ['value ' ], '# ' ) || (null !== $ subTag = $ this ->getLineTag ($ values ['value ' ], $ flags ))) {
314
+ } elseif (!isset ($ values ['value ' ]) || '' === $ values ['value ' ] || 0 === strpos ($ values ['value ' ], '# ' ) || (null !== $ subTag = $ this ->getLineTag ($ values ['value ' ], $ flags )) || ' << ' === $ key ) {
315
315
// hash
316
316
// if next line is less indented or equal, then it means that the current value is null
317
317
if (!$ this ->isNextLineIndented () && !$ this ->isNextLineUnIndentedCollection ()) {
@@ -330,9 +330,12 @@ private function doParse($value, $flags)
330
330
// remember the parsed line number here in case we need it to provide some contexts in error messages below
331
331
$ realCurrentLineNbKey = $ this ->getRealCurrentLineNb ();
332
332
$ value = $ this ->parseBlock ($ this ->getRealCurrentLineNb () + 1 , $ this ->getNextEmbedBlock (), $ flags );
333
- // Spec: Keys MUST be unique; first one wins.
334
- // But overwriting is allowed when a merge node is used in current block.
335
- if ($ allowOverwrite || !isset ($ data [$ key ])) {
333
+ if ('<< ' === $ key ) {
334
+ $ this ->refs [$ refMatches ['ref ' ]] = $ value ;
335
+ $ data += $ value ;
336
+ } elseif ($ allowOverwrite || !isset ($ data [$ key ])) {
337
+ // Spec: Keys MUST be unique; first one wins.
338
+ // But overwriting is allowed when a merge node is used in current block.
336
339
if (null !== $ subTag ) {
337
340
$ data [$ key ] = new TaggedValue ($ subTag , $ value );
338
341
} else {
0 commit comments