On Tue, Feb 26, 2013 at 4:19 PM, Mike Willbanks <pen...@gmail.com> wrote:
> Hello All, > > Before drafting an RFC I would like to gauge interest in adding: > get_object_constants and get_class_constants > > Currently this can only be done through ReflectionClass which is far slower > than retrieving them directly from the constants table. Some simple > timings show that through reflection retrieving these values is 2-3 times > slower than providing a quick access function for retrieval. > > This also fits nicely amongst the current stack of: > get_object_vars, get_class_vars and get_class_methods > > These functions are commonly asked about on areas such as StackOverflow ( > > http://stackoverflow.com/questions/956401/can-i-get-consts-defined-on-a-php-class > ) > amongst other places on the net. > > I have already drafted up a PR with the changes and supplemental data: > https://github.com/php/php-src/pull/292 > > Regards, > > Mike > I don't quite see why we need this. The only argument seems to be performance and I'm not quite sure why performance would be relevant here. At least I can't imagine in what kind of code fetching the class constants is a bottleneck. Nikita