Re: [Discussion] Revisiting typed closures
| From: | Joe Watkins | Date: | Wed, 01 Jul 2026 15:17:51 +0000 |
| Subject: | Re: [Discussion] Revisiting typed closures | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-131658@lists.php.net to get a copy of this message | ||
There was also this: https://wiki.php.net/rfc/functional-interfaces
A re-reading of the very brief thread, shows Dmitry thought it an inelegant
use/abuse of the type system, and more generally there was a feeling that
anon classes could be used in their place.
Cheers
Joe
On Wed, 1 Jul 2026, 16:44 Matheus Martins, <mathrm@gmail.com> wrote:
> Hello internals,
>
> I would like to revisit the idea of giving closures a typed call signature.
>
> e.g. Closure(int, string): array -- enforced at the point a value crosses a
> type boundary (an argument, a return, a property), the same places any
> other
> type is checked.
>
> Today a closure can only be typed as Closure or callable, neither of which
> says anything about its parameters or return, even though that information
> is
> right there.
>
> I know this is not new ground: Callable Prototypes was declined in 2016,
> and
> Garfield and Grekas shared two further RFCs in 2023 -- Structural Typing
> for
> Closures, and Allow Closures to Declare Interfaces they Implement -- both
> still
> in draft.
>
> Before taking it further, I would like to know whether closure typing
> is still considered worth pursuing -- or whether the topic is now regarded
> as
> settled.
>
> References:
>
> - https://wiki.php.net/rfc/callable-types
> - https://wiki.php.net/rfc/structural-typing-for-closures
> -
>
> https://wiki.php.net/rfc/allow-closures-to-declare-interfaces-they-implement
>
> Thanks.
>