Re: [PHP-DEV] [Discussion] Revisiting typed closures

[email protected] (Joe Watkins)
Newsgroups php.internals
Message-ID <CAOwTYAsvJVLkW+Qd38S_MPrSE3dtcLuj6rtWGRemeeB+A+1ZhA@mail.gmail.com>
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, <[email protected]> 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.
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.