Skip to content

Advise trusting the input in the allow_named_closures refusal message#28

Merged
nicolas-grekas merged 1 commit into
mainfrom
improve-named-closure-message
Jun 11, 2026
Merged

Advise trusting the input in the allow_named_closures refusal message#28
nicolas-grekas merged 1 commit into
mainfrom
improve-named-closure-message

Conversation

@nicolas-grekas

Copy link
Copy Markdown
Member

deepclone_to_array() refuses to serialize a closure over a named callable unless allow_named_closures is set. The refusal message now quotes the option and adds that it should be enabled only for trusted input, since a by-name payload can mint a Closure over any function or method of that name (including internal functions like system()):

deepclone_to_array(): serializing a closure over the named callable "strlen" requires enabling
the "allow_named_closures" option; do it only if you trust the input

This mirrors the polyfill's wording (symfony/polyfill#635), which additionally suggests installing this extension — the extension does not suggest installing itself. The leading part of the message is unchanged up to requires enabling the, so the shared substring the polyfill's dual-implementation tests match on still holds.

The three .phpts asserting the message are updated; the deepclone_from_array() ("resolving") refusal is left as-is, matching the polyfill.

deepclone_to_array() refuses to serialize a closure over a named callable
unless allow_named_closures is set. The message now quotes the option and adds
that it should be enabled only for trusted input, since a by-name payload can
mint a Closure over any function or method of that name. This mirrors the
polyfill's wording (symfony/polyfill#635), which additionally points at this
extension; the extension does not suggest installing itself.
@nicolas-grekas nicolas-grekas merged commit c838ae3 into main Jun 11, 2026
20 checks passed
@nicolas-grekas nicolas-grekas deleted the improve-named-closure-message branch June 11, 2026 16:59
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