#34502 [Opn]: method chaining on constructor causes parse error

From: Date: Wed, 14 Sep 2005 19:26:51 +0000
Subject: #34502 [Opn]: method chaining on constructor causes parse error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-85052@lists.php.net to get a copy of this message
ID: 34502 Updated by: derick@php.net Reported By: goat at daholygoat dot com Status: Open -Bug Type: Class/Object related +Bug Type: Feature/Change Request Operating System: Linux PHP Version: 5.0.5 New Comment: I think this is simply not supported right now, so marking as a Feature Request Previous Comments: ------------------------------------------------------------------------ [2005-09-14 21:14:57] goat at daholygoat dot com Description: ------------ When doing method chaining on a constructor (without seperately instantiating the object first), a parse error occurs. Reproduce code: --------------- class A { private $str; function A($str) { $this->str = $str; } function returnStr() { return $str; } } echo new A("hello")->returnStr(); Expected result: ---------------- The reference to an object of A created with A's constructor would allow me to call returnStr() on it. Actual result: -------------- I'm getting a parse error. PHP Parse error: parse error, unexpected T_OBJECT_OPERATOR, expecting ',' or ';' ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=34502&edit=1

« previous php.bugs (#85052) next »