From:
Operating system: Darwin 10.8.0
PHP version: 5.3.6
Package: *General Issues
Bug Type: Bug
Bug description:Parser problem with static calls using string method name
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 bug report at https://bugs.php.net/bug.php?id=55247&edit=1
--
Try a snapshot (PHP 5.2):
https://bugs.php.net/fix.php?id=55247&r=trysnapshot52
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=55247&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=55247&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=55247&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=55247&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=55247&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=55247&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=55247&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=55247&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=55247&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=55247&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=55247&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=55247&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=55247&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=55247&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=55247&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=55247&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=55247&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=55247&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=55247&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=55247&r=mysqlcfg
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=55247&r=trysnapshot54