From bc780e16879000f77a1022163c052f5323b5e640 Mon Sep 17 00:00:00 2001
From: Christian Flothmann <christian.flothmann@qossmic.com>
Date: Tue, 23 Apr 2024 13:55:11 +0200
Subject: [PATCH] call substr() with integer offsets

---
 Parser.php           | 4 ++--
 Tests/ParserTest.php | 9 +++++++--
 2 files changed, 9 insertions(+), 4 deletions(-)

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);