Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[YamlComponent] Dump enums with !php/enum instead of !php/const #54150

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

Closed
Justinas-Jurciukonis opened this issue Mar 4, 2024 · 1 comment
Closed

Comments

@Justinas-Jurciukonis
Copy link

Description

Yaml Component allows reading new !php/enum SomeEnum::FOO_BAR into actual enum.
But same code is written back, this becomes constant: !php/const SomeEnum::FOO_BAR


Allow to write enums back instead of converting them to const

Example

$yamlData = <<< YAML
parameters:
    foo_bar: !php/enum App\Constant\Enum\Foo::BAR
YAML;

$yaml = Yaml::parse($yamlData, Yaml::PARSE_CONSTANT);
$yaml['parameters']['bar'] = App\Constant\Enum\Foo::BAR;

echo Yaml::dump($yaml);
/*
parameters:
    foo_bar: !php/const App\Constant\Enum\Foo::BAR
    bar: !php/const App\Constant\Enum\Foo::BAR
*/
@xabbuh
Copy link
Member

xabbuh commented Mar 4, 2024

This will be the case with Symfony 7.1 (see #53680).

@xabbuh xabbuh closed this as completed Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants