[Yaml] fix parse error when unindented collections contain a comment
This commit is contained in:
parent
469d82d6e2
commit
58bb2c52ac
@ -619,8 +619,14 @@ class Parser
|
||||
}
|
||||
|
||||
$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) {
|
||||
|
@ -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']]
|
||||
|
Reference in New Issue
Block a user