php.net |  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
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: brandon at brandonsavage dot net Assigned: felipe (profile)
Status: Closed Package: Reflection related
PHP Version: 5.3.2 OS: All
Private report: No CVE-ID: None
 [2010-06-11 23:08 UTC] 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


Patches

Pull Requests

History

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] felipe@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: felipe
 [2010-06-12 01:37 UTC] felipe@php.net
-Status: Assigned +Status: Closed
 [2010-06-12 01:37 UTC] felipe@php.net
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
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2010-06-12 01:37 UTC] felipe@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&revision=300393
Log: - Fixed bug #52057 (ReflectionClass fails on Closure class)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC