diff --git a/Zend/tests/anon/015.phpt b/Zend/tests/anon/015.phpt index f55c4b2605259..45426c2085843 100644 --- a/Zend/tests/anon/015.phpt +++ b/Zend/tests/anon/015.phpt @@ -19,12 +19,15 @@ var_dump($d->foo(24)); var_dump($c->foo()); ?> --EXPECT-- -NULL +array(1) { + [0]=> + int(42) +} array(1) { [0]=> int(24) } array(1) { [0]=> - int(42) + int(24) } diff --git a/Zend/tests/anon/016.phpt b/Zend/tests/anon/016.phpt index a5607cda74e1a..ca1c1d2181c37 100644 --- a/Zend/tests/anon/016.phpt +++ b/Zend/tests/anon/016.phpt @@ -19,13 +19,16 @@ var_dump($d->foo(24)); var_dump($c->foo()); ?> --EXPECT-- -NULL +array(1) { + [0]=> + object(stdClass)#2 (0) { + } +} array(1) { [0]=> int(24) } array(1) { [0]=> - object(stdClass)#2 (0) { - } + int(24) } diff --git a/Zend/tests/method_static_var.phpt b/Zend/tests/method_static_var.phpt index f92e6d3a5d3f6..dd9583df99002 100644 --- a/Zend/tests/method_static_var.phpt +++ b/Zend/tests/method_static_var.phpt @@ -20,5 +20,5 @@ Bar::test(); --EXPECT-- int(1) int(2) -int(1) -int(2) +int(3) +int(4) diff --git a/Zend/tests/static_variables_traits.phpt b/Zend/tests/static_variables_traits.phpt new file mode 100644 index 0000000000000..a5974d2253f83 --- /dev/null +++ b/Zend/tests/static_variables_traits.phpt @@ -0,0 +1,43 @@ +--TEST-- +Behavior of static variables in trait methods +--FILE-- + +--EXPECT-- +int(1) +int(1) +int(1) +int(1) +int(2) +int(2) +int(2) +int(2) diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 042861e10cbb0..d4616d4bd56f4 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -88,16 +88,7 @@ static zend_function *zend_duplicate_internal_function(zend_function *func, zend } /* }}} */ -static zend_function *zend_duplicate_user_function(zend_function *func) /* {{{ */ -{ - zend_op_array *new_op_array = zend_arena_alloc(&CG(arena), sizeof(zend_op_array)); - memcpy(new_op_array, func, sizeof(zend_op_array)); - zend_init_static_variables_map_ptr(new_op_array); - return (zend_function *) new_op_array; -} -/* }}} */ - -static zend_always_inline zend_function *zend_duplicate_function(zend_function *func, zend_class_entry *ce, bool is_interface) /* {{{ */ +static zend_always_inline zend_function *zend_duplicate_function(zend_function *func, zend_class_entry *ce) /* {{{ */ { if (UNEXPECTED(func->type == ZEND_INTERNAL_FUNCTION)) { return zend_duplicate_internal_function(func, ce); @@ -108,12 +99,7 @@ static zend_always_inline zend_function *zend_duplicate_function(zend_function * if (EXPECTED(func->op_array.function_name)) { zend_string_addref(func->op_array.function_name); } - if (is_interface - || EXPECTED(!func->op_array.static_variables)) { - /* reuse the same op_array structure */ - return func; - } - return zend_duplicate_user_function(func); + return func; } } /* }}} */ @@ -948,9 +934,7 @@ static zend_always_inline inheritance_status do_inheritance_check_on_method_ex( if (!check_only && child->common.prototype != proto && child_zv) { do { - if (child->common.scope != ce - && child->type == ZEND_USER_FUNCTION - && !child->op_array.static_variables) { + if (child->common.scope != ce && child->type == ZEND_USER_FUNCTION) { if (ce->ce_flags & ZEND_ACC_INTERFACE) { /* Few parent interfaces contain the same method */ break; @@ -1021,7 +1005,7 @@ static zend_always_inline void do_inherit_method(zend_string *key, zend_function ce->ce_flags |= ZEND_ACC_IMPLICIT_ABSTRACT_CLASS; } - parent = zend_duplicate_function(parent, ce, is_interface); + parent = zend_duplicate_function(parent, ce); if (!is_interface) { _zend_hash_append_ptr(&ce->function_table, key, parent); diff --git a/ext/opcache/tests/preload_method_static_vars.phpt b/ext/opcache/tests/preload_method_static_vars.phpt index 7edddba1b4eb2..52edfc0fd338a 100644 --- a/ext/opcache/tests/preload_method_static_vars.phpt +++ b/ext/opcache/tests/preload_method_static_vars.phpt @@ -19,8 +19,8 @@ Bar::test(); --EXPECT-- int(1) int(2) -int(1) -int(2) +int(3) +int(4) int(1) -int(1) +int(2) diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c index fe177cf8d6364..74764c45ca475 100644 --- a/ext/opcache/zend_persist.c +++ b/ext/opcache/zend_persist.c @@ -763,7 +763,6 @@ static void zend_persist_class_method(zval *zv, zend_class_entry *ce) } if ((op_array->fn_flags & ZEND_ACC_IMMUTABLE) - && !op_array->static_variables && !ZCG(current_persistent_script)->corrupted && zend_accel_in_shm(op_array)) { zend_shared_alloc_register_xlat_entry(op_array, op_array);