PHP 8.1 brings Enums, one of the most requested features in PHP. Enums, or Enumerations, allow creating strict and type-safe structures for fixed values. An Enum structure can hold a number of values that can also be backed with integer or string values.
In this comprehensive session, we will discover what Enums are, why they are useful, how to apply them on our applications including Drupal, and things to watch out for when using Enums.
This session is for those who are familiar with modern PHP practices such as Object Oriented Programming, and principles such as Liskov Substitution principle. A quick introduction will be given to catch up to speed, but familiarity with such concepts can help a lot.
- What are Enums
- Why Enums are useful
- How to use Enums
- Migrating from magic constants/values to Enums
- Backed Enums and storing/fetching Enum values with a database
- Using Enums in a Drupal context
- Caveats when using Enums