<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/discussion-revisiting-typed-closures-rfepn6m1q" -->

---
title: [Discussion] Revisiting typed closures | daily.dev
description: A PHP internals mailing list discussion revisiting the idea of typed closure signatures in PHP, e.g. `Closure(int, string): array`. The proposal would allow...
canonical: https://daily.dev/posts/discussion-revisiting-typed-closures-rfepn6m1q
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: [Discussion] Revisiting typed closures | daily.dev
og:description: A PHP internals mailing list discussion revisiting the idea of typed closure signatures in PHP, e.g. `Closure(int, string): array`. The proposal would allow...
og:url: https://daily.dev/posts/discussion-revisiting-typed-closures-rfepn6m1q
og:image: https://api.daily.dev/og/posts/rfePn6m1Q.png
og:image:alt: [Discussion] Revisiting typed closures
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# [Discussion] Revisiting typed closures

**[externals.io](https://daily.dev/sources/externals)** · 23 min read · 1 upvotes · 0 comments

## Summary

A PHP internals mailing list discussion revisiting the idea of typed closure signatures in PHP, e.g. `Closure(int, string): array`. The proposal would allow runtime enforcement of a closure's parameter and return types at type boundaries. The thread covers prior art (declined Callable Prototypes RFC from 2016, two 2023 draft RFCs), debate over whether to scope it to Closure only vs. callable, why generics are not a substitute (variadic generics would be needed and are far off), whether inline syntax vs. named delegate/alias syntax is preferable, and the relationship to a future type aliases feature. Key contributors include Larry Garfield, Rowan Tommins, and others from PHP internals.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://externals.io/message/131781>

## Questions this post answers

### Can PHP closures currently be typed with their parameter and return types, like Closure(int, string): array?

No, PHP only allows typing a closure as the generic Closure or callable, neither of which expresses its parameters or return type. A proposal to add such typed call signatures, enforced at type boundaries like arguments, returns, and properties, is under discussion in PHP internals but has not been formally proposed as an RFC.

_Developers weighing PHP's evolving type system can follow proposals like this on daily.dev before committing to a coding style._

### Why can't PHP use Closure(int): array as type syntax without ambiguity?

The syntax collides at the lexer level because (int) is already a cast token, the same conflict applies to (string), (array), and similar casts. A prior attempt to fix this tokenization issue was rejected as a backwards-compatibility break to the token stream, so any typed closure syntax proposal must work around this engine limitation.

_Anyone tracking PHP syntax proposals that touch the parser can follow the debate on daily.dev to avoid surprises later._

### Was PHP's Callable Prototypes RFC ever accepted?

No, Callable Prototypes was declined in 2016. Since then, related proposals including Structural Typing for Closures and Allow Closures to Declare Interfaces they Implement, both from 2023, remain in draft, and a separate Functional Interfaces RFC also failed to gain traction, with concerns raised that anonymous classes could serve the same purpose.

_Developers deciding whether to rely on future PHP typing features can track this history via daily.dev before adopting workarounds._

## Similar posts on daily.dev

- [\[RFC\] \[Discussion\] Serializable closures from constant expressions](https://daily.dev/posts/rfc-discussion-serializable-closures-from-constant-expressions-vflymqvec) · externals.io · 0 upvotes · 0 comments
- [\[RFC\] \[Discussion\] Bound-Erased Generic Types](https://daily.dev/posts/rfc-discussion-bound-erased-generic-types-ze8fx3ymf) · externals.io · 0 upvotes · 0 comments
- [\[RFC\] Scope functions](https://daily.dev/posts/rfc-scope-functions-mm4kxzaa0) · externals.io · 0 upvotes · 0 comments

---

Tags: [#php](https://daily.dev/tags/php)

[View this post on daily.dev](https://daily.dev/posts/discussion-revisiting-typed-closures-rfepn6m1q)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"[Discussion] Revisiting typed closures","url":"https://daily.dev/posts/discussion-revisiting-typed-closures-rfepn6m1q","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/discussion-revisiting-typed-closures-rfepn6m1q"},"datePublished":"2026-07-06T20:58:06.085Z","dateModified":"2026-09-13T20:40:28.278Z","description":"A PHP internals mailing list discussion revisiting the idea of typed closure signatures in PHP, e.g. `Closure(int, string): array`. The proposal would allow...","image":"https://media.daily.dev/image/upload/s--1KxV4ohY--/f_auto/v1722860400/public/Placeholder%2007","thumbnailUrl":"https://media.daily.dev/image/upload/s--1KxV4ohY--/f_auto/v1722860400/public/Placeholder%2007","isAccessibleForFree":true,"articleSection":"externals.io","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"externals.io","logo":"https://media.daily.dev/image/upload/s--9i0zxASK--/f_auto,q_auto/v1780213616/logos/externals?_a=BAMAMiWQ0","url":"https://daily.dev/sources/externals"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/discussion-revisiting-typed-closures-rfepn6m1q","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"php","timeRequired":"PT23M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"externals.io","item":"https://daily.dev/sources/externals"},{"@type":"ListItem","position":3,"name":"[Discussion] Revisiting typed closures"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/discussion-revisiting-typed-closures-rfepn6m1q#faq","mainEntity":[{"@type":"Question","name":"Can PHP closures currently be typed with their parameter and return types, like Closure(int, string): array?","acceptedAnswer":{"@type":"Answer","text":"No, PHP only allows typing a closure as the generic Closure or callable, neither of which expresses its parameters or return type. A proposal to add such typed call signatures, enforced at type boundaries like arguments, returns, and properties, is under discussion in PHP internals but has not been formally proposed as an RFC. Developers weighing PHP's evolving type system can follow proposals like this on daily.dev before committing to a coding style."}},{"@type":"Question","name":"Why can't PHP use Closure(int): array as type syntax without ambiguity?","acceptedAnswer":{"@type":"Answer","text":"The syntax collides at the lexer level because (int) is already a cast token, the same conflict applies to (string), (array), and similar casts. A prior attempt to fix this tokenization issue was rejected as a backwards-compatibility break to the token stream, so any typed closure syntax proposal must work around this engine limitation. Anyone tracking PHP syntax proposals that touch the parser can follow the debate on daily.dev to avoid surprises later."}},{"@type":"Question","name":"Was PHP's Callable Prototypes RFC ever accepted?","acceptedAnswer":{"@type":"Answer","text":"No, Callable Prototypes was declined in 2016. Since then, related proposals including Structural Typing for Closures and Allow Closures to Declare Interfaces they Implement, both from 2023, remain in draft, and a separate Functional Interfaces RFC also failed to gain traction, with concerns raised that anonymous classes could serve the same purpose. Developers deciding whether to rely on future PHP typing features can track this history via daily.dev before adopting workarounds."}}]}
```

