Re: [RFC] [Discussion] new MyClass()->method() without parentheses
| From: | Alexandru Pătrănescu | Date: | Tue, 23 Apr 2024 13:54:52 +0000 |
| Subject: | Re: [RFC] [Discussion] new MyClass()->method() without parentheses | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-123185@lists.php.net to get a copy of this message | ||
On Tue, Apr 23, 2024 at 3:31 PM Robert Landers <landers.robert@gmail.com>
wrote:
> On Tue, Apr 23, 2024 at 11:10 AM Valentin Udaltsov
> <udaltsov.valentin@gmail.com> wrote:
> >
> >
> > Does anyone have additional feedback? I'd like to start voting on
> Thursday, April 25th.
> > I've also added a section on other syntax ideas that have been expressed
> on Twitter and in the PR:
>
> https://wiki.php.net/rfc/new_without_parentheses#other_syntax_ideas
> > --
> > Valentin
>
> I suspect this will break (badly written) reflection in interesting ways:
>
> https://3v4l.org/mcSNH
>
> This basically breaks dereferencing order of operations and makes it
> inconsistent.
>
Quote from RFC:
"RFC still does not allow to omit parentheses around the new expression
*without* constructor arguments' parentheses, because in some cases this
leads to an ambiguity"
And actually it mentions a list in the RFC:
// Instantiate and then access the instance or instantiate the result
of the expression?new MyClass::CONSTANT
<http://www.php.net/constant>;new
MyClass::$staticProperty;new
$myClass::CONSTANT <http://www.php.net/constant>;new
$myClass::$staticProperty;new $myClass->property;new
$myClass->method();
But actually from all of those, right now, only "new MyClass::CONSTANT
<http://www.php.net/constant>;" and "*new*
$myClass::CONSTANT
<http://www.php.net/constant>;" are not
working, while the other 4 are
working fine.
So yeah, this needs clarification if they continue to work as they work
right now:
https://3v4l.org/PmCfR
Thanks,
Alex