|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52057 ReflectionClass fails on Closure class
Submitted: 2010-06-11 23:08 UTC Modified: 2010-06-12 01:37 UTC
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: brandon at brandonsavage dot net Assigned: felipe
Status: Closed Package: Reflection related
PHP Version: 5.3.2 OS: All
Private report: No CVE-ID:
 [2010-06-11 23:08 UTC] brandon at brandonsavage dot net
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);

Expected result:
boolean true

Actual result:
boolean false


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-11 23:15 UTC] brandon at brandonsavage dot net
I forgot to mention that method_exists() correctly identifies the presence of __invoke() in the Closure class instance.
 [2010-06-12 00:56 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: felipe
 [2010-06-12 01:37 UTC]
-Status: Assigned +Status: Closed
 [2010-06-12 01:37 UTC]
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

 [2010-06-12 01:37 UTC]
Automatic comment from SVN on behalf of felipe
Log: - Fixed bug #52057 (ReflectionClass fails on Closure class)
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Tue Oct 13 08:01:52 2015 UTC