Andy Snell: Enums: PHP’s Missing Data Type

This is a past event

16 people went

Location image of event venue


Please note the location this month, as we will be meeting at the RealPage headquarters off of 75 and Campbell in Richardson, TX. Our new venue requests that attendees bring a photo identification to attend and to be as close to on-time as you can. If you plan to attend, we ask that you would please RSVP beforehand so we can get a headcount for our new host. Thank you!


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 session, 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.