Re: [PHP-DEV] Raising the precedence of the new operator

2021-04-05 Thread Marco Pivetta
On Mon, Apr 5, 2021, 22:51 Marco Pivetta wrote: > > > On Mon, Apr 5, 2021, 19:42 Mike Schinkel wrote: > >> >> > On Apr 5, 2021, at 12:47 PM, Ben Ramsey wrote: >> > >> >> On Apr 5, 2021, at 11:40, André Hänsel wrote: >> >> >> >> I was wondering... PHP is the only language I know of where you

Re: [PHP-DEV] Raising the precedence of the new operator

2021-04-05 Thread Marco Pivetta
On Mon, Apr 5, 2021, 19:42 Mike Schinkel wrote: > > > On Apr 5, 2021, at 12:47 PM, Ben Ramsey wrote: > > > >> On Apr 5, 2021, at 11: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

Re: [PHP-DEV] Raising the precedence of the new operator

2021-04-05 Thread Christoph M. Becker
On 05.04.2021 at 19:19, Ben Ramsey wrote: >> On Apr 5, 2021, at 12:12, Christoph M. Becker 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()`.

RE: [PHP-DEV] Raising the precedence of the new operator

2021-04-05 Thread André Hänsel
Rowan Tommins wrote: > it was looking for a property $bar, not a method bar(). Working version: > https://3v4l.org/S9gLf Oh, right. > we would need to allow a more restricted version, as discussed on that > feature request. Yeah, that would be great. I think it would already cover the by far

Re: [PHP-DEV] Raising the precedence of the new operator

2021-04-05 Thread Stanislav Malyshev
Hi! On 4/5/21 9:40 AM, 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: Enabling something that is syntax error now sounds pretty

Re: [PHP-DEV] Raising the precedence of the new operator

2021-04-05 Thread Rowan Tommins
On 05/04/2021 20:51, André Hänsel wrote: Note that in that bug entry the solution was based on the premise that `$obj = new $foo->bar();` was valid code, which it isn't. (https://3v4l.org/lpN1T) Looking at the error message, that code parsed as valid, but failed at run-time, because it was

RE: [PHP-DEV] Raising the precedence of the new operator

2021-04-05 Thread André Hänsel
Mike Schinkel wrote: > I had asked Ben what he thought about allowing the following syntax as a > synonym for `new Foo()`: > > Foo::new() This can already be done in application code, having the language add a synonym is IMO unnecessary magic and breaks the principle of the least surprise.

Re: [PHP-DEV] Raising the precedence of the new operator

2021-04-05 Thread Mike Schinkel
> On Apr 5, 2021, at 1:51 PM, Claude Pache wrote: > >> Le 5 avr. 2021 à 19:42, Mike Schinkel a écrit : >> >> Foo::new() >> >> That would be backward compatible because you currently cannot have a method >> named `new()`. > > Really? The following compiles without hiccup for me:

Re: [PHP-DEV] Raising the precedence of the new operator

2021-04-05 Thread Claude Pache
> Le 5 avr. 2021 à 19:42, Mike Schinkel a écrit : > > Foo::new() > > That would be backward compatible because you currently cannot have a method > named `new()`. Really? The following compiles without hiccup for me: https://3v4l.org/Vb5Sj —Claude

Re: [PHP-DEV] Raising the precedence of the new operator

2021-04-05 Thread Mike Schinkel
> On Apr 5, 2021, at 12:47 PM, Ben Ramsey wrote: > >> On Apr 5, 2021, at 11: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

Re: [PHP-DEV] Raising the precedence of the new operator

2021-04-05 Thread Ben Ramsey
> On Apr 5, 2021, at 12:12, Christoph M. Becker 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

Re: [PHP-DEV] Raising the precedence of the new operator

2021-04-05 Thread Ben Ramsey
> On Apr 5, 2021, at 11: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

[PHP-DEV] Raising the precedence of the new operator

2021-04-05 Thread André Hänsel
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