php.net |  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
Votes:1
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
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
Description:
------------
Hello,
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();}
}
AClass::main();

Expected result:
----------------
abc

Actual result:
--------------
(Fatal Error)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-11-23 10:33 UTC] aharvey@php.net
-Status: Open +Status: Duplicate -Package: Feature/Change Request +Package: *General Issues
 [2010-11-23 10:33 UTC] aharvey@php.net
Duplicate of request #34502.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 11:01:30 2024 UTC