Re: Null-safe property access in interpolated strings
| From: | Nikita Popov | Date: | Mon, 10 Aug 2020 10:33:22 +0000 |
| Subject: | Re: Null-safe property access in interpolated strings | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-111420@lists.php.net to get a copy of this message | ||
On Sun, Aug 9, 2020 at 8:34 PM Jordi Boggiano <j.boggiano@seld.be> wrote:
> On 09/08/2020 00:17, Sara Golemon wrote:
> > Do we expect this to work?
> >
> > $foo = new stdClass;
> > $foo->bar = "Hello";
> > echo "$foo?->bar world\n";
> >
> > Because at the moment it doesn't:
> > https://3v4l.org/nLv3l
> >
> > -Sara
>
> Can't say I'm big on interpolation but I'd definitely expect this to
> work because why not?
>
> I think if it can be reasonably fixed it probably would make sense for
> consistency and WTF-avoidance if anything.
>
> Best,
> Jordi
>
Agree. I don't think the question of whether it is useful should come into
this, it's a matter of language consistency. There could be some leeway
here if we say that we have plans to deprecate the "$x->y" syntax in the
future anyway and don't want to extend it anymore -- but I don't believe we
have such plans at the present time.
Nikita