Skip to content

Commit bc780e1

Browse files
committed
call substr() with integer offsets
1 parent a38ba0b commit bc780e1

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

Parser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,12 +653,12 @@ private function getNextEmbedBlock(?int $indentation = null, bool $inSequence =
653653
}
654654

655655
if ($this->isCurrentLineBlank()) {
656-
$data[] = substr($this->currentLine, $newIndent);
656+
$data[] = substr($this->currentLine, $newIndent ?? 0);
657657
continue;
658658
}
659659

660660
if ($indent >= $newIndent) {
661-
$data[] = substr($this->currentLine, $newIndent);
661+
$data[] = substr($this->currentLine, $newIndent ?? 0);
662662
} elseif ($this->isCurrentLineComment()) {
663663
$data[] = $this->currentLine;
664664
} elseif (0 == $indent) {

Tests/ParserTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,13 +1476,13 @@ public static function getBinaryData()
14761476
data: !!binary |
14771477
SGVsbG8gd29ybGQ=
14781478
EOT
1479-
],
1479+
],
14801480
'containing spaces in block scalar' => [
14811481
<<<'EOT'
14821482
data: !!binary |
14831483
SGVs bG8gd 29ybGQ=
14841484
EOT
1485-
],
1485+
],
14861486
];
14871487
}
14881488

@@ -2949,6 +2949,11 @@ public function testParseIdeographicSpaces()
29492949
], $this->parser->parse($expected));
29502950
}
29512951

2952+
public function testSkipBlankLines()
2953+
{
2954+
$this->assertSame(['foo' => [null]], (new Parser())->parse("foo:\n-\n\n"));
2955+
}
2956+
29522957
private function assertSameData($expected, $actual)
29532958
{
29542959
$this->assertEquals($expected, $actual);

0 commit comments

Comments
 (0)