|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75186 Inconsistent reflection of Closure:::__invoke()
Submitted: 2017-09-11 12:37 UTC Modified: 2018-10-02 16:49 UTC
Avg. Score:2.0 ± 1.0
Reproduced:0 of 2 (0.0%)
From: kontakt at kukulich dot cz Assigned: nikic (profile)
Status: Closed Package: Reflection related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2017-09-11 12:37 UTC] kontakt at kukulich dot cz

Test script:

$rc = new ReflectionClass(Closure::class);

$methodNames = array_map(function ($m) {
   return $m->getName();
}, $rc->getMethods());

var_dump(in_array('__invoke', $methodNames));

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-02-07 16:02 UTC] carusogabriel34 at gmail dot com
Could not reproduced
 [2018-02-07 20:24 UTC] kontakt at kukulich dot cz
See the test in the description.
 [2018-02-28 20:08 UTC] carusogabriel34 at gmail dot com
From the documentation:
> Besides the methods listed here, this class also has an __invoke method. This is for consistency with other classes that implement calling magic, as this method is not used for calling the function.

So I believe is the expected behavior.
 [2018-10-02 16:49 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: nikic
 [2018-10-02 16:49 UTC]
It looks like we have a bunch of special-casing for Closure::__invoke, but getMethods() in particular only uses it if the reflection is on an object rather than class.
 [2019-05-09 10:36 UTC]
Automatic comment on behalf of
Log: Fixed bug #75186
 [2019-05-09 10:36 UTC]
-Status: Assigned +Status: Closed
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Mar 28 16:20:31 2023 UTC