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

Skip to content

Commit 3c6a833

Browse files
committed
Added deprecation notice when mappings found inside a multiline string
1 parent 1027180 commit 3c6a833

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
@@ -376,15 +376,13 @@ private function doParse(string $value, int $flags)
376376
$previousLineWasTerminatedWithBackslash = false;
377377
$value = '';
378378

379-
foreach ($this->lines as $multiLineIncrement => $line) {
379+
foreach ($this->lines as $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-
$nextLine = $this->lines[$multiLineIncrement + 1] ?? false;
386-
387-
if ($this->offset >= 1 && $this->isNextLineIndented() && ($nextLine && strpos($nextLine, ': '))) {
385+
if ($this->offset >= 1 && strpos($line, ': ')) {
388386
@trigger_error('Support for mapping keys in multiline blocks is deprecated since version 4.1.', E_USER_DEPRECATED);
389387
}
390388

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)