|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #48246 Allow the new statement to be a value.
Submitted: 2009-05-12 14:53 UTC Modified: 2010-11-23 10:33 UTC
From: mathieu dot suen at easyflirt dot com Assigned:
Status: Duplicate Package: *General Issues
PHP Version: 5.2.9 OS: not relevant
Private report: No CVE-ID: None
 [2009-05-12 14:53 UTC] mathieu dot suen at easyflirt dot com
The new statement can only be use insid a assignement statement.
ex: $a = new A();

It would be better to also allow it in other statement like the invokation:

(new A())->foo()

In other word "new A()" should be a valuable statement.

Reproduce code:
(new A())->foo()

Expected result:
The method foo() is invoked on the newlly created object

Actual result:
Compilation error


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-11-23 10:33 UTC]
-Status: Open +Status: Duplicate -Package: Feature/Change Request +Package: *General Issues
 [2010-11-23 10:33 UTC]
Duplicate of request #34502.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon May 17 01:01:23 2021 UTC