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
Hello ! While working with enums at my job, I did encounter some limitations while trying go from "fake enums" to "real enums". What I call fake enums is what we used to do in PHP 7 :
class FakeEnum
{
publicconstENUM_CASE = 'value';
privatefunction__construct() {}
}
And what I called a "real enum" is a pure PHP 8, which follows the RFC's recommandation for the cases' case (PascalCase) (yes that's weird) :
enum RealEnum: string
{
case EnumCase = 'value';
}
I don't know if it is out of scope but I think the real could also rename the class and remove the private constructor :
-class MyEnum+enum MyEnum: string
-private function __construct() {}
I may have missed something, maybe Rector already handles everything listed above. In that case I am sorry for the fake feature request 😄 However, if that's not the case and you guys agree with my feature request, I can obviously contribute to the rule creation if needed. I am also opened to discussion obvisouly.
Thanks, Fabien
The text was updated successfully, but these errors were encountered:
Feature Request
Hello ! While working with enums at my job, I did encounter some limitations while trying go from "fake enums" to "real enums". What I call fake enums is what we used to do in PHP 7 :
And what I called a "real enum" is a pure PHP 8, which follows the RFC's recommandation for the cases' case (PascalCase) (yes that's weird) :
Diff
Also we should be able to update our code like so :
I don't know if it is out of scope but I think the real could also rename the class and remove the
private
constructor :-private function __construct() {}
I may have missed something, maybe Rector already handles everything listed above. In that case I am sorry for the fake feature request 😄 However, if that's not the case and you guys agree with my feature request, I can obviously contribute to the rule creation if needed. I am also opened to discussion obvisouly.
Thanks, Fabien
The text was updated successfully, but these errors were encountered: