diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index f1cb6b57aa8d6..39116d84247a8 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -619,8 +619,14 @@ private function getNextEmbedBlock($indentation = null, $inSequence = false) } $isItUnindentedCollection = $this->isStringUnIndentedCollectionItem(); + $isItComment = $this->isCurrentLineComment(); while ($this->moveToNextLine()) { + if ($isItComment && !$isItUnindentedCollection) { + $isItUnindentedCollection = $this->isStringUnIndentedCollectionItem(); + $isItComment = $this->isCurrentLineComment(); + } + $indent = $this->getCurrentLineIndentation(); if ($isItUnindentedCollection && !$this->isCurrentLineEmpty() && !$this->isStringUnIndentedCollectionItem() && $newIndent === $indent) { diff --git a/src/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml b/src/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml index af3ab38597a95..4b0c91c9b1eb9 100644 --- a/src/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml +++ b/src/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml @@ -74,3 +74,17 @@ yaml: | 'foo #': baz php: | ['foo #' => 'baz'] +--- +test: Comment before first item in unindented collection +brief: > + Comment directly before unindented collection is allowed +yaml: | + collection1: + # comment + - a + - b + collection2: + - a + - b +php: | + ['collection1' => ['a', 'b'], 'collection2' => ['a', 'b']]
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: