]> granicus.if.org Git - php/commitdiff
- Fix flag handling in message generation
authorMarcus Boerger <helly@php.net>
Sat, 2 Feb 2008 13:56:59 +0000 (13:56 +0000)
committerMarcus Boerger <helly@php.net>
Sat, 2 Feb 2008 13:56:59 +0000 (13:56 +0000)
Zend/zend_API.c
Zend/zend_execute_API.c
Zend/zend_vm_def.h

index 503ea5fde34713b3efecb4f8f0138c8652e7b34c..bfec867576be7bd54c48112d2e8d4ccd589558d0 100644 (file)
@@ -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);
                                        }
                                }
                        }
index b40901630a6dfe3ee179e7b2411b4f76cc7cb589..1eca3b1ec8a39df8085a0a77826a86b09e4d4c62 100644 (file)
@@ -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);
                }
        }
 
index 2a76dfbad3c4254f745e4c9c7cbc0852079e5861..8cb595e36e66640126183952bfb4d6da44882cfe 100644 (file)
@@ -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))) {