@@ -171,7 +171,13 @@ private function doParse(string $value, int $flags)
171
171
// array
172
172
if (isset ($ values ['value ' ]) && 0 === strpos (ltrim ($ values ['value ' ], ' ' ), '- ' )) {
173
173
// Inline first child
174
- $ data [] = $ this ->parseBlock ($ this ->getRealCurrentLineNb () + 1 , $ this ->getNextEmbedBlock (2 , true , true ) ?? '' , $ flags );
174
+ $ currentLineNumber = $ this ->getRealCurrentLineNb ();
175
+
176
+ $ sequenceIndentation = strlen ($ values ['leadspaces ' ]) + 1 ;
177
+ $ sequenceYaml = substr ($ this ->currentLine , $ sequenceIndentation );
178
+ $ sequenceYaml .= "\n" .$ this ->getNextEmbedBlock ($ sequenceIndentation , true );
179
+
180
+ $ data [] = $ this ->parseBlock ($ currentLineNumber , rtrim ($ sequenceYaml ), $ flags );
175
181
} elseif (!isset ($ values ['value ' ]) || '' == trim ($ values ['value ' ], ' ' ) || 0 === strpos (ltrim ($ values ['value ' ], ' ' ), '# ' )) {
176
182
$ data [] = $ this ->parseBlock ($ this ->getRealCurrentLineNb () + 1 , $ this ->getNextEmbedBlock (null , true ) ?? '' , $ flags );
177
183
} elseif (null !== $ subTag = $ this ->getLineTag (ltrim ($ values ['value ' ], ' ' ), $ flags )) {
@@ -559,19 +565,18 @@ private function getCurrentLineIndentation(): int
559
565
/**
560
566
* Returns the next embed block of YAML.
561
567
*
562
- * @param int|null $indentation The indent level at which the block is to be read, or null for default
563
- * @param bool $inSequence True if the enclosing data structure is a sequence
564
- * @param bool $isInlineFirstChild True if the definition has an inline first element
568
+ * @param int|null $indentation The indent level at which the block is to be read, or null for default
569
+ * @param bool $inSequence True if the enclosing data structure is a sequence
565
570
*
566
571
* @return string A YAML string
567
572
*
568
573
* @throws ParseException When indentation problem are detected
569
574
*/
570
- private function getNextEmbedBlock (int $ indentation = null , bool $ inSequence = false , bool $ isInlineFirstChild = false ): string
575
+ private function getNextEmbedBlock (int $ indentation = null , bool $ inSequence = false ): string
571
576
{
572
577
$ oldLineIndentation = $ this ->getCurrentLineIndentation ();
573
578
574
- if (!$ isInlineFirstChild && ! $ this ->moveToNextLine ()) {
579
+ if (!$ this ->moveToNextLine ()) {
575
580
return '' ;
576
581
}
577
582
@@ -609,7 +614,7 @@ private function getNextEmbedBlock(int $indentation = null, bool $inSequence = f
609
614
610
615
$ data = [];
611
616
612
- if ($ isInlineFirstChild || $ this ->getCurrentLineIndentation () >= $ newIndent ) {
617
+ if ($ this ->getCurrentLineIndentation () >= $ newIndent ) {
613
618
$ data [] = substr ($ this ->currentLine , $ newIndent );
614
619
} elseif ($ this ->isCurrentLineEmpty () || $ this ->isCurrentLineComment ()) {
615
620
$ data [] = $ this ->currentLine ;
@@ -619,7 +624,7 @@ private function getNextEmbedBlock(int $indentation = null, bool $inSequence = f
619
624
return '' ;
620
625
}
621
626
622
- if (! $ isInlineFirstChild && $ inSequence && $ oldLineIndentation === $ newIndent && isset ($ data [0 ][0 ]) && '- ' === $ data [0 ][0 ]) {
627
+ if ($ inSequence && $ oldLineIndentation === $ newIndent && isset ($ data [0 ][0 ]) && '- ' === $ data [0 ][0 ]) {
623
628
// the previous line contained a dash but no item content, this line is a sequence item with the same indentation
624
629
// and therefore no nested list or mapping
625
630
$ this ->moveToPreviousLine ();
@@ -638,7 +643,7 @@ private function getNextEmbedBlock(int $indentation = null, bool $inSequence = f
638
643
639
644
$ indent = $ this ->getCurrentLineIndentation ();
640
645
641
- if (! $ isInlineFirstChild && $ isItUnindentedCollection && !$ this ->isCurrentLineEmpty () && !$ this ->isStringUnIndentedCollectionItem () && $ newIndent === $ indent ) {
646
+ if ($ isItUnindentedCollection && !$ this ->isCurrentLineEmpty () && !$ this ->isStringUnIndentedCollectionItem () && $ newIndent === $ indent ) {
642
647
$ this ->moveToPreviousLine ();
643
648
break ;
644
649
}
0 commit comments