From: mjs at beebo dot org
Operating system: OS X
PHP version: 5.3.0
PHP Bug Type: Feature/Change Request
Bug description: No is_function() to check whether variable is an anonymous
function
Description:
------------
There doesn't seem to be any good way to check whether a variable is a
closure/anonymous function. If
$fn = function() { };
gettype($fn) is "object", and there is no is_function() or equivalent.
The only way seems to be
gettype($fn) == "object" && get_class($fn) == "Closure"
but the anonymous function documentation says that the fact that
anonymous functions have class Closure "is an implementation detail
and should not be relied upon."
I suggest:
1. gettype() returns "function" or "closure" when passed a closure.
2. is_function() is created that returns true when passed a closure,
otherwise false.
--
Edit bug report at http://bugs.php.net/?id=50037&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=50037&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=50037&r=trysnapshot53
Try a snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=50037&r=trysnapshot60
Fixed in SVN:
http://bugs.php.net/fix.php?id=50037&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=50037&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=50037&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=50037&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=50037&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=50037&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=50037&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=50037&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=50037&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=50037&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=50037&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50037&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=50037&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=50037&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=50037&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=50037&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=50037&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=50037&r=mysqlcfg