diff --git a/UPGRADE-3.3.md b/UPGRADE-3.3.md index 036ad1f61cf7c..5e83a3bf3a974 100644 --- a/UPGRADE-3.3.md +++ b/UPGRADE-3.3.md @@ -252,8 +252,12 @@ Workflow Yaml ---- - * Deprecated support for implicitly parsing non-string mapping keys as strings. Mapping keys that are no strings will - lead to a `ParseException` in Symfony 4.0. Use the `PARSE_KEYS_AS_STRINGS` flag to opt-in for keys to be parsed as + * Starting an unquoted string with a question mark followed by a space is + deprecated and will throw a `ParseException` in Symfony 4.0. + + * Deprecated support for implicitly parsing non-string mapping keys as strings. + Mapping keys that are no strings will lead to a `ParseException` in Symfony + 4.0. Use the `PARSE_KEYS_AS_STRINGS` flag to opt-in for keys to be parsed as strings. Before: diff --git a/UPGRADE-4.0.md b/UPGRADE-4.0.md index 1123d9a87a869..fd30de43aa726 100644 --- a/UPGRADE-4.0.md +++ b/UPGRADE-4.0.md @@ -463,8 +463,12 @@ Workflow Yaml ---- - * Removed support for implicitly parsing non-string mapping keys as strings. Mapping keys that are no strings will - result in a `ParseException`. Use the `PARSE_KEYS_AS_STRINGS` flag to opt-in for keys to be parsed as strings. + * Starting an unquoted string with a question mark followed by a space + throws a `ParseException`. + + * Removed support for implicitly parsing non-string mapping keys as strings. + Mapping keys that are no strings will result in a `ParseException`. Use the + `PARSE_KEYS_AS_STRINGS` flag to opt-in for keys to be parsed as strings. Before: diff --git a/src/Symfony/Component/Yaml/CHANGELOG.md b/src/Symfony/Component/Yaml/CHANGELOG.md index fb62848470cf2..b50a7b875f337 100644 --- a/src/Symfony/Component/Yaml/CHANGELOG.md +++ b/src/Symfony/Component/Yaml/CHANGELOG.md @@ -4,8 +4,12 @@ CHANGELOG 3.3.0 ----- - * Deprecated support for implicitly parsing non-string mapping keys as strings. Mapping keys that are no strings will - lead to a `ParseException` in Symfony 4.0. Use the `PARSE_KEYS_AS_STRINGS` flag to opt-in for keys to be parsed as + * Starting an unquoted string with a question mark followed by a space is + deprecated and will throw a `ParseException` in Symfony 4.0. + + * Deprecated support for implicitly parsing non-string mapping keys as strings. + Mapping keys that are no strings will lead to a `ParseException` in Symfony + 4.0. Use the `PARSE_KEYS_AS_STRINGS` flag to opt-in for keys to be parsed as strings. Before: diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 40ad7244e77d0..867244163313a 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -144,6 +144,10 @@ public function parse($value, $flags = 0) $values['value'] = $matches['value']; } + if (isset($values['value'][1]) && '?' === $values['value'][0] && ' ' === $values['value'][1]) { + @trigger_error('Starting an unquoted string with a question mark followed by a space is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', E_USER_DEPRECATED); + } + // array if (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) { $data[] = $this->parseBlock($this->getRealCurrentLineNb() + 1, $this->getNextEmbedBlock(null, true), $flags); @@ -301,6 +305,10 @@ public function parse($value, $flags = 0) throw new ParseException('Multiple documents are not supported.', $this->currentLineNb + 1, $this->currentLine); } + if (isset($this->currentLine[1]) && '?' === $this->currentLine[0] && ' ' === $this->currentLine[1]) { + @trigger_error('Starting an unquoted string with a question mark followed by a space is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', E_USER_DEPRECATED); + } + // 1-liner optionally followed by newline(s) if (is_string($value) && $this->lines[0] === trim($value)) { try { diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index 01b17a147dbf4..dfbc989f98659 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -1640,6 +1640,52 @@ public function testExceptionWhenUsingUnsuportedBuiltInTags() $this->parser->parse('!!foo'); } + /** + * @group legacy + * @expectedDeprecation Starting an unquoted string with a question mark followed by a space is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. + */ + public function testComplexMappingThrowsParseException() + { + $yaml = <<parser->parse($yaml); + } + + /** + * @group legacy + * @expectedDeprecation Starting an unquoted string with a question mark followed by a space is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. + */ + public function testComplexMappingNestedInMappingThrowsParseException() + { + $yaml = <<parser->parse($yaml); + } + + /** + * @group legacy + * @expectedDeprecation Starting an unquoted string with a question mark followed by a space is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. + */ + public function testComplexMappingNestedInSequenceThrowsParseException() + { + $yaml = <<parser->parse($yaml); + } + private function loadTestsFromFixtureFiles($testsFile) { $parser = new Parser(); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy