diff options
| author | Marcus Boerger <helly@php.net> | 2008-02-02 13:56:59 +0000 |
|---|---|---|
| committer | Marcus Boerger <helly@php.net> | 2008-02-02 13:56:59 +0000 |
| commit | 95a3cccf5f1259eb1d8c225e7e1e4f06f6cc74d7 (patch) | |
| tree | 70906df92112c82f336eee0d8b43ae5bf2d64f61 | |
| parent | 30eb2dcabf823b0fd48e6a513a95e7bc479616eb (diff) | |
| download | php-git-95a3cccf5f1259eb1d8c225e7e1e4f06f6cc74d7.tar.gz | |
- Fix flag handling in message generation
| -rw-r--r-- | Zend/zend_API.c | 17 | ||||
| -rw-r--r-- | Zend/zend_execute_API.c | 5 | ||||
| -rw-r--r-- | Zend/zend_vm_def.h | 11 |
3 files changed, 27 insertions, 6 deletions
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))) { |
