-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Document code-style for enums and class constants #16537
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
Document code-style for enums and class constants #16537
Conversation
0ad7362
to
cf5eaee
Compare
Works for me. I would add that attributes should be in an |
e80d6d7
to
3d0cde2
Compare
In that case, let's move |
Yeah, and then there are validation constraints that also violate the rule. We need to document a couple of exceptions to that rule which is why I'd like to separate attribute namespacing from this discussion, if that's okay for you. |
3d0cde2
to
4cc6393
Compare
Works for me also :) |
The case of Constraints is special, because they are not only attributes. They are the API of the component directly. |
Thank you Alexander. |
This PR adds some naming conventions.
First of all, class constants. We seem to have an unwritten rule on how class constants should be named. I've made that rule explicit.
Secondly, it adds enumerations to the mix. Those are a new language element introduced in PHP 8.1. Our codebase does not have any enums yet (apart from test fixtures), so I think we should discuss the options before the first PR adding an enum to Symfony's public API arrives.
I took inspiration from the example code from the RFC. The most complete example is probably this one:
I propose to adopt the naming conventions used by the RFC because they seem reasonable to me.
Fixes #16538, symfony/symfony#45516.