Edit report at http://bugs.php.net/bug.php?id=52057&edit=1
ID: 52057
Comment by: brandon at brandonsavage dot net
Reported by: brandon at brandonsavage dot net
Summary: ReflectionClass fails on Closure class
Status: Open
Type: Bug
Package: Reflection related
Operating System: All
PHP Version: 5.3.2
New Comment:
I forgot to mention that method_exists() correctly identifies the
presence of __invoke() in the Closure class instance.
Previous Comments:
------------------------------------------------------------------------
[2010-06-11 23:08:24] brandon at brandonsavage dot net
Description:
------------
According to the documentation, the Closure class implements
__construct() and __invoke(). However, when ReflectionClass::hasMethod()
and ReflectionClass::getMethods() are run against a closure, they do not
report the existence of the __invoke() method. On user-defined classes,
the existence of __invoke() is reported if __invoke() is defined.
Test script:
---------------
$closure = function($a) { echo $a; };
$reflection = new ReflectionClass($closure);
var_dump($reflection->hasMethod('__invoke()');
Expected result:
----------------
boolean true
Actual result:
--------------
boolean false
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52057&edit=1