From: a at b dot c dot de
Operating system: Windows (irrelevant)
PHP version: 5.3.0alpha3
PHP Bug Type: Feature/Change Request
Bug description: $foo() syntax is too limited
Description:
------------
It's already possible to have arrays that represent callable methods
(either static or instance), and 5.3's closures offer a third type of
"callable" function.
But the $foo() syntax that facilitates calling that callable function
still requires $foo to contain a string.
Since in general one cannot know in advance just what type of callable the
value of $foo actually is, and when one does know it's often NOT a string,
it's necessary to forego the syntax and rely on call_user_func($foo).
What would be nice is if $foo() also worked in the cases where $foo was a
callable array or Closure object. call_user_func() itself would largely be
relegated to the status of "function equivalent should you need it" and
complement to call_user_func_array().
Reproduce code:
---------------
<?php
// For 5.2.x as well.
class Thing {
static function DoesStuff() {
echo 'Hello, World';
}
}
$f = array('Thing', 'DoesStuff');
$f();
?>
Expected result:
----------------
Hello, World
Actual result:
--------------
Fatal error: Function name must be a string in C:\test.php on line 11
--
Edit bug report at http://bugs.php.net/?id=47160&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=47160&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=47160&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=47160&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=47160&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=47160&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=47160&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=47160&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=47160&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=47160&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=47160&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=47160&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=47160&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=47160&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=47160&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47160&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=47160&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=47160&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=47160&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=47160&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=47160&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=47160&r=mysqlcfg