[php-src] Issue #24703: Allow Closure interface
| From: | mvorisek | Date: | Sun, 25 Oct 2026 21:18:14 +0000 |
| Subject: | [php-src] Issue #24703: Allow Closure interface | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-253189@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/24703
Author: mvorisek
### Description
This is a feature request to add
ClosureInterface interface.
It would allow anonymous functions to be runtime checked againts interface using LSP.
What I expect:
1. Closure class to always extend ClosureInterface.
2. interface like:
```
interface FooClosure extends ClosureInterface
{
public function call(object $newThis, bool $p);
}
```
would accept function (bool $x) {} but not function (int $x) {}.
3. throw when class/enum tries to implement it:
```
class Foo implements ClosureInterface {}
```
related past RFCs:
- https://wiki.php.net/rfc/typesafe-callable
- https://wiki.php.net/rfc/callable-interfaces