Req #45724 [Opn->Dup]: correct "new Object()->method()"

From: Date: Tue, 23 Nov 2010 09:33:23 +0000
Subject: Req #45724 [Opn->Dup]: correct "new Object()->method()"
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-156305@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=45724&edit=1 ID: 45724 Updated by: aharvey@php.net Reported by: bastard_man at hotmail dot co dot uk Summary: correct "new Object()->method()" -Status: Open +Status: Duplicate Type: Feature/Change Request -Package: Feature/Change Request +Package: *General Issues Operating System: XP/Ubuntu PHP Version: 5.3CVS-2008-08-05 (CVS) Block user comment: N Private report: N New Comment: Duplicate of request #34502. Previous Comments: ------------------------------------------------------------------------ [2008-08-05 12:31:07] 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) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=45724&edit=1

« previous php.bugs (#156305) next »