Re: [RFC] Variable syntax tweaks

From: Date: Tue, 07 Jan 2020 10:42:26 +0000
Subject: Re: [RFC] Variable syntax tweaks
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-108024@lists.php.net to get a copy of this message
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) ); Another edge case of an edge case, of course, but a mark against that option in my view. :) Regards, -- Rowan Tommins [IMSoP]

« previous php.internals (#108024) next »