]> granicus.if.org Git - php/commitdiff
Disallow calling __clone/__construct/__destruct static
authorMarcus Boerger <helly@php.net>
Fri, 23 Jan 2004 20:58:23 +0000 (20:58 +0000)
committerMarcus Boerger <helly@php.net>
Fri, 23 Jan 2004 20:58:23 +0000 (20:58 +0000)
Send an E_STRICT when calling a non static method static

Zend/zend_execute.c
Zend/zend_execute_API.c

index 51851d684727569f14541802b4dd73ec46e45e3c..e3f19478e3241a4675d22edc567cf9dadc024dad 100644 (file)
@@ -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));
index 52f0d9e3ef7fed6749b6e014f78e5dfd8eaaf271..84844992e0822c46834ffd592ba28e62b82ff1d9 100644 (file)
@@ -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);