|  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: bastard_man at hotmail dot co dot uk
New email:
PHP Version: OS:


 [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: Sat Dec 04 09:03:37 2021 UTC