Skip to content

Fix GH-17126: get_class_methods omits __invoke for Closure#21879

Open
iliaal wants to merge 1 commit intophp:masterfrom
iliaal:fix/gh-17126-closure-invoke-in-class-methods
Open

Fix GH-17126: get_class_methods omits __invoke for Closure#21879
iliaal wants to merge 1 commit intophp:masterfrom
iliaal:fix/gh-17126-closure-invoke-in-class-methods

Conversation

@iliaal
Copy link
Copy Markdown
Contributor

@iliaal iliaal commented Apr 27, 2026

Closure::__invoke is documented and reachable via method_exists() and ReflectionClass (getMethod, hasMethod, getMethods), but get_class_methods() walks ce->function_table directly and Closure does not register __invoke there: the parameter list is materialized per-instance by zend_get_closure_invoke_method(). get_class_methods() now appends __invoke when ce == zend_ce_closure, the same predicate is_closure_invoke() already uses in ext/reflection.

Fixes #17126

Closure::__invoke is documented and reachable via method_exists() and
ReflectionClass (getMethod, hasMethod, getMethods), but
get_class_methods() walks ce->function_table directly and Closure does
not register __invoke there: the parameter list is materialized
per-instance by zend_get_closure_invoke_method().

Append __invoke to the result when ce == zend_ce_closure, the same
predicate is_closure_invoke() already uses in ext/reflection.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_class_methods($closure) doesn't return __invoke

1 participant