Re: [RFC] new foo()->bar()
| From: | Johannes Schlüter | Date: | Fri, 26 Nov 2010 20:21:43 +0000 |
| Subject: | Re: [RFC] new foo()->bar() | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-50595@lists.php.net to get a copy of this message | ||
On Fri, 2010-11-26 at 17:36 -0200, Felipe Pena wrote:
> var_dump(new foo()->bar()->x); // string(3) "PHP"
It has some readability issues. One might assume it is
new (foo()->bar()->x)
not
(new foo())->bar()->x
As there is a mandatory space between "new" and its operand and no space
in front of the object operator and we allow non-constant operands to
"new".
So what is
new $bar->foo();
? If I read the patch correctly this is valid and evaluated as
(new $bar)->foo();
johannes