PHP may not have a native data type for an enumerated type (“enum”), like other programming languages, but there are userland solutions we can leverage to get access to this powerful data type. We’ll see how representing things like statuses with enums provides immutability, improved readability, and type safety — preventing the kind of errors that happen with “magic strings” and class constants. In this Talk, we’ll be making our own immutable enums from scratch in order to explore the concept, but we’ll also introduce two libraries for use in your production code. We’ll also demystify the imposing-sounding “finite state machine” by using using immutable enum objects to regulate the transitions between statuses.

Comments

Comments are closed.

Speaker is really knowledgable on the subject and makes clear explanation, use cases and demonstration. Gives code sample and compare alternative. Great talk, Good job!

Cecili Reid at 16:24 on 23 Oct 2019

Clearly knowledgeable and a great resource for enums. I will definitely be considering writing my own enum or using an existing library moving forward until one is provided inherently with PHP.

Tim Gallagher at 21:42 on 24 Oct 2019

Loved it. Well prepared and Andy really knew the topic!

J Graham at 11:05 on 27 Oct 2019

Andy is one of my favorite presenters of the conference. Contents and flow were well thought out. I liked how he created a custom enum type, explaining possible issues and solutions at each step.