Skip to content

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

Closed
iliaal wants to merge 1 commit intomasterfrom
fix/gh-17126-closure-invoke-in-class-methods
Closed

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

Conversation

@iliaal
Copy link
Copy Markdown
Owner

@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 php#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
@iliaal
Copy link
Copy Markdown
Owner Author

iliaal commented Apr 27, 2026

Submitted upstream as php#21879.

@iliaal iliaal closed this Apr 27, 2026
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.

get_class_methods($closure) doesn't return __invoke

1 participant