Re: Revisiting proposal for addition of `get_class_constants()`

From: Date: Fri, 12 Jun 2020 08:52:23 +0000
Subject: Re: Revisiting proposal for addition of `get_class_constants()`
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-110495@lists.php.net to get a copy of this message
On Fri, 12 Jun 2020 at 05:32, Troy McCabe <troy.mccabe@gmail.com> wrote: > > > You do mention performance as a benefit, but it's not immediately > obvious to me which use-cases are bottlenecked by class constant reflection. > > Enum implementations are the big case for this. > I've also used it in the past for generating exception messages, because the base Exception class requires $code to be int, so given a value of 1011, I wanted to map back to a constant like "MyException::TYPE_FOO". If the concern is that we will end up with too many of these as global functions, might there be value in a "lightweight reflection" API, which gave access to things like this without the full power or performance cost of Reflection? Regards, -- Rowan Tommins [IMSoP]

« previous php.internals (#110495) next »