From: Nikita Popov Date: Thu, 9 May 2019 10:36:20 +0000 (+0200) Subject: Merge branch 'PHP-7.3' into PHP-7.4 X-Git-Tag: php-7.4.0alpha1~322 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4b40a46bf157c2e26714dffdf6c78b2bb85f24ab;p=php Merge branch 'PHP-7.3' into PHP-7.4 --- 4b40a46bf157c2e26714dffdf6c78b2bb85f24ab diff --cc ext/reflection/php_reflection.c index da459e60be,c38160297d..f1037ef694 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@@ -4137,15 -4193,24 +4128,26 @@@ ZEND_METHOD(reflection_class, getMethod GET_REFLECTION_OBJECT_PTR(ce); array_init(return_value); - zend_hash_apply_with_arguments(&ce->function_table, (apply_func_args_t) _addmethod_va, 4, &ce, return_value, filter); + ZEND_HASH_FOREACH_PTR(&ce->function_table, mptr) { - _addmethod(mptr, ce, return_value, filter, &intern->obj); ++ _addmethod(mptr, ce, return_value, filter); + } ZEND_HASH_FOREACH_END(); - if (Z_TYPE(intern->obj) != IS_UNDEF && instanceof_function(ce, zend_ce_closure)) { - zend_function *closure = zend_get_closure_invoke_method(Z_OBJ(intern->obj)); + if (instanceof_function(ce, zend_ce_closure)) { + zend_bool has_obj = Z_TYPE(intern->obj) != IS_UNDEF; + zval obj_tmp; + zend_object *obj; + if (!has_obj) { + object_init_ex(&obj_tmp, ce); + obj = Z_OBJ(obj_tmp); + } else { + obj = Z_OBJ(intern->obj); + } + zend_function *closure = zend_get_closure_invoke_method(obj); if (closure) { - _addmethod(closure, ce, return_value, filter, &intern->obj); - _free_function(closure); + _addmethod(closure, ce, return_value, filter); + } + if (!has_obj) { + zval_ptr_dtor(&obj_tmp); } } }