Skip to content

Commit 6c84a4b

Browse files
Merge branch '7.3' into 7.4
* 7.3: [Cache] Fix accepting named closures as early-expiration callbacks [Mime] Update mime types [Yaml] Align unquoted multiline scalar parsing with spec for comments work around limitation in JsonResponse when the data is null do not use recipient phone numbers as sender e-mail addresses [Dotenv] DotenvDumpCommand cannot be internal
2 parents c082fdb + 18aba8f commit 6c84a4b

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ private function parseValue(string $value, int $flags, string $context): mixed
782782
}
783783

784784
if ($this->isCurrentLineComment()) {
785-
continue;
785+
break;
786786
}
787787

788788
$lines[] = trim($this->currentLine);

Tests/ParserTest.php

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,25 +1760,22 @@ public function testParseMultiLineUnquotedString()
17601760
$this->assertSame(['foo' => 'bar baz foobar foo', 'bar' => 'baz'], $this->parser->parse($yaml));
17611761
}
17621762

1763-
#[DataProvider('unquotedStringWithTrailingComment')]
1764-
public function testUnquotedMultilineScalarIgnoresComments(string $yaml, array $expected)
1763+
#[DataProvider('getUnquotedMultilineScalarHandlesCommentsAndBlanksData')]
1764+
public function testUnquotedMultilineScalarHandlesCommentsAndBlanks(string $yaml, array $expected)
17651765
{
17661766
$this->assertSame($expected, $this->parser->parse($yaml));
17671767
}
17681768

1769-
public static function getUnquotedMultilineScalarIgnoresCommentsData()
1769+
public static function getUnquotedMultilineScalarHandlesCommentsAndBlanksData()
17701770
{
1771-
yield 'comments interspersed' => [
1771+
yield 'comments interspersed stops scalar' => [
17721772
<<<YAML
17731773
key: unquoted
1774-
# this comment should be ignored
1775-
next line
1776-
# another comment
1777-
final line
1774+
# this comment terminates
17781775
another_key: works
17791776
YAML,
17801777
[
1781-
'key' => 'unquoted next line final line',
1778+
'key' => 'unquoted',
17821779
'another_key' => 'works',
17831780
],
17841781
];
@@ -1796,17 +1793,16 @@ public static function getUnquotedMultilineScalarIgnoresCommentsData()
17961793
],
17971794
];
17981795

1799-
yield 'blank lines and comments' => [
1796+
yield 'blank lines are preserved and comment stops scalar' => [
18001797
<<<YAML
18011798
key: unquoted
18021799
next line
18031800
1804-
# this comment should be ignored
1805-
final line
1801+
# this comment terminates the scalar
18061802
another_key: works
18071803
YAML,
18081804
[
1809-
'key' => "unquoted next line\nfinal line",
1805+
'key' => 'unquoted next line',
18101806
'another_key' => 'works',
18111807
],
18121808
];
@@ -1825,6 +1821,21 @@ public static function getUnquotedMultilineScalarIgnoresCommentsData()
18251821
];
18261822
}
18271823

1824+
public function testUnquotedMultilineScalarThrowsOnOrphanedLineAfterComment()
1825+
{
1826+
$this->expectException(ParseException::class);
1827+
$this->expectExceptionMessage('Unable to parse at line 3 (near " next line")');
1828+
1829+
$yaml = <<<YAML
1830+
key: unquoted
1831+
# this comment terminates
1832+
next line
1833+
another_key: works
1834+
YAML;
1835+
1836+
$this->parser->parse($yaml);
1837+
}
1838+
18281839
#[DataProvider('unquotedStringWithTrailingComment')]
18291840
public function testParseMultiLineUnquotedStringWithTrailingComment(string $yaml, array $expected)
18301841
{

0 commit comments

Comments
 (0)