L.S.,

I just noticed the following, which struck me as weird/inconsistent:

There are four different OO structures in PHP:
1. Classes
2. Interfaces
3. Traits
4. Enums

For all four, an `*_exists()` function is available, i.e. `class_exists()`, `interface_exists()`, `trait_exists()` and `enum_exists()` [2].

But only for three out of the four, a `get_declared_*()` function exists.
There is `get_declared_classes()`, `get_declared_interfaces()`, `get_declared_traits()`, but no `get_declared_enums()` [2].

I'm aware that enums are internally considered classes and that `get_declared_classes()` will retrieve them [1], but the same could be said about interfaces and traits, yet they do have their own `get_declared_*()` function.

Should a `get_declared_enums()` function be added ?
And should the `get_declared_classes()` function be adjusted to exclude enums ?

I did check the enum RFC [3], but I couldn't find any mention or discussion about this in the RFC.

Smile,
Juliette


1: https://3v4l.org/0ub6I
2: https://www.php.net/manual/en/ref.classobj.php
3: https://wiki.php.net/rfc/enumerations

Reply via email to