On Tue, Jan 7, 2020 at 11:43 AM Rowan Tommins <rowan.coll...@gmail.com>
wrote:

> On Tue, 7 Jan 2020 at 10:23, Nikita Popov <nikita....@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

Reply via email to