Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7ed6318

Browse filesBrowse files
committed
Fixed incorrect behavior for mappings inside multiline string
1 parent 05dae61 commit 7ed6318
Copy full SHA for 7ed6318

File tree

2 files changed

+9
-6
lines changed
Filter options

2 files changed

+9
-6
lines changed

‎src/Symfony/Component/Yaml/Parser.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Parser.php
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,14 +376,16 @@ private function doParse(string $value, int $flags)
376376
$previousLineWasTerminatedWithBackslash = false;
377377
$value = '';
378378

379-
foreach ($this->lines as $line) {
379+
foreach ($this->lines as $multiLineIncrement => $line) {
380380
// If the indentation is not consistent at offset 0, it is to be considered as a ParseError
381381
if (0 === $this->offset && !$deprecatedUsage && isset($line[0]) && ' ' === $line[0]) {
382382
throw new ParseException('Unable to parse.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
383383
}
384384

385-
if ($this->offset >= 1 && strpos($this->currentLine, ':') && $this->isNextLineIndented()) {
386-
@trigger_error('Support for indented blocks after definition is deprecated since version 4.1. Use same level of indentation to fix this issue.', E_USER_DEPRECATED);
385+
$nextLine = $this->lines[$multiLineIncrement + 1] ?? false;
386+
387+
if ($this->offset >= 1 && $this->isNextLineIndented() && ($nextLine && strpos($nextLine, ': '))) {
388+
@trigger_error('Support for mapping keys in multiline blocks is deprecated since version 4.1.', E_USER_DEPRECATED);
387389
}
388390

389391
if ('' === trim($line)) {

‎src/Symfony/Component/Yaml/Tests/ParserTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Tests/ParserTest.php
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -527,9 +527,9 @@ public function testObjectsSupportDisabledWithExceptions()
527527

528528
/**
529529
* @group legacy
530-
* @expectedDeprecation Support for indented blocks after definition is deprecated since version 4.1. Use same level of indentation to fix this issue.
530+
* @expectedDeprecation Support for mapping keys in multiline blocks is deprecated since version 4.1.
531531
*/
532-
public function testMappingKeyWithAdditionalStringThrowsException()
532+
public function testMappingKeyInMultiLineStringTriggersDeprecationNotice()
533533
{
534534
$yaml = <<<'EOF'
535535
data:
@@ -749,9 +749,10 @@ public function testMultiLineStringLastResortParsing()
749749
You can have things that don't look like strings here
750750
true
751751
yes you can
752+
with a: colon
752753
EOT;
753754
$expected = array(
754-
'test' => 'You can have things that don\'t look like strings here true yes you can',
755+
'test' => 'You can have things that don\'t look like strings here true yes you can with a: colon',
755756
);
756757

757758
$this->assertSame($expected, $this->parser->parse($yaml));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.