Skip to content

Commit

Permalink
call substr() with integer offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Apr 23, 2024
1 parent a38ba0b commit bc780e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 7 additions & 2 deletions Tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1476,13 +1476,13 @@ public static function getBinaryData()
data: !!binary |
SGVsbG8gd29ybGQ=
EOT
],
],
'containing spaces in block scalar' => [
<<<'EOT'
data: !!binary |
SGVs bG8gd 29ybGQ=
EOT
],
],
];
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit bc780e1

Please sign in to comment.