#44026 [NEW]: new AnObject->method(); can't work

From: Date: Sun, 03 Feb 2008 01:15:42 +0000
Subject: #44026 [NEW]: new AnObject->method(); can't work
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-121914@lists.php.net to get a copy of this message
From: giorgio dot liscio at email dot it Operating system: winxpsp2 / Apache 2 PHP version: 5.2.5 PHP Bug Type: Feature/Change Request Bug description: new AnObject->method(); can't work Description: ------------ Hello, i'm asking for a feature change in PHP in java this code works nice MyClass object = new MyClass().someMethod(); in php not too. It is possible make working this syntax? thank you [for creating my favourite language] :) Reproduce code: --------------- <?php /* JAVA CODE: class TestPhp { public TestPhp() {System.out.print("Construct ");} public TestPhp method1() {System.out.print("Method1 "); return this;} public TestPhp method2() {System.out.print("Method2 "); return this;} public static void main(String []args) {TestPhp obj = new TestPhp().method1().method1();} } */ class TestPhp { public function __construct() {echo("Construct ");} public function method1() {echo("Method1 "); return $this;} public function method2() {echo("Method2 "); return $this;} public static main() {$obj = new TestPhp()->method1()->method2();} } TestPhp::main(); ?> Expected result: ---------------- Construct Method1 Method2 Actual result: -------------- (Fatal Error) -- Edit bug report at http://bugs.php.net/?id=44026&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=44026&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44026&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44026&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44026&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=44026&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=44026&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=44026&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=44026&r=needscript Try newer version: http://bugs.php.net/fix.php?id=44026&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=44026&r=support Expected behavior: http://bugs.php.net/fix.php?id=44026&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=44026&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=44026&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=44026&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=44026&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=44026&r=dst IIS Stability: http://bugs.php.net/fix.php?id=44026&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=44026&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=44026&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=44026&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=44026&r=mysqlcfg

« previous php.bugs (#121914) next »