diff --git a/UPGRADE-3.1.md b/UPGRADE-3.1.md index c2269062e306b..309698eea3742 100644 --- a/UPGRADE-3.1.md +++ b/UPGRADE-3.1.md @@ -33,6 +33,8 @@ Serializer Yaml ---- + * Deprecated usage of `%` at the beginning of an unquoted string. + * The `Dumper::setIndentation()` method is deprecated and will be removed in Symfony 4.0. Pass the indentation level to the constructor instead. diff --git a/UPGRADE-4.0.md b/UPGRADE-4.0.md index 6f92825068601..e2eb6a972bec7 100644 --- a/UPGRADE-4.0.md +++ b/UPGRADE-4.0.md @@ -30,6 +30,8 @@ Serializer Yaml ---- + * Starting an unquoted string with `%` leads to a `ParseException`. + * The `Dumper::setIndentation()` method was removed. Pass the indentation level to the constructor instead. diff --git a/src/Symfony/Component/Yaml/CHANGELOG.md b/src/Symfony/Component/Yaml/CHANGELOG.md index 1ce9f6553ab8a..23b9f6f6b9306 100644 --- a/src/Symfony/Component/Yaml/CHANGELOG.md +++ b/src/Symfony/Component/Yaml/CHANGELOG.md @@ -4,6 +4,8 @@ CHANGELOG 3.1.0 ----- + * Deprecated usage of `%` at the beginning of an unquoted string. + * Added support for customizing the YAML parser behavior through an optional bit field: ```php diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index f08a6fa177954..4907e695c1125 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -289,6 +289,10 @@ public static function parseScalar($scalar, $delimiters = null, $stringDelimiter throw new ParseException(sprintf('The reserved indicator "%s" cannot start a plain scalar; you need to quote the scalar.', $output[0])); } + if ($output && '%' === $output[0]) { + @trigger_error('Not quoting a scalar starting with the "%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.', E_USER_DEPRECATED); + } + if ($evaluate) { $output = self::evaluateScalar($output, $references); } diff --git a/src/Symfony/Component/Yaml/Tests/InlineTest.php b/src/Symfony/Component/Yaml/Tests/InlineTest.php index c6fac119a2df3..c23c78bd998c0 100644 --- a/src/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php @@ -252,6 +252,27 @@ public function getScalarIndicators() return array(array('|'), array('>')); } + /** + * @group legacy + * throws \Symfony\Component\Yaml\Exception\ParseException in 4.0 + */ + public function testParseUnquotedScalarStartingWithPercentCharacter() + { + $deprecations = array(); + set_error_handler(function ($type, $msg) use (&$deprecations) { + if (E_USER_DEPRECATED === $type) { + $deprecations[] = $msg; + } + }); + + Inline::parse('{ foo: %foo }'); + + restore_error_handler(); + + $this->assertCount(1, $deprecations); + $this->assertContains('Not quoting a scalar starting with the "%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.', $deprecations[0]); + } + public function getTestsForParse() { return array( 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