Req #55828 [Opn->Csd]: Instantiation and call in one expression.
Edit report at https://bugs.php.net/bug.php?id=55828&edit=1
ID: 55828
Updated by: nikic@php.net
Reported by: connec dot 2002 at gmail dot com
Summary: Instantiation and call in one expression.
-Status: Open
+Status: Closed
Type: Feature/Change Request
Package: Class/Object related
Operating System: Irrelevant
PHP Version: 5.4.0beta1
-Assigned To:
+Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
This is supported as of PHP 5.4. Parentheses around the new expression are required.
Previous Comments:
------------------------------------------------------------------------
[2011-11-06 16:23:01] php-dev at zerocue dot com
There is an RFC documenting this request here:
https://wiki.php.net/rfc/instance-method-call
I believe one of the patches has been applied to the 5.4 branch per Felipe Pena on 11/6/2011
------------------------------------------------------------------------
[2011-10-04 18:21:00] mikko dot petteri dot hirvonen at gmail dot com
This feature is found on the 5.4 TODO list (https://wiki.php.net/todo/php54) and
even a patch is available at https://wiki.php.net/rfc/instance-method-call,
but
for reasons unknown it is not committed to 5.4 or even trunk.
------------------------------------------------------------------------
[2011-10-04 18:10:15] design at oleku dot org
I totally agree ..
------------------------------------------------------------------------
[2011-10-01 23:49:32] connec dot 2002 at gmail dot com
Description:
------------
It would be nice if object instantiation and calling methods on the object could
occur within the same expression.
Test script:
---------------
class A {
public function method() {
echo "call\n";
}
}
new A(/* args, mayhaps */)->method();
new A->method();
Expected result:
----------------
call
call
Actual result:
--------------
Parse error: syntax error, unexpected '->'
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55828&edit=1
Thread (5 messages)