Skip to content

Serialize closures declared in constant expressions#4

Open
nicolas-grekas wants to merge 1 commit into
masterfrom
serializable-closures
Open

Serialize closures declared in constant expressions#4
nicolas-grekas wants to merge 1 commit into
masterfrom
serializable-closures

Conversation

@nicolas-grekas

@nicolas-grekas nicolas-grekas commented Jun 10, 2026

Copy link
Copy Markdown
Owner

RFC: https://wiki.php.net/rfc/serializable_closures

Closures declared in constant expressions of a class member (anonymous closures and first-class callables, of any visibility) become serializable as references to their declaration site: class name, deterministic per-class id, start line. unserialize() resolves the reference against the loaded class; payloads contain no code and can only designate closures that classes declare. Runtime-created closures keep refusing to serialize with the current error.

Adds Closure::fromConstExpr() and ReflectionFunction::getConstExprId()/getConstExprClass() for exporters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant