From: Marcus Boerger Date: Sat, 2 Feb 2008 13:56:59 +0000 (+0000) Subject: - Fix flag handling in message generation X-Git-Tag: RELEASE_1_3_1~164 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=95a3cccf5f1259eb1d8c225e7e1e4f06f6cc74d7;p=php - Fix flag handling in message generation --- diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 503ea5fde3..bfec867576 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -2400,21 +2400,30 @@ static int zend_is_callable_check_func(int check_flags, zval ***zobj_ptr_ptr, ze *fptr_ptr = fptr; if (*ce_ptr) { if (!*zobj_ptr_ptr && !(fptr->common.fn_flags & ZEND_ACC_STATIC)) { + int severity; + char *verb; + if (fptr->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { + severity = E_STRICT; + verb = "should not"; + } else { + severity = E_ERROR; + verb = "cannot"; + } if ((check_flags & IS_CALLABLE_CHECK_IS_STATIC) != 0) { retval = 0; } if (EG(This) && instanceof_function(Z_OBJCE_P(EG(This)), *ce_ptr TSRMLS_CC)) { *zobj_ptr_ptr = &EG(This); if (error) { - zend_spprintf(error, 0, "non-static method %s::%s() cannot be called statically, assuming $this from compatible context %s", (*ce_ptr)->name, fptr->common.function_name, Z_OBJCE_P(EG(This))->name); + zend_spprintf(error, 0, "non-static method %s::%s() %s be called statically, assuming $this from compatible context %s", (*ce_ptr)->name, fptr->common.function_name, verb, Z_OBJCE_P(EG(This))->name); } else if (retval) { - zend_error(E_STRICT, "Non-static method %s::%s() cannot be called statically, assuming $this from compatible context %s", (*ce_ptr)->name, fptr->common.function_name, Z_OBJCE_P(EG(This))->name); + zend_error(severity, "Non-static method %s::%s() %s be called statically, assuming $this from compatible context %s", (*ce_ptr)->name, fptr->common.function_name, verb, Z_OBJCE_P(EG(This))->name); } } else { if (error) { - zend_spprintf(error, 0, "non-static method %s::%s() should not be called statically", (*ce_ptr)->name, fptr->common.function_name); + zend_spprintf(error, 0, "non-static method %s::%s() %s be called statically", (*ce_ptr)->name, fptr->common.function_name, verb); } else if (retval) { - zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically", (*ce_ptr)->name, fptr->common.function_name); + zend_error(severity, "Non-static method %s::%s() %s be called statically", (*ce_ptr)->name, fptr->common.function_name, verb); } } } diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index b40901630a..1eca3b1ec8 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -1046,12 +1046,15 @@ 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; + char *verb; if (EX(function_state).function->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { severity = E_STRICT; + verb = "should not"; } else { severity = E_ERROR; + verb = "cannot"; } - zend_error(severity, "Non-static method %s::%s() cannot be called statically", calling_scope->name, EX(function_state).function->common.function_name); + zend_error(severity, "Non-static method %s::%s() %s be called statically", calling_scope->name, EX(function_state).function->common.function_name, verb); } } diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 2a76dfbad3..8cb595e36e 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -1969,7 +1969,16 @@ ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_METHOD_CALL, CONST|VAR, CONST|TMP|VAR|UNUS !instanceof_function(Z_OBJCE_P(EG(This)), ce TSRMLS_CC)) { /* We are calling method of the other (incompatible) class, but passing $this. This is done for compatibility with php-4. */ - zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name); + int severity; + char *verb; + if (EX(fbc)->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { + severity = E_STRICT; + verb = "should not"; + } else { + severity = E_ERROR; + verb = "cannot"; + } + zend_error(severity, "Non-static method %s::%s() %s be called statically, assuming $this from incompatible context", EX(fbc)->common.scope->name, EX(fbc)->common.function_name, verb); } if ((EX(object) = EG(This))) {