diff --git a/UPGRADE-5.1.md b/UPGRADE-5.1.md index fed85626586c..feb288540656 100644 --- a/UPGRADE-5.1.md +++ b/UPGRADE-5.1.md @@ -40,3 +40,8 @@ Routing ------- * Deprecated `RouteCollectionBuilder` in favor of `RoutingConfigurator`. + +Yaml +---- + + * Deprecated using the `!php/object` and `!php/const` tags without a value. diff --git a/src/Symfony/Component/Yaml/CHANGELOG.md b/src/Symfony/Component/Yaml/CHANGELOG.md index c7150badb07c..69932882406a 100644 --- a/src/Symfony/Component/Yaml/CHANGELOG.md +++ b/src/Symfony/Component/Yaml/CHANGELOG.md @@ -5,6 +5,7 @@ CHANGELOG ----- * Added `yaml-lint` binary. + * Deprecated using the `!php/object` and `!php/const` tags without a value. 5.0.0 ----- diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index de153c34f4bc..d3ea5ab0421b 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -590,6 +590,8 @@ private static function evaluateScalar(string $scalar, int $flags, array $refere case 0 === strpos($scalar, '!php/object'): if (self::$objectSupport) { if (!isset($scalar[12])) { + @trigger_error('Using the !php/object tag without a value is deprecated since Symfony 5.1.', E_USER_DEPRECATED); + return false; } @@ -604,6 +606,8 @@ private static function evaluateScalar(string $scalar, int $flags, array $refere case 0 === strpos($scalar, '!php/const'): if (self::$constantSupport) { if (!isset($scalar[11])) { + @trigger_error('Using the !php/const tag without a value is deprecated since Symfony 5.1.', E_USER_DEPRECATED); + return ''; } diff --git a/src/Symfony/Component/Yaml/Tests/InlineTest.php b/src/Symfony/Component/Yaml/Tests/InlineTest.php index 79c1df6d7614..ccc4fed13d5e 100644 --- a/src/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php @@ -740,6 +740,10 @@ public function getTestsForOctalNumbers() /** * @dataProvider phpObjectTagWithEmptyValueProvider + * + * @group legacy + * + * @expectedDeprecation Using the !php/object tag without a value is deprecated since Symfony 5.1. */ public function testPhpObjectWithEmptyValue($expected, $value) { @@ -760,6 +764,10 @@ public function phpObjectTagWithEmptyValueProvider() /** * @dataProvider phpConstTagWithEmptyValueProvider + * + * @group legacy + * + * @expectedDeprecation Using the !php/const tag without a value is deprecated since Symfony 5.1. */ public function testPhpConstTagWithEmptyValue($expected, $value) {