Re: [RFC] [Discussion] nameof

From: Date: Sat, 13 May 2023 16:14:39 +0000
Subject: Re: [RFC] [Discussion] nameof
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-120264@lists.php.net to get a copy of this message
On Sat, May 13, 2023 at 5:18 PM Niels Dossche <dossche.niels@gmail.com> wrote: > > On 13/05/2023 09:27, Robert Landers wrote: > > Hello Internals, > > > > It is with much trepidation and excitement that I'd like to announce > > the nameof RFC (https://wiki.php.net/rfc/nameof). It has > > changed > > quite a bit in the last couple of days, so if you haven't seen the > > latest draft, please check it out. > > > > Essentially, it allows using nameof() anywhere a string > > can be used, > > even in static contexts. From a developer's perspective, it is a > > string and from the engine's perspective, it is also mostly a string > > (depending on how deep we want to go on error checking -- see the > > RFC). > > > > If anything is unclear or if I missed something, please let me know. > > > > Robert Landers > > Software Engineer > > Utrecht NL > > > > Hello Robert > > Thank you for doing the proposal. I can see some places where I might use this. > > I have an additional question that I don't think has been asked yet. About the interaction > of nameof with "variable variables": > What should be returned by nameof($$variable), and similarly > nameof($$$variable), etc? > Defining the semantics for this, and giving examples in the RFC text would be great :) > > Good luck with your RFC. > > Cheers > Niels That is a good question. It should be a compile error due to ambiguity. I'll update the RFC to include that. $variable would already be the name of the variable being referenced by $$variable, so if you want the name of $variable, just get the name of $variable, and if you want the name of $$variable, just get the value of $variable.

« previous php.internals (#120264) next »