mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
* Fix ReflectionMethod::invoke() crash with internal closures The closure identity check added in GH-21366 accessed op_array.opcodes unconditionally, but internal closures (e.g. var_dump(...)) use internal_function, not op_array. This caused undefined behavior when comparing closures created via first-class callable syntax on internal functions. Check the function type first: compare op_array.opcodes for user closures, compare the function pointer directly for internal closures. * Fix internal closure comparison and expand test coverage The previous comparison (orig_func == given_func) could never match for internal closures since zend_get_closure_method_def() returns a pointer to each closure's embedded copy. Compare function_name and scope instead. Also handle the mixed user/internal type case explicitly. Add tests for: userland first-class callables, cloned internal closures, and cross-type (user vs internal) closure rejection. * php_reflection: Simplify the Closure::__invoke() check --------- Co-authored-by: Tim Düsterhus <tim@bastelstu.be>