You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
minor #16537 Document code-style for enums and class constants (derrabus)
This PR was merged into the 4.4 branch.
Discussion
----------
Document code-style for enums and class constants
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](https://wiki.php.net/rfc/enumerations). The most complete example is probably this one:
```php
enum UserStatus: string
{
case Pending = 'P';
case Active = 'A';
case Suspended = 'S';
case CanceledByUser = 'C';
}
```
I propose to adopt the naming conventions used by the RFC because they seem reasonable to me.
Fixes#16538, symfony/symfony#45516.
Commits
-------
4cc6393 Document code-style for enums and class constants
0 commit comments