RFC proposal: Invokable interface
| From: | Osama Aldemeery | Date: | Sun, 29 Mar 2026 21:42:48 +0000 |
| Subject: | RFC proposal: Invokable interface | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-130483@lists.php.net to get a copy of this message | ||
Hi all,
I'd like to propose an Invokable interface, the Stringable equivalent for
__invoke().
The idea has come up a few times over the years (most recently in the PR
#15492 discussion, where Gina suggested this exact approach) but never had
a concrete implementation.
I've put one together: https://github.com/php/php-src/pull/21574
It follows the Stringable pattern: auto-implemented for any class defining
__invoke(), explicitly implementable with enforcement, and covariant to
callable in return type checks.
I'm working on a formal RFC and would love feedback before posting it.
I'd also like to request wiki karma to create the RFC page — my wiki
username is *aldemeery*.
Thanks,
Osama Aldemeery