enum icon indicating copy to clipboard operation
enum copied to clipboard

PHP 8.1

Open Gummibeer opened this issue 3 years ago • 7 comments

Gummibeer avatar Apr 12 '21 14:04 Gummibeer

@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?

Gummibeer avatar Apr 12 '21 14:04 Gummibeer

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

brendt avatar Apr 21 '21 10:04 brendt

@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 avatar Jul 08 '21 17:07 Gummibeer

What would you call the interface?

brendt avatar Jul 14 '21 03:07 brendt

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.

Gummibeer avatar Jul 14 '21 07:07 Gummibeer

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?

brendt avatar Jul 14 '21 08:07 brendt

Would also be fine with combining the traits.

Gummibeer avatar Jul 14 '21 11:07 Gummibeer

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

Synchro avatar Nov 22 '22 11:11 Synchro

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.

Gummibeer avatar Nov 24 '22 13:11 Gummibeer

Closing due to inactivity.

freekmurze avatar Dec 05 '22 09:12 freekmurze