--FILE--
<?php
-class Foo {
- const BAR = 1;
- public static function method() {
- return static::BAR;
+class A {
+ public static function test() {
+ var_dump(static::class);
}
}
-var_dump(Closure::fromCallable(['Foo', 'method'])());
+
+class B extends A {
+}
+
+Closure::fromCallable(['A', 'test'])();
+Closure::fromCallable(['B', 'test'])();
?>
--EXPECT--
-int(1)
+string(1) "A"
+string(1) "B"
static void zend_closure_call_magic(INTERNAL_FUNCTION_PARAMETERS) /* {{{ */ {
zend_fcall_info fci;
zend_fcall_info_cache fcc;
+ zval params[2];
memset(&fci, 0, sizeof(zend_fcall_info));
memset(&fci, 0, sizeof(zend_fcall_info_cache));
fcc.initialized = 1;
fcc.function_handler = (zend_function *) EX(func)->common.arg_info;
- fci.params = (zval*) emalloc(sizeof(zval) * 2);
+ fci.params = params;
fci.param_count = 2;
ZVAL_STR(&fci.params[0], EX(func)->common.function_name);
array_init(&fci.params[1]);
zval_ptr_dtor(&fci.params[0]);
zval_ptr_dtor(&fci.params[1]);
- efree(fci.params);
}
/* }}} */
}
mptr = fcc.function_handler;
- if (mptr == NULL) {
- return FAILURE;
- }
-
if (mptr->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {
memset(&call, 0, sizeof(zend_internal_function));
if (fcc.object) {
ZVAL_OBJ(&instance, fcc.object);
- zend_create_fake_closure(return_value, mptr, mptr->common.scope, fcc.object->ce, &instance);
+ zend_create_fake_closure(return_value, mptr, mptr->common.scope, fcc.called_scope, &instance);
} else {
- zend_create_fake_closure(return_value, mptr, mptr->common.scope, mptr->common.scope, NULL);
+ zend_create_fake_closure(return_value, mptr, mptr->common.scope, fcc.called_scope, NULL);
}
return SUCCESS;