Skip to content
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 #96

Closed
wants to merge 14 commits into from
Closed

PHP 8.1 #96

wants to merge 14 commits into from

Conversation

Gummibeer
Copy link
Collaborator

No description provided.

@Gummibeer Gummibeer added the enhancement New feature or request label Apr 12, 2021
@Gummibeer Gummibeer requested a review from brendt April 12, 2021 14:39
@Gummibeer Gummibeer self-assigned this Apr 12, 2021
@Gummibeer
Copy link
Collaborator Author

@brendt could you please check these changes.
I don't want to fully abandon the package - primary because of the faker provider and phpunit assertions.

There are some interfaces missing and the code isn't perfect. But these three traits are what I can reduce to.
The value() method is only for convenience so you don't have to use $enum->value but $enum->label().
Do you have some more things in mind we could/should keep?

src/Concerns/Comparable.php Outdated Show resolved Hide resolved
tests/EnumLabelTest.php Outdated Show resolved Hide resolved
@brendt
Copy link
Collaborator

brendt commented Apr 21, 2021

Looking good, only two minor remarks. I think these traits offer enough value to keep the package alive for now :)

@Gummibeer
Copy link
Collaborator Author

@brendt as you can't type-hint traits - what do you think about an interface? This would make type-safety for the Laravel wrapper easier and allows other packages/apps to interact with this base package.

@Gummibeer Gummibeer requested a review from brendt July 8, 2021 17:08
@brendt
Copy link
Collaborator

brendt commented Jul 14, 2021

What would you call the interface?

@Gummibeer
Copy link
Collaborator Author

Enum, Enumerable, EnumContract - I'm open for everything.
But I would add only one combining all traits of the package. So that we can build on all of them without checking for multiple interfaces and telling the user which features requires what interface.

@brendt
Copy link
Collaborator

brendt commented Jul 14, 2021

Then you'd only be able to implement the interface if you use all traits. I'm fine with that simplicity, but why not combine all traits into one as well then?

@Gummibeer
Copy link
Collaborator Author

Would also be fine with combining the traits.

@Synchro
Copy link

Synchro commented Nov 22, 2022

Is there a guide somewhere for migrating from Spatie enums to native PHP enums?

@Gummibeer
Copy link
Collaborator Author

https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md#spatieenumclasstoenumrector

Besides that you will have to replace all "method" calls with constant-like calls.

For MyClabs there's a rule, you can probably adjust it or even add it to rector.
https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md#myclabsmethodcalltoenumconstrector

Last one will be replacing all ->equals() calls with === or in_array() or add the ->equals() method via trait or whatever to your enums as it can be really useful.

@freekmurze
Copy link
Member

Closing due to inactivity.

@freekmurze freekmurze closed this Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants