Bug->Req #55247 [Opn]: Parser problem with static calls using string method name
| From: | felipe@php.net | Date: | Fri, 22 Jul 2011 22:53:20 +0000 |
| Subject: | Bug->Req #55247 [Opn]: Parser problem with static calls using string method name | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-162117@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=55247&edit=1
ID: 55247
Updated by: felipe@php.net
Reported by: gehrig at teqneers dot de
Summary: Parser problem with static calls using string method
name
Status: Open
-Type: Bug
+Type: Feature/Change Request
Package: *General Issues
Operating System: Darwin 10.8.0
PHP Version: 5.3.6
Block user comment: N
Private report: N
New Comment:
It isn't supposed to work, so not a bug.
Changed to feature request.
Previous Comments:
------------------------------------------------------------------------
[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