summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2004-01-23 20:58:23 +0000
committerMarcus Boerger <helly@php.net>2004-01-23 20:58:23 +0000
commit79e7145cc7b96ee562179bb0ab80c096cb42d89c (patch)
tree2da88c50c1ca8bacec552f3bdc235ce75b07903c
parent7c2e02d38019efcd170ec789bd360de5637d1b84 (diff)
downloadphp-git-79e7145cc7b96ee562179bb0ab80c096cb42d89c.tar.gz
Disallow calling __clone/__construct/__destruct static
Send an E_STRICT when calling a non static method static
-rw-r--r--Zend/zend_execute.c11
-rw-r--r--Zend/zend_execute_API.c9
2 files changed, 20 insertions, 0 deletions
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index 51851d6847..e3f19478e3 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -2517,6 +2517,17 @@ int zend_do_fcall_common_helper(ZEND_OPCODE_HANDLER_ARGS)
EX_T(EX(opline)->result.u.var).var.fcall_returned_reference = 0;
+ 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_CTOR|ZEND_ACC_DTOR|ZEND_ACC_CLONE)) {
+ severity = E_ERROR;
+ } else {
+ severity = E_STRICT;
+ }
+ zend_error(severity, "Cannot call non static method %s::%s() static", EX(function_state).function->common.scope->name, EX(function_state).function->common.function_name);
+ }
+ }
if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION) {
ALLOC_ZVAL(EX_T(EX(opline)->result.u.var).var.ptr);
INIT_ZVAL(*(EX_T(EX(opline)->result.u.var).var.ptr));
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index 52f0d9e3ef..84844992e0 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -716,6 +716,15 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
}
} else {
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_CTOR|ZEND_ACC_DTOR|ZEND_ACC_CLONE)) {
+ severity = E_ERROR;
+ } else {
+ severity = E_STRICT;
+ }
+ zend_error(E_STRICT, "Cannot call non static method %s::%s() static", calling_scope->name, EX(function_state).function->common.function_name);
+ }
}
EX(prev_execute_data) = EG(current_execute_data);