Hi Ilija, > I'd like to propose a simple RFC to introduce looking up class > > constants by name. We have dedicated syntax for basically all other > > language constructs. This RFC aims to get rid of this seemingly > > arbitrary limitation. > > > > https://wiki.php.net/rfc/dynamic_class_constant_fetch > > Heads up: There hasn't been much discussion on this RFC in the last > couple of weeks, thus I'd like to start the voting phase in the next > couple of days. >
Thanks for the reminder about this topic. I'm wondering about this: > This RFC proposes no change in the interaction between class constant fetches and the null-coalescing operator ??. That is, Foo::{$bar} ?? null; will throw an Error if the given constant does not exist. It would be possible to suppress this error as is done for other types of member accesses. However, it's not clear whether this is desirable, especially for explicit class constant fetches. This change can be made in the future with no backwards compatibility break. Since an argument in favor of the RFC is to replace a function call by native syntax, wouldn't it be desired to allow the same for checking the existence of a const? I'm thinking about defined(), which the ?? operator would nicely replace IMHO. Are there technical reasons to not do it in this RFC? If not, could this be considered? Thanks, Nicolas