Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Yaml] Deprecate using the object and const tag without a value #35368

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions UPGRADE-5.1.md
Expand Up @@ -40,3 +40,8 @@ Routing
-------

* Deprecated `RouteCollectionBuilder` in favor of `RoutingConfigurator`.

Yaml
----

* Deprecated using the `!php/object` and `!php/const` tags without a value.
1 change: 1 addition & 0 deletions src/Symfony/Component/Yaml/CHANGELOG.md
Expand Up @@ -5,6 +5,7 @@ CHANGELOG
-----

* Added `yaml-lint` binary.
* Deprecated using the `!php/object` and `!php/const` tags without a value.

5.0.0
-----
Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/Yaml/Inline.php
Expand Up @@ -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;
}

Expand All @@ -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 '';
}

Expand Down
8 changes: 8 additions & 0 deletions src/Symfony/Component/Yaml/Tests/InlineTest.php
Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand Down