> Should a `get_declared_enums()` function be added ?
>
> Here we go:
>
>     function get_declared_enums() {
>         $enums = [];
>         $exts = get_loaded_extensions(false);
>         foreach ($exts as $ext) {
>             $re = new ReflectionExtension($ext);
>             $classes = $re->getClasses();
>             foreach ($classes as $class) {
>                 if ($class->isEnum()) {
>                     $enums[] = $class->name;
>                 }
>             }
>         }
>         return $enums;
>     }
>
> Porting this to C is left as an excercise for the reader. ;)  Hint:
> <
> https://github.com/php/php-src/blob/8853cf3ae950a1658054f286117bc8f77f724f00/Zend/zend_builtin_functions.c#L1371-L1399
> >
>
> Note that the terminating folding marker is backwards.
>
> > And should the `get_declared_classes()` function be adjusted to exclude
> > enums ?
>
> For reasons that have been stated elsewhere in this thread, I don't
> think so.
>


And here is a one liner:

    function get_declared_enums() {
         return array_filter(get_declared_classes(), 'enum_exists');
    }

Reply via email to