Support for enums in existence checks

We have several places in the framework checking for existence of arbitrary class names, allowing classes, interfaces or traits (see #40140 for instance which adds such a usage, but I’m almost sure we have others elsewhere).
As PHP 8.1 will introduce the support of enums (the RFC has been accepted), these places should be updated to also check enum_exists

symfony/polyfill#335 might help here to avoid checking for the availability of enum_exists|

1 possible answer(s) on “Support for enums in existence checks

  1. Effectively, enums are classes with slightly different syntax. At runtime, they are classes and their enumerated values are objects. The rest is just syntactic sugar. Suit::Clubs will pass an object type check, for instance, and enums share the class namespace.

    So, intended-ish. Our general stance was “they’re classes, so don’t vary from what classes do/look like/work like unless there’s a reason to.” So far no one offered a reason that class_exists(Suit::class) shouldn’t return true.