Re: [PHP-DEV] Null-safe property access in interpolated strings

2020-08-10 Thread Björn Larsson
Hi Ilija, Den 2020-08-10 kl. 17:06, skrev Ilija Tovilo: Hi Nikita I think if it can be reasonably fixed it probably would make sense for consistency and WTF-avoidance if anything. Agree. I don't think the question of whether it is useful should come into this, it's a matter of language consi

Re: [PHP-DEV] Null-safe property access in interpolated strings

2020-08-10 Thread Mike Schinkel
> > On Aug 10, 2020 at 11:02 AM, mailto:tovilo.il...@gmail.com)> > wrote: > > > > Hi Mike > $card_html = << {$card->content}HTML; Two things: 1. We're solely > talking about string interpolation without braces {}. You're using braces in > your example and this d

Re: [PHP-DEV] Null-safe property access in interpolated strings

2020-08-10 Thread Ilija Tovilo
Hi Nikita > > I think if it can be reasonably fixed it probably would make sense for > > consistency and WTF-avoidance if anything. > > 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

Re: [PHP-DEV] Null-safe property access in interpolated strings

2020-08-10 Thread Ilija Tovilo
Hi Mike > $card_html = << > {$card->content}HTML; Two things: 1. We're solely talking about string interpolation without braces {}. You're using braces in your example and this does indeed work right now. 2. The semantics of ?-> are different than you're depicting them to be in this examp

Re: [PHP-DEV] Null-safe property access in interpolated strings

2020-08-10 Thread Mike Schinkel
> > On Aug 9, 2020 at 3:00 PM, mailto:deleu...@gmail.com)> wrote: > > > > I like and make use of interpolation, but I can't think of a use case for > this. Is there any valid use case that would benefit from this fix regardless > of personal preference? In other words, w

Re: [PHP-DEV] Null-safe property access in interpolated strings

2020-08-10 Thread Philip Hofstetter
Hi, On Sun, Aug 9, 2020 at 8:34 PM Jordi Boggiano wrote: > Can't say I'm big on interpolation but I'd definitely expect this to > work because why not? A reason why not is because it will break backwards compatibility with existing (though admittedly unlikely) code which also can't be fixed by

Re: [PHP-DEV] Null-safe property access in interpolated strings

2020-08-10 Thread Nikita Popov
On Sun, Aug 9, 2020 at 8:34 PM Jordi Boggiano 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 > > Ca

Re: [PHP-DEV] Null-safe property access in interpolated strings

2020-08-09 Thread Deleu
I like and make use of interpolation, but I can't think of a use case for this. Is there any valid use case that would benefit from this fix regardless of personal preference? In other words, where would one use string interpolation with an empty string being a valid case? On Sun, Aug 9, 2020, 20:

Re: [PHP-DEV] Null-safe property access in interpolated strings

2020-08-09 Thread Jordi Boggiano
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?

Re: [PHP-DEV] Null-safe property access in interpolated strings

2020-08-09 Thread Ilija Tovilo
Hi internals > 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 The patch can be found here: https://github.com/php/php-src/pull/5966 It adds ~5 lines to the lexer. As mentioned, t

Re: [PHP-DEV] Null-safe property access in interpolated strings

2020-08-09 Thread Yousuf Tafhim
What are the good uses cases for this to work? On Sun, Aug 9, 2020 at 8:48 AM Marco Pivetta wrote: > On Sun, Aug 9, 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

Re: [PHP-DEV] Null-safe property access in interpolated strings

2020-08-08 Thread Marco Pivetta
On Sun, Aug 9, 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 > Ooof, people still interpolate strings that way? Good riddance if it

[PHP-DEV] Null-safe property access in interpolated strings

2020-08-08 Thread Sara Golemon
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