-
Notifications
You must be signed in to change notification settings - Fork 22
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
CamelCase vs UPPER_CASE #22
Comments
Hey, thanks for bringing this up. I'd like to support all of these cases with sane defaults. So probably something like:
The option values would remain the same as the case names (for pure enums, without a backing value) so that you can use |
See the linked commit and let me know if that's how you'd intuitively expect it to behave (I included tests for both backed enums and pure enums). If it looks fine I'll tag a release, thanks! |
Oops accidentally overrode the test for pure PascalCase enum when I was adding the test for the backed enum. Fixed here 61ba793 |
I think my main point was that it could be useful to have For people to use that mainly, and having upper case as optional thing, but not what usually would be used. |
Ah that makes sense. I think with the changes I made here, all logic should be 1:1 consistent for both UPPER_SNAKE_CASE and PascalCase enum cases, so now the only remaining step would be to make the README consistent with the more standard syntax? |
Very interesting library!
One question:
Have you considered using what appears to be the convention for enums: CamelCase?
We had similar discussions for CakePHP for example:
cakephp/bake#972
And in the end seemed to go with those, as the cases are different from the constants in the end.
This way it also seems easier to distinguish the two.
It also seems to be the way they were intended to be in terms of convention by the core PHP (RFC).
Also saw a bit of both in your example so far: fc428d5#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R210
What do you think?
For form options we usually use
as CamelCase for key vs Humanized Form for text.
Side note:
I also added a specific trait to mine for sorting and custom filtering (for some forms only a subset sometimes is wanted):
https://github.com/dereuromark/cakephp-tools/blob/master/src/Model/Entity/EnumTrait.php
Could be yours with a custom fn can also already do that out of the box, just doesnt mention it yet.
The text was updated successfully, but these errors were encountered: