Talk Details

Enums: The Missing Data Type.

Everyday PHP


PHP may not have a native data type for an Enumerated Type like other programming languages, but there are other solutions we can leverage to represent a member of a set of values. 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 session, we’ll be making our own immutable enums from scratch in order to explore the concept, but we’ll also introduce some open source 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 member elements.



Register Now