Re: [RFC] [Discussion] nameof

From: Date: Mon, 15 May 2023 18:05:48 +0000
Subject: Re: [RFC] [Discussion] nameof
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-120291@lists.php.net to get a copy of this message
On 15 May 2023 14:07:31 BST, Lydia de Jongh <flexjoly@gmail.com> wrote: >> ... >> #[SomeAttribute(callback: nameof(\Acme\bar(...))] >> ... > >This callback to nameof()..... is really terrible 😣😣 Just to be clear, the "callback:" in that example is existing syntax for named parameters, not part of the nameof() syntax. A positional parameter would just look like this: #[SomeAttribute(nameof(\Acme\bar(...))] That's the same number of characters as this: #[SomeAttribute(\Acme\bar(...)::nameof] The main difference is the the function-ish syntax makes it a bit clearer what you're asking for the name of, because the whole thing is in parentheses. There might even be cases where the function-ish syntax needs additional parentheses anyway, like are needed in (new Something)->doSomething() Changing "nameof" to "function", "method", etc depending on type doesn't really add anything, since the output is always a string anyway, not some type-specific thing. Regards, -- Rowan Tommins [IMSoP]

« previous php.internals (#120291) next »