From:
Operating system: Irrelevant
PHP version: 5.3.5
Package: Class/Object related
Bug Type: Feature/Change Request
Bug description:"new" keyword vs. call_user_func
Description:
------------
When one defines a class with __callStatic() which under some circumstances
accepts method name of "new", it may not be called. However, with __call(),
it may
be called. May be solved using call_user_func(), but that loses the nice
syntax.
Personally, I don't get it why "new" is parsed as T_NEW after "Base::" and
not
after $base->.
Test script:
---------------
<?php
class Base {
public static function __callStatic($method, $args) {
if ($method == 'new')
echo 'Base::new() called successfully';
}
public function __call($method, $args) {
if ($method == 'new')
echo '$base->new() called successfully';
}
}
$base = Base::new();
call_user_func(array('Base', 'new');
$base = new Base;
$base->new();
?>
Expected result:
----------------
Base::new() called successfully
Base::new() called successfully
$base->new() called successfully
Actual result:
--------------
Parse error: syntax error, unexpected T_NEW, expecting T_STRING or
T_VARIABLE or
'$' in C:\inetpub\wwwroot\test.php on line 14
--
Edit bug report at http://bugs.php.net/bug.php?id=53697&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=53697&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=53697&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=53697&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=53697&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=53697&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=53697&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=53697&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=53697&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=53697&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=53697&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=53697&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=53697&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=53697&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=53697&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53697&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=53697&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=53697&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=53697&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=53697&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=53697&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=53697&r=mysqlcfg