diff --git a/Parser.php b/Parser.php index 1b193ee6..6b5b273a 100644 --- a/Parser.php +++ b/Parser.php @@ -653,12 +653,12 @@ private function getNextEmbedBlock(?int $indentation = null, bool $inSequence = } if ($this->isCurrentLineBlank()) { - $data[] = substr($this->currentLine, $newIndent); + $data[] = substr($this->currentLine, $newIndent ?? 0); continue; } if ($indent >= $newIndent) { - $data[] = substr($this->currentLine, $newIndent); + $data[] = substr($this->currentLine, $newIndent ?? 0); } elseif ($this->isCurrentLineComment()) { $data[] = $this->currentLine; } elseif (0 == $indent) { diff --git a/Tests/ParserTest.php b/Tests/ParserTest.php index 741a6ad8..5fa6d080 100644 --- a/Tests/ParserTest.php +++ b/Tests/ParserTest.php @@ -1476,13 +1476,13 @@ public static function getBinaryData() data: !!binary | SGVsbG8gd29ybGQ= EOT - ], + ], 'containing spaces in block scalar' => [ <<<'EOT' data: !!binary | SGVs bG8gd 29ybGQ= EOT - ], + ], ]; } @@ -2949,6 +2949,11 @@ public function testParseIdeographicSpaces() ], $this->parser->parse($expected)); } + public function testSkipBlankLines() + { + $this->assertSame(['foo' => [null]], (new Parser())->parse("foo:\n-\n\n")); + } + private function assertSameData($expected, $actual) { $this->assertEquals($expected, $actual);