empty lines don't count for indent detection

This commit is contained in:
Christian Flothmann 2017-12-11 16:47:32 +01:00
parent 50644d0d58
commit eb073fa349
2 changed files with 15 additions and 3 deletions

View File

@ -543,8 +543,8 @@ class Parser
do {
$EOF = false;
// comment-like lines do not influence the indentation depth
if ($this->isCurrentLineComment()) {
// empty and comment-like lines do not influence the indentation depth
if ($this->isCurrentLineEmpty() || $this->isCurrentLineComment()) {
$EOF = !$this->moveToNextLine();
if (!$EOF) {
@ -571,7 +571,7 @@ class Parser
$data = array();
if ($this->getCurrentLineIndentation() >= $newIndent) {
$data[] = substr($this->currentLine, $newIndent);
} elseif ($this->isCurrentLineComment()) {
} elseif ($this->isCurrentLineEmpty() || $this->isCurrentLineComment()) {
$data[] = $this->currentLine;
} else {
$this->moveToPreviousLine();

View File

@ -2073,6 +2073,18 @@ YAML;
);
$tests['mapping in sequence starting on a new line'] = array($yaml, $expected);
$yaml = <<<YAML
foo:
bar: baz
YAML;
$expected = array(
'foo' => array(
'bar' => 'baz',
),
);
$tests['blank line at the beginning of an indented mapping value'] = array($yaml, $expected);
return $tests;
}
}