Recently I had to build something where an Enum would have been perfect.
It needed to run on PHP 8.0. Of course.
So what to do? I decided to build an Enum like thingy that I can easily upgrade into a real Enum once we are on PHP8.1 with that project.
Why not use a library for that? There are plenty of libraries on packagist that already provide you with the basics!
For one thing: I only needed one Enum. Not a multitude. And Adding a further dependency to make creating one enum easier that will (hopefully) converted into a “eral” enum in about half a year? That sounds bit like taking the sledgehammer to crack a nut.
And on the other hand it turned out that creating an enum from scratch isn’t rocket science.Continue reading Enums. With PHP < 8.1