Req #55247 [Asn->Csd]: Parser problem with static calls using string method name
Edit report at https://bugs.php.net/bug.php?id=55247&edit=1
ID: 55247
Updated by: dmitry@php.net
Reported by: gehrig at teqneers dot de
Summary: Parser problem with static calls using string method
name
-Status: Assigned
+Status: Closed
Type: Feature/Change Request
Package: *General Issues
Operating System: Darwin 10.8.0
PHP Version: 5.3.6
Assigned To: dmitry
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in SVN.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
For Windows:
http://windows.php.net/snapshots/
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2011-07-27 04:46:58] pierrick@php.net
The following patch has been added/updated:
Patch Name: 55247.diff
Revision: 1311742018
URL: https://bugs.php.net/patch-display.php?bug=55247&patch=55247.diff&revision=1311742018
------------------------------------------------------------------------
[2011-07-22 18:53:20] felipe@php.net
It isn't supposed to work, so not a bug.
Changed to feature request.
------------------------------------------------------------------------
[2011-07-20 05:55:26] gehrig at teqneers dot de
Description:
------------
PHP allows to call instance methods using the {} syntax together with a string -
such as $obj->{'my-method'} for example. This allows developers to call methods
whose names are not valid PHP method names.
The same does not work with static method calls.
Test script:
---------------
<?php
class Test{
public static function __callStatic($method, $arguments)
{
echo $method . PHP_EOL;
}
public function __call($method, $arguments)
{
echo $method . PHP_EOL;
}
}
$method = 'method';
$test = new Test();
$test->method();
$test->$method();
$test->{'method'}();
Test::method();
Test::$method();
Test::{'method'}();
Expected result:
----------------
method
method
method
method
method
method
Actual result:
--------------
PHP Parse error: syntax error, unexpected '{', expecting T_STRING or T_VARIABLE
or '$' in Untitled.php on line 21
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55247&edit=1
Thread (4 messages)