8000 [Yaml] empty lines don't count for indent detection by xabbuh · Pull Request #25438 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
empty lines don't count for indent detection
  • Loading branch information
xabbuh committed Dec 11, 2017
commit eb073fa3498e2e4a055c7fd278f98e63acda386c
6 changes: 3 additions & 3 deletions src/Symfony/Component/Yaml/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,8 @@ private function getNextEmbedBlock($indentation = null, $inSequence = false)
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) {
Expand All @@ -571,7 +571,7 @@ private function getNextEmbedBlock($indentation = null, $inSequence = false)
$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();
Expand Down
12 changes: 12 additions & 0 deletions src/Symfony/Component/Yaml/Tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2073,6 +2073,18 @@ public function indentedMappingData()
);
$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;
}
}
Expand Down
0