Re: [RFC] Variable syntax tweaks

From: Date: Tue, 07 Jan 2020 12:08:06 +0000
Subject: Re: [RFC] Variable syntax tweaks
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-108025@lists.php.net to get a copy of this message
On Tue, Jan 7, 2020 at 11:43 AM Rowan Tommins <rowan.collins@gmail.com> wrote: > On Tue, 7 Jan 2020 at 10:23, Nikita Popov <nikita.ppv@gmail.com> wrote: > > > I'd like to propose a small RFC, which addresses a few minor issues that > > have not been handled by the original "uniform variable syntax" RFC: > > > > https://wiki.php.net/rfc/variable_syntax_tweaks > > > > > Hi Nikita, > > Thanks for this, I'm definitely a fan of this kind of consistency, even if > it rarely matters in practice. :) > > Regarding instanceof, and specifically your last alternative: > > > The second possibility is to relax the restrictions around the > right-hand-side of instanceof entirely. This would involve treating it as a > normal expression, and then reinterpreting plain constant accesses as class > name references instead. > > Am I right in thinking that another disadvantage of this is that you > couldn't use a bare constant to define a class name, thus introducing a new > inconsistency? That is, using a bracketed form, it should be possible to > write: > > const CLASS_NAME='MyClass'; > var_dump( $string instanceof {CLASS_NAME} ); > > or: > > const CLASS_NAME='MyClass'; > var_dump( $string instanceof (CLASS_NAME) ); > > but using the "reinterpreted expression" option, you'd need to do something > hacky to force the interpretation as a constant, like: > > const CLASS_NAME='MyClass'; > var_dump( $string instanceof ('' . CLASS_NAME) ); > If we went with this option, we'd only interpret a plain "constant" access as a class name reference. "instanceof (FOO)" should definitely be interpreted as a constant access, not a class reference. Nikita

« previous php.internals (#108025) next »