-
-
Notifications
You must be signed in to change notification settings - Fork 347
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
[PHP 8.1] Add basic support for Spatie Enums to native Enums #653
Conversation
Awesome! 🥳 |
Thank you for nice and clean code. It's joy to read |
rules-tests/Php81/Rector/Class_/SpatieEnumClassToEnumRector/Fixture/some_class.php.inc
Outdated
Show resolved
Hide resolved
There 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.
I think the Enum
suffix should be kept to avoid manual file rename.
@samsonasik - I suppose that's a fair view of things. Well unless there's a way to have rector rename the files too. Then maybe we just do that. 🤔 |
@TomasVotruba - Am I mistaken or would the |
The You may need to use |
@samsonasik - I disagree that this rector needs to match how MyCLabs rector works. These are both distinct and opinionated packages providing Enum features before native Enums. As such I think matching the individual packages convention will make sense. One of the creators/maintainers of the Spatie package @brendt wrote an article about how they will be updating their Spatie Enums to native Enums. And that included the removal of redundant EDIT: Link to Article: https://stitcher.io/blog/php-enums |
I guess put a different way, what's the Rector philosophy on providing rectors of varying levels of aggressiveness? Personally I want a rule that will update all the things for me and I don't like redundant suffixes. So having one rector that gets me part the way there doesn't feel like a solution to me. At that point I'd just do this all manually since it will still require me to rename the enum and file. |
Co-authored-by: Abdul Malik Ikhsan <samsonasik@gmail.com>
Co-authored-by: Abdul Malik Ikhsan <samsonasik@gmail.com>
…xture/some_class.php.inc Co-authored-by: Abdul Malik Ikhsan <samsonasik@gmail.com>
I think rename class name is not this rule's responsibility, you can use |
👍 Agreed, the rule should be doing one job at a time. Let's merge this as it is to keep it simple and iteratate improvements 🙂 Thank you |
rules-tests/Php81/Rector/Class_/SpatieEnumClassToEnumRector/Fixture/some_class.php.inc
Outdated
Show resolved
Hide resolved
…xture/some_class.php.inc
rules-tests/Php81/Rector/Class_/SpatieEnumClassToEnumRector/Fixture/some_class.php.inc
Outdated
Show resolved
Hide resolved
…xture/some_class.php.inc
Fair enough - that's why I was seeking to understand the philosophy here. |
Thank you @mallardduck |
Undrestood. We try to follow unix philosophy. The oldest rules try to do many things at once, but last 2 years we try to go as narrow as possible, while keeping the main idea together. |
Per the title, this add support for the most basic usage of Spatie Enums.
This does not cover usages of Spatie Enums where a
values()
method is use to override the automatic values. However it does (from my understanding) mimic the experience one would expect with only using the DocBlocks to define enum cases for their enums.It also doesn't bother to remove the import of the spatie Enums since that seems to match what the MyCLabsClass version of the rector.