Bug #75186 [Opn->Asn]: Inconsistent reflection of Closure:::__invoke()

From: Date: Tue, 02 Oct 2018 16:49:15 +0000
Subject: Bug #75186 [Opn->Asn]: Inconsistent reflection of Closure:::__invoke()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217367@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75186&edit=1 ID: 75186 Updated by: nikic@php.net Reported by: kontakt at kukulich dot cz Summary: Inconsistent reflection of Closure:::__invoke() -Status: Open +Status: Assigned Type: Bug Package: Reflection related PHP Version: Irrelevant -Assigned To: +Assigned To: nikic Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2018-02-28 20:08:19] 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-02-07 20:24:02] kontakt at kukulich dot cz See the test in the description. ------------------------------------------------------------------------ [2018-02-07 16:02:15] carusogabriel34 at gmail dot com Could not reproduced https://3v4l.org/mGJjd ------------------------------------------------------------------------ [2017-09-11 12:37:00] kontakt at kukulich dot cz Description: ------------ https://3v4l.org/QBIvb Test script: --------------- <?php $rc = new ReflectionClass(Closure::class); $methodNames = array_map(function ($m) { return $m->getName(); }, $rc->getMethods()); var_dump(in_array('__invoke', $methodNames)); var_dump($rc->hasMethod('__invoke')); Expected result: ---------------- bool(true) bool(true) Actual result: -------------- bool(false) bool(true) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75186&edit=1

« previous php.bugs (#217367) next »