A PHP internals mailing list discussion revisiting the idea of typed closure signatures in PHP, e.g. `Closure(int, string): array`. Currently PHP only allows typing closures as `Closure` or `callable`, with no way to express parameter or return types at the type boundary. The thread references prior declined and draft RFCs (Callable Prototypes 2016, Structural Typing for Closures 2023, functional interfaces). Participants debate whether to pursue this independently or wait for generics to make Closure a generic type. The concrete use case is catching mismatched higher-order callbacks at the call site rather than deep inside an operation or only via static analysis annotations. One participant suggests extending the concept to `callable(int):bool` for broader coverage beyond just closures.

5m read timeFrom externals.io
Post cover image
68 Impressions