bug #25438 [Yaml] empty lines don't count for indent detection (xabbuh)

This PR was merged into the 3.3 branch.

Discussion
----------

[Yaml] empty lines don't count for indent detection

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #25405
| License       | MIT
| Doc PR        |

Commits
-------

eb073fa349 empty lines don't count for indent detection
This commit is contained in:
Fabien Potencier 2017-12-11 08:48:46 -08:00
commit 7b35c2dcde
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;
}
}