@@ -96,7 +96,6 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport =
96
96
$ data [] = $ parser ->parse ($ this ->getNextEmbedBlock (null , true ), $ exceptionOnInvalidType , $ objectSupport );
97
97
} else {
98
98
if (isset ($ values ['leadspaces ' ])
99
- && ' ' == $ values ['leadspaces ' ]
100
99
&& preg_match ('#^(?P<key> ' .Inline::REGEX_QUOTED_STRING .'|[^ \'"\{\[].*?) *\:(\s+(?P<value>.+?))?\s*$#u ' , $ values ['value ' ], $ matches )
101
100
) {
102
101
// this is a compact notation element, add to next block and parse
@@ -106,7 +105,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport =
106
105
107
106
$ block = $ values ['value ' ];
108
107
if ($ this ->isNextLineIndented ()) {
109
- $ block .= "\n" .$ this ->getNextEmbedBlock ($ this ->getCurrentLineIndentation () + 2 );
108
+ $ block .= "\n" .$ this ->getNextEmbedBlock ($ this ->getCurrentLineIndentation () + strlen ( $ values [ ' leadspaces ' ]) + 1 );
110
109
}
111
110
112
111
$ data [] = $ parser ->parse ($ block , $ exceptionOnInvalidType , $ objectSupport );
@@ -313,7 +312,14 @@ private function getNextEmbedBlock($indentation = null, $inSequence = false)
313
312
$ newIndent = $ indentation ;
314
313
}
315
314
316
- $ data = array (substr ($ this ->currentLine , $ newIndent ));
315
+ $ data = array ();
316
+ if ($ this ->getCurrentLineIndentation () >= $ newIndent ) {
317
+ $ data [] = substr ($ this ->currentLine , $ newIndent );
318
+ } else {
319
+ $ this ->moveToPreviousLine ();
320
+
321
+ return ;
322
+ }
317
323
318
324
if ($ inSequence && $ oldLineIndentation === $ newIndent && '- ' === $ data [0 ][0 ]) {
319
325
// the previous line contained a dash but no item content, this line is a sequence item with the same indentation
@@ -336,7 +342,7 @@ private function getNextEmbedBlock($indentation = null, $inSequence = false)
336
342
$ removeComments = !preg_match ($ removeCommentsPattern , $ this ->currentLine );
337
343
}
338
344
339
- if ($ isItUnindentedCollection && !$ this ->isStringUnIndentedCollectionItem ($ this ->currentLine )) {
345
+ if ($ isItUnindentedCollection && !$ this ->isStringUnIndentedCollectionItem ($ this ->currentLine ) && $ newIndent === $ indent ) {
340
346
$ this ->moveToPreviousLine ();
341
347
break ;
342
348
}
0 commit comments