8000 Added deprecation notice when mapping keys are found in multi-line bl… · symfony/symfony@7bf8381 · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit 7bf8381

Browse files
committed
Added deprecation notice when mapping keys are found in multi-line blocks
1 parent cafbdb7 commit 7bf8381

File tree

5 files changed

+35
-0
lines changed

5 files changed

+35
-0
lines changed

UPGRADE-4.3.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,8 @@ HttpFoundation
3030
use `Symfony\Component\Mime\FileBinaryMimeTypeGuesser` instead.
3131
* The `FileinfoMimeTypeGuesser` class has been deprecated,
3232
use `Symfony\Component\Mime\FileinfoMimeTypeGuesser` instead.
33+
34+
Yaml
35+
----
36+
37+
* Using a mapping inside a multi-line string is deprecated and will throw a `ParseException` in 5.0.

UPGRADE-5.0.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,3 +286,9 @@ Workflow
286286
* `add` method has been removed use `addWorkflow` method in `Workflow\Registry` instead.
287287
* `SupportStrategyInterface` has been removed, use `WorkflowSupportStrategyInterface` instead.
288288
* `ClassInstanceSupportStrategy` has been removed, use `InstanceOfSupportStrategy` instead.
289+
290+
Yaml
291+
----
292+
293+
* The parser is now stricter and will throw a `ParseException` when a
294+
mapping is found inside a multi-line string.

src/Symfony/Component/Yaml/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
4.3.0
5+
-----
6+
7+
* Using a mapping inside a multi-line string is deprecated and will throw a `ParseException` in 5.0.
8+
49
4.2.0
510
-----
611

src/Symfony/Component/Yaml/Parser.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,11 @@ private function doParse(string $value, int $flags)
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
}
393+
394+
if (false !== strpos($line, ': ')) {
395+
@trigger_error('Support for mapping keys in multi-line blocks is deprecated since Symfony 4.3 and will throw a ParseException in 5.0.', E_USER_DEPRECATED);
396+
}
397+
393398
if ('' === trim($line)) {
394399
$value .= "\n";
395400
} elseif (!$previousLineWasNewline && !$previousLineWasTerminatedWithBackslash) {

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,20 @@ public function testObjectsSupportDisabledWithExceptions()
525525
$this->parser->parse($yaml, Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE);
526526
}
527527

528+
/**
529+
* @group legacy
530+
* @expectedDeprecation Support for mapping keys in multi-line blocks is deprecated since Symfony 4.3 and will throw a ParseException in 5.0.
531+
*/
532+
public function testMappingKeyInMultiLineStringTriggersDeprecationNotice()
533+
{
534+
$yaml = <<<'EOF'
535+
data:
536+
dbal:wrong
537+
default_connection: monolith
538+
EOF;
539+
$this->parser->parse($yaml);
540+
}
541+
528542
public function testCanParseContentWithTrailingSpaces()
529543
{
530544
$yaml = "items: \n foo: bar";

0 commit comments

Comments
 (0)
0