Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6009167

Browse files
committed
Added deprecation notice when mappings found inside a multiline string
1 parent 1927fba commit 6009167

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

src/Symfony/Component/Yaml/Parser.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,15 +385,13 @@ private function doParse(string $value, int $flags)
385385
$previousLineWasTerminatedWithBackslash = false;
386386
$value = '';
387387

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

394-
$nextLine = $this->lines[$multiLineIncrement + 1] ?? false;
395-
396-
if ($this->offset >= 1 && $this->isNextLineIndented() && ($nextLine && strpos($nextLine, ': '))) {
394+
if ($this->offset >= 1 && strpos($line, ': ')) {
397395
@trigger_error('Support for mapping keys in multiline blocks is deprecated since version 4.1.', E_USER_DEPRECATED);
398396
}
399397

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -749,10 +749,9 @@ 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
753752
EOT;
754753
$expected = array(
755-
'test' => 'You can have things that don\'t look like strings here true yes you can with a: colon',
754+
'test' => 'You can have things that don\'t look like strings here true yes you can',
756755
);
757756

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

0 commit comments

Comments
 (0)