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
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 doesn't work: this code is questionable (and not just
because of the question mark in it) ?
What are the good uses cases for this to work?
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 doesn't work: this code is questionable (and not just
because of the question mark in it) ?
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, there is a BC break
although it is probably very small (I could find no code that breaks
on grep.app). Because this BC break was never mentioned in the RFC I'm
leaning towards not merging this patch but I am happy either way.
Let's hear from a few more people what they think until we decide how
to move forward.
Ilija
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
--
Jordi Boggiano
@seldaek - https://seld.be
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?
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--
Jordi Boggiano
@seldaek - https://seld.be--
To unsubscribe, visit: https://www.php.net/unsub.php
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
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 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.
So for the sake of consistency let's merge this then. As mentioned,
the BC break should be very very small. A few people have mentioned
they didn't expect it to work but when asked again they didn't feel
strongly about it.
Unless there are objections I will merge this tomorrow. A review of
the PR would also be welcome.
Ilija
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 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.
So for the sake of consistency let's merge this then. As mentioned,
the BC break should be very very small. A few people have mentioned
they didn't expect it to work but when asked again they didn't feel
strongly about it.Unless there are objections I will merge this tomorrow. A review of
the PR would also be welcome.Ilija
I second Nikitas opinion that consistency is important here. One shouldn't
need to spend time as an PHP end user wondering why we have a special
case that doesn't work like the rest!
Good luck with merging.
r//Björn L
Hi,
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 easy search and replace:
$foo = "gnegg";
echo "$foo?->bar()"
would be fine in PHP < 8 and would blow up with Uncaught Error: Call to a member function bar() on string
with this change.
I'm not saying this is a problem because code like this is unlikely to
be written, but it is a BC break.
Philip