Re: Should there be a `get_declared_enums()` function ?

From: Date: Fri, 16 Aug 2024 11:13:51 +0000
Subject: Re: Should there be a `get_declared_enums()` function ?
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-124973@lists.php.net to get a copy of this message
On 15.08.2024 at 03:51, Juliette Reinders Folmer wrote: > 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. Cheers, Christoph

« previous php.internals (#124973) next »