summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/tests/static_variable_in_private_method.phpt16
-rw-r--r--Zend/zend_execute_API.c2
-rw-r--r--Zend/zend_inheritance.c9
3 files changed, 17 insertions, 10 deletions
diff --git a/Zend/tests/static_variable_in_private_method.phpt b/Zend/tests/static_variable_in_private_method.phpt
new file mode 100644
index 0000000000..0aa04a0918
--- /dev/null
+++ b/Zend/tests/static_variable_in_private_method.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Inheritance of private method with static variable
+--FILE--
+<?php
+
+class A {
+ private function m() {
+ static $x;
+ }
+}
+class B extends A {}
+
+?>
+===DONE===
+--EXPECT--
+===DONE===
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index ab48566002..11819cf327 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -300,7 +300,7 @@ void shutdown_executor(void) /* {{{ */
}
if (ce->ce_flags & ZEND_HAS_STATIC_IN_METHODS) {
zend_op_array *op_array;
- ZEND_HASH_FOREACH_PTR(&ce->function_table, op_array) {
+ ZEND_HASH_FOREACH_PTR(&ce->function_table, op_array) {
if (op_array->type == ZEND_USER_FUNCTION) {
if (op_array->static_variables) {
HashTable *ht = ZEND_MAP_PTR_GET(op_array->static_variables_ptr);
diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c
index b0e35a9552..2ac73f617f 100644
--- a/Zend/zend_inheritance.c
+++ b/Zend/zend_inheritance.c
@@ -100,15 +100,6 @@ static zend_always_inline zend_function *zend_duplicate_function(zend_function *
/* reuse the same op_array structure */
return func;
}
- if (func->op_array.fn_flags & ZEND_ACC_PRIVATE) {
- /* For private methods we reuse the same op_array structure even if
- * static variables are used, because it will not end up being used
- * anyway. However we still need to addref as the dtor will delref. */
- if (!(GC_FLAGS(func->op_array.static_variables) & IS_ARRAY_IMMUTABLE)) {
- GC_ADDREF(func->op_array.static_variables);
- }
- return func;
- }
return zend_duplicate_user_function(func);
}
}