On Wed, Jun 10, 2020 at 6:33 AM Troy McCabe <troy.mcc...@gmail.com> wrote:

> Hi All,
>
> With several functions (`str_contains()`, `str_[starts|ends]_with()`) added
> for PHP8 to make things more clear, it feels like a good time to revisit
> the multiple requests to add `get_class_constants(string $class): array`.
> This would allow userland code to retrieve constants in the same way as
> properties / methods, instead of having to use reflection for constants and
> built-in functions for properties / methods. In addition to uniformity, a
> bit of fiddling shows close to half the time for 10k executions
>
> I'm willing to implement if there's interest (curiosity got the best of me
> for the aforementioned fiddling)
>

Could you please explain in more detail *why* we should duplicate existing
reflection functionality into free-standing functions?

I believe the existence of functions like get_class_methods() is a
historical artifact, because they were introduced before Reflection was a
thing. Unless there is a strong reason to the contrary, I would prefer
reflection functionality to stay inside Reflection...

You do mention performance as a benefit, but it's not immediately obvious
to me which use-cases are bottlenecked by class constant reflection.

Regards,
Nikita

Reply via email to