diff options
-rw-r--r-- | Zend/zend_API.c | 9 | ||||
-rw-r--r-- | Zend/zend_compile.c | 8 | ||||
-rw-r--r-- | Zend/zend_compile.h | 2 | ||||
-rw-r--r-- | Zend/zend_execute.c | 6 | ||||
-rw-r--r-- | Zend/zend_execute_API.c | 6 | ||||
-rw-r--r-- | tests/lang/bug23384.phpt | 5 |
6 files changed, 22 insertions, 14 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c index ec6fb918db..40e80ff366 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -1293,22 +1293,25 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, zend_function_entr scope->destructor = dtor; scope->clone = clone; if (ctor) { - ctor->common.fn_flags |= ZEND_ACC_CTOR|ZEND_ACC_DYNAMIC; + ctor->common.fn_flags |= ZEND_ACC_CTOR; if (ctor->common.fn_flags & ZEND_ACC_STATIC) { zend_error(error_type, "Constructor %s::%s cannot be static", ctor->common.scope->name, ctor->common.function_name); } + ctor->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC; } if (dtor) { - dtor->common.fn_flags |= ZEND_ACC_DTOR|ZEND_ACC_DYNAMIC; + dtor->common.fn_flags |= ZEND_ACC_DTOR; if (dtor->common.fn_flags & ZEND_ACC_STATIC) { zend_error(error_type, "Destructor %s::%s cannot be static", dtor->common.scope->name, dtor->common.function_name); } + dtor->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC; } if (clone) { - clone->common.fn_flags |= ZEND_ACC_CLONE|ZEND_ACC_DYNAMIC; + clone->common.fn_flags |= ZEND_ACC_CLONE; if (clone->common.fn_flags & ZEND_ACC_STATIC) { zend_error(error_type, "Constructor %s::%s cannot be static", clone->common.scope->name, clone->common.function_name); } + clone->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC; } } return SUCCESS; diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index fe98fc24f4..1d32d0f124 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1043,6 +1043,8 @@ void zend_do_begin_function_declaration(znode *function_token, znode *function_n CG(active_class_entry)->__get = (zend_function *) CG(active_op_array); } else if ((name_len == sizeof(ZEND_SET_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_SET_FUNC_NAME, sizeof(ZEND_SET_FUNC_NAME)))) { CG(active_class_entry)->__set = (zend_function *) CG(active_op_array); + } else if (!(fn_flags & ZEND_ACC_STATIC)) { + CG(active_op_array)->fn_flags |= ZEND_ACC_ALLOW_STATIC; } free_alloca(short_class_name); @@ -2389,19 +2391,19 @@ void zend_do_end_class_declaration(znode *class_token, znode *parent_token TSRML do_inherit_parent_constructor(ce); if (ce->constructor) { - ce->constructor->common.fn_flags |= ZEND_ACC_CTOR|ZEND_ACC_DYNAMIC; + ce->constructor->common.fn_flags |= ZEND_ACC_CTOR; if (ce->constructor->common.fn_flags & ZEND_ACC_STATIC) { zend_error(E_COMPILE_ERROR, "Constructor %s::%s() cannot be static", ce->name, ce->constructor->common.function_name); } } if (ce->destructor) { - ce->destructor->common.fn_flags |= ZEND_ACC_DTOR|ZEND_ACC_DYNAMIC; + ce->destructor->common.fn_flags |= ZEND_ACC_DTOR; if (ce->destructor->common.fn_flags & ZEND_ACC_STATIC) { zend_error(E_COMPILE_ERROR, "Destructor %s::%s() cannot be static", ce->name, ce->destructor->common.function_name); } } if (ce->clone) { - ce->clone->common.fn_flags |= ZEND_ACC_CLONE|ZEND_ACC_DYNAMIC; + ce->clone->common.fn_flags |= ZEND_ACC_CLONE; if (ce->clone->common.fn_flags & ZEND_ACC_STATIC) { zend_error(E_COMPILE_ERROR, "Clone method %s::%s() cannot be static", ce->name, ce->clone->common.function_name); } diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 70ad15f6b8..8c2026dfe8 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -101,7 +101,7 @@ typedef struct _zend_brk_cont_element { #define ZEND_ACC_ABSTRACT_CLASS 0x10 #define ZEND_ACC_FINAL_CLASS 0x20 -#define ZEND_ACC_DYNAMIC 0x80 +#define ZEND_ACC_ALLOW_STATIC 0x80 /* The order of those must be kept - public < protected < private */ #define ZEND_ACC_PUBLIC 0x100 diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index e74278935e..08a77d1c6b 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -2520,10 +2520,10 @@ int zend_do_fcall_common_helper(ZEND_OPCODE_HANDLER_ARGS) if (EX(function_state).function->common.scope) { if (!EG(This) && !(EX(function_state).function->common.fn_flags & ZEND_ACC_STATIC)) { int severity; - if (EX(function_state).function->common.fn_flags & ZEND_ACC_DYNAMIC) { - severity = E_ERROR; - } else { + if (EX(function_state).function->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { severity = E_STRICT; + } else { + severity = E_ERROR; } zend_error(severity, "Non-static method %s::%s() cannot be called statically", EX(function_state).function->common.scope->name, EX(function_state).function->common.function_name); } diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 63a0e4254b..3d2c4ccd28 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -718,10 +718,10 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS EG(This) = NULL; if (calling_scope && !(EX(function_state).function->common.fn_flags & ZEND_ACC_STATIC)) { int severity; - if (EX(function_state).function->common.fn_flags & ZEND_ACC_DYNAMIC) { - severity = E_ERROR; - } else { + if (EX(function_state).function->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { severity = E_STRICT; + } else { + severity = E_ERROR; } zend_error(E_STRICT, "Non-static method %s::%s() cannot be called statically", calling_scope->name, EX(function_state).function->common.function_name); } diff --git a/tests/lang/bug23384.phpt b/tests/lang/bug23384.phpt index e6184c4690..f48d89a3b0 100644 --- a/tests/lang/bug23384.phpt +++ b/tests/lang/bug23384.phpt @@ -1,5 +1,7 @@ --TEST-- Bug #23384 (use of class constants in statics) +--INI-- +error_reporting=4095 --FILE-- <?php define('TEN', 10); @@ -18,7 +20,8 @@ class Foo { Foo::test(); echo Foo::HUN."\n"; ?> ---EXPECT-- +--EXPECTF-- +Strict Standards: Non-static method Foo::test() cannot be called statically in %sbug23384.php on line %d Array ( [100] => ten |