Re: Re: [VOTE] nullsafe operator RFC
| From: | Ilija Tovilo | Date: | Sat, 08 Aug 2020 20:42:36 +0000 |
| Subject: | Re: Re: [VOTE] nullsafe operator RFC | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-111382@lists.php.net to get a copy of this message | ||
Hi again
> > I just noticed that while we support "$a->b", we do not support
> > "$a?->b" (the quotes are relevant -- I'm talking about interpolated strings here).
> > That is, in the latter case the "?->b" is just treated like a string part, not like a
> > property access.
> >
> > I don't think the behavior for this case has been discussed and I'm not sure
> > what the intended behavior here is.
>
> I missed that one. There's a test for var_dump("{$null?->foo}"); but
> not one without the braces. I would classify this as a bug and expect
> this to behave the same as -> (but not erroring on null obviously).
> Worth noting that chaining won't work as it doesn't work for ->
> either.
>
> Sara/Gabriel, What do you think? Should we fix this? I'm assuming this
> will only require a change in the grammar but I haven't checked yet.
Just as I sent this I realized this is technically a breaking change,
probably a small one but still worth mentioning. I'm now also not
totally sure if we should change it at this point. Let me know what
you think.
Ilija