On 05.04.2021 at 19:19, Ben Ramsey wrote:

>> On Apr 5, 2021, at 12:12, Christoph M. Becker <cmbecke...@gmx.de> wrote:
>>
>> On 05.04.2021 at 18:40, André Hänsel wrote:
>>
>>> I was wondering... PHP is the only language I know of where you have to
>>> write `(new Foo())->bar()` instead of
>>> `new Foo()->bar()`. This is particularly apparent with the builder pattern:
>>>
>>> $developer->drink((new Coffee())->withCream()->withSugar());
>>> $logger->log((new LogMessage())->withMessage('Coffee was drunk'));
>>>
>>> Since `new Foo()->bar()` cannot (and probably should not) be used to
>>> "dynamically instantiate a new thing of the class
>>> name returned by function Foo()", it seems like it would be no problem to
>>> change the precedence rules so that
>>> `new Foo()->bar()` means "instantiate a new Foo and call bar() on it".
>>>
>>> It's currently a syntax error, so allowing it would be automatically
>>> compatible.
>>>
>>> Has this ever been discussed before?
>>
>> See <https://bugs.php.net/bug.php?id=70549>.
>
> The last comment on that issue reads:
>
>> @Nikic
>> Good news. I'll prepare RFC for 7.1.
>
> Was there an RFC for it? I can’t find one.

I don't think there ever was an RFC for this.

--
Christoph M. Becker

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to