[php-src] Issue #9423: Closure is not considered a callable when checking signature compatibility

From: Date: Thu, 25 Aug 2022 11:49:07 +0000
Subject: [php-src] Issue #9423: Closure is not considered a callable when checking signature compatibility
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-242308@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/9423 Author: greg0ire ### Description The following code: ```php <?php interface Collection { public function foo(Closure $f): void; } class MyCollection implements Collection { public function foo(callable $f): void { } } ``` Resulted in this output: ``` Fatal error: Declaration of MyCollection::foo(callable $f): void must be compatible with Collection::foo(Closure $f): void in /in/EZVGv on line 10 ``` But I expected no output instead, since a Closure is a callable as hinted in [the docs](https://www.php.net/manual/en/language.types.callable.php): > Apart from common user-defined function, [anonymous > functions](https://www.php.net/manual/en/functions.anonymous.php) and [arrow > functions](https://www.php.net/manual/en/functions.arrow.php) can also be passed to a callback > parameter. ### PHP Version 8.1.9 ### Operating System _No response_

« previous php.bugs (#242308) next »