Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[Config] Allow using an enum FQCN withEnumNode
#57686
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
src/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
a84a01b
to1b7d1e9
Comparealexandre-daubois commentedJul 9, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Thanks for the review! I didn't answer to each message individually to avoid spamming your notifications but I addressed everything |
6d25b9b
to7808738
CompareUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Great stuff overall, thanks for picking this up! :) |
f1daab5
toba522e8
CompareThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM now from an end user perspective, but the core team might have more feedback 😅
Ah an interesting problem came up herehttps://github.com/symfony/symfony/pull/57653/files#r1671760696 - what if the enum class is not defined? Should it make an empty value set then? Or error loudly but in a nicer way than just calling |
alexandre-daubois commentedJul 10, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
In the constructor, I check the existence of the enum. If it doesn't exist, it will treat it as a simple string. I think it is enough, otherwise I'm affraid it will complexify the whole thing a lot. Additionally, I also think that people will use it with the |
Yes it seems safe, but it doesn't solve the problem in the other PR :)
That is not true unfortunatelyhttps://3v4l.org/ibsvJ |
alexandre-daubois commentedJul 10, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Ah yes indeed... In fact, making an assertion that a string looks like an FQCN seems a bit brittle to me. Another solution that could be considered is that, if only one value is passed to |
Sorry you lost me there. You already have |
Ah yes I forgot a bit of context, sorry. Actually I was talking about the standalone use of But anyway, let's see what others think of the current state yes! 👍 |
Uh oh!
There was an error while loading.Please reload this page.
...mponent/Config/Tests/Builder/Fixtures/PrimitiveTypes/Symfony/Config/PrimitiveTypesConfig.phpShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
ba522e8
to98794a0
CompareUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
315c6b3
to1f036a0
Compare1f036a0
toc034e3e
Comparec034e3e
toa31c025
Comparea31c025
tod060265
CompareThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Let's get this over the finish line, shall we?
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
d060265
tobc2ab61
CompareThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Minor things on my side
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
95b3c59
to6529b5a
CompareThank you for the review. I updated to have as many early return/throw as possible as well as improved the exception messages. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
6529b5a
to836d0a7
CompareUh oh!
There was an error while loading.Please reload this page.
836d0a7
to2b3b4bf
CompareThank you@alexandre-daubois. |
6b02c77
intosymfony:7.3Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
This PR allows doing the following with backed enums:
Then, you can pass enum cases as well as plain strings to the config, which will be automatically converted to an enum case with
BackedEnum::tryFrom()
.