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

Skip to content

[Yaml] Add support for !php/enum *->value syntax #46771

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

Merged
merged 1 commit into from
Jun 25, 2022

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? 6.2
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #44203 and the likes
License MIT
Doc PR -

This PR allows one to use the following Yaml together with enums:

- !php/enum SomeEnum::Bar
- !php/enum SomeEnum::Bar->value

The first line gets the SomeEnum::Bar instance. It's the same as writing !php/const SomeEnum::Bar but with an additional check that this is really an enum.

The second line is the one that is really needed as it allows referencing the value backed by an enum, which is something that is not possible currently.

Copy link
Member

@stof stof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This misses the test ensuring that !php/enum cannot be parsed without Yaml::PARSE_CONSTANT

@nicolas-grekas
Copy link
Member Author

@stof PR updated, thanks for the review

@fabpot
Copy link
Member

fabpot commented Jun 25, 2022

Thank you @nicolas-grekas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants