On Wed, Oct 2, 2024 at 1:48 AM Juliette Reinders Folmer < php-internals_nos...@adviesenzo.nl> wrote:
> L.S., > > After the earlier discussion [1] regarding this topic in August, it is our > pleasure to present the RFC to add a `get_declared_enums()` function to PHP > for discussion. > > https://wiki.php.net/rfc/get_declared_enums > > We look forward to your feedback and hope for a constructive discussion. > > I'm all for `get_declared_enums()`. However, I don't accept that enums are not classes and going with the assumption that they are not will bring more problems than it solves. I noticed how you analyzed things internally, that everything is a class internally, including an interface or a trait. But this is an API for the userland, and in userland this is not true. The 3 structures: classes, interfaces and traits and distinct things that you can use in different ways in (generated) code. I believe that in userland, the common understanding is that enums are just a specific type of class, final ones. I would find it surprising if `get_declared_classes()` would not return enums. Avoiding a BC break would be nice also if there is no reason for it. One would be able to get only the enums by using something like: ```php function get_declared_enums_only() { return array_diff(get_declared_classes(), get_declared_enums()); } ``` -- Alex