Re: [RFC][Dynamic class constant fetch]

From: Date: Fri, 04 Nov 2022 14:48:33 +0000
Subject: Re: [RFC][Dynamic class constant fetch]
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-118964@lists.php.net to get a copy of this message
On Fri, 4 Nov 2022 at 15:40, Larry Garfield <larry@garfieldtech.com> wrote: > On Fri, Nov 4, 2022, at 9:31 AM, Marco Pivetta wrote: > > Heyo, > > > > On Fri, 4 Nov 2022 at 15:26, Ilija Tovilo <tovilo.ilija@gmail.com> > wrote: > > > >> Hi everyone > >> > >> 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 > >> > >> Please let me know if you have any thoughts. > >> > > > > What's the problem with using constant() for this? > > > > Marco Pivetta > > > > https://twitter.com/Ocramius > > > > https://ocramius.github.io/ > > As it says right in the RFC: > > // This: > echo Foo::{$bar}; > > // is way more convenient than this mess: > echo constant(Foo::class . '::' . $bar); > > This is something people have mentioned a number of times with enums and > dynamic case references, and seems like a good small cleanup. > What's convenient about Foo::{$bar} vs `constant(Foo::class . '::' . $bar)`? I'm a bit confused by this :| Is it the few keystrokes added? Marco Pivetta https://twitter.com/Ocramius https://ocramius.github.io/

« previous php.internals (#118964) next »