|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #45724 correct "new Object()->method()"
Submitted: 2008-08-05 12:31 UTC Modified: 2010-11-23 10:33 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: bastard_man at hotmail dot co dot uk Assigned:
Status: Duplicate Package: *General Issues
PHP Version: 5.3CVS-2008-08-05 (CVS) OS: XP/Ubuntu
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
22 + 10 = ?
Subscribe to this entry?

 [2008-08-05 12:31 UTC] bastard_man at hotmail dot co dot uk
can you help me with a feature change in PHP?
in java this code works well

AClass object = new AClass().aMethod();

in php it doesnt.

It is possible to correct this so the syntax is valid?

Reproduce code:
class AClass
	public function __construct()
		{echo("a"); /* return $this; ???? */ }
	public function method1()
		{echo("b"); return $this;}
	public function method2()
		{echo("c"); return $this;}
	public static main()
		{$obj = new TestPhp()->method1()->method2();}

Expected result:

Actual result:
(Fatal 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: Thu Dec 02 16:03:40 2021 UTC