]> granicus.if.org Git - php/commitdiff
Moved checks and error reporting related to static methods from DO_FCALL inti INTI_FC...
authorDmitry Stogov <dmitry@zend.com>
Sat, 4 Oct 2014 10:55:44 +0000 (14:55 +0400)
committerDmitry Stogov <dmitry@zend.com>
Sat, 4 Oct 2014 10:55:44 +0000 (14:55 +0400)
Zend/zend_vm_def.h
Zend/zend_vm_execute.h
tests/lang/passByReference_005.phpt

index 7fa544b57969d843100ebfb1336be4a4834cf8c8..d87b1e496fd6d8aa2d594bdb8dbb1fb8eb252267 100644 (file)
@@ -2261,16 +2261,25 @@ ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_METHOD_CALL, CONST|VAR, CONST|TMP|VAR|UNUS
                if (Z_OBJ(EX(This))) {
                        object = Z_OBJ(EX(This));
                        GC_REFCOUNT(object)++;
-                       if (object->handlers->get_class_entry &&
-                           !instanceof_function(zend_get_class_entry(object TSRMLS_CC), ce TSRMLS_CC)) {
-                           /* We are calling method of the other (incompatible) class,
-                              but passing $this. This is done for compatibility with php-4. */
-                               if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
-                                       zend_error(E_DEPRECATED, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", fbc->common.scope->name->val, fbc->common.function_name->val);
-                               } else {
-                                       /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
-                                       zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", fbc->common.scope->name->val, fbc->common.function_name->val);
-                               }
+               }
+               if (!object ||
+                   (object->handlers->get_class_entry &&
+                    !instanceof_function(zend_get_class_entry(object TSRMLS_CC), ce TSRMLS_CC))) {
+                   /* We are calling method of the other (incompatible) class,
+                      but passing $this. This is done for compatibility with php-4. */
+                       if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
+                               zend_error(
+                                       object ? E_DEPRECATED : E_STRICT,
+                                       "Non-static method %s::%s() should not be called statically%s",
+                                       fbc->common.scope->name->val, fbc->common.function_name->val,
+                                       object ? ", assuming $this from incompatible context" : "");
+                       } else {
+                               /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
+                               zend_error_noreturn(
+                                       E_ERROR,
+                                       "Non-static method %s::%s() cannot be called statically%s",
+                                       fbc->common.scope->name->val, fbc->common.function_name->val,
+                                       object ? ", assuming $this from incompatible context" : "");
                        }
                }
        }
@@ -2396,6 +2405,18 @@ ZEND_VM_HANDLER(59, ZEND_INIT_FCALL_BY_NAME, ANY, CONST|TMP|VAR|CV)
                                if (UNEXPECTED(fbc == NULL)) {
                                        zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", called_scope->name->val, Z_STRVAL_P(method));
                                }
+                               if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
+                                       if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
+                                               zend_error(E_STRICT,
+                                               "Non-static method %s::%s() should not be called statically",
+                                               fbc->common.scope->name->val, fbc->common.function_name->val);
+                                       } else {
+                                               zend_error_noreturn(
+                                                       E_ERROR,
+                                                       "Non-static method %s::%s() cannot be called statically",
+                                                       fbc->common.scope->name->val, fbc->common.function_name->val);
+                                       }
+                               }
                        } else {
                                called_scope = Z_OBJCE_P(obj);
                                object = Z_OBJ_P(obj);
@@ -2452,6 +2473,18 @@ ZEND_VM_HANDLER(118, ZEND_INIT_USER_CALL, CONST, CONST|TMP|VAR|CV)
                object = fcc.object;
                if (object) {
                        GC_REFCOUNT(object)++; /* For $this pointer */
+               } else if (func->common.scope &&
+                          !(func->common.fn_flags & ZEND_ACC_STATIC)) {
+                       if (func->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
+                               zend_error(E_STRICT,
+                               "Non-static method %s::%s() should not be called statically",
+                               func->common.scope->name->val, func->common.function_name->val);
+                       } else {
+                               zend_error_noreturn(
+                                       E_ERROR,
+                                       "Non-static method %s::%s() cannot be called statically",
+                                       func->common.scope->name->val, func->common.function_name->val);
+                       }
                }
        } else {
                zend_error(E_WARNING, "%s() expects parameter 1 to be a valid callback, %s", Z_STRVAL_P(opline->op1.zv), error);
@@ -2548,22 +2581,6 @@ ZEND_VM_HANDLER(60, ZEND_DO_FCALL, ANY, ANY)
                        }
                }
        }
-       if (fbc->common.scope &&
-               !(fbc->common.fn_flags & ZEND_ACC_STATIC) &&
-               !object) {
-
-               if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
-                       /* FIXME: output identifiers properly */
-                       zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically", fbc->common.scope->name->val, fbc->common.function_name->val);
-                       if (UNEXPECTED(EG(exception) != NULL)) {
-                               HANDLE_EXCEPTION();
-                       }
-               } else {
-                       /* FIXME: output identifiers properly */
-                       /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
-                       zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically", fbc->common.scope->name->val, fbc->common.function_name->val);
-               }
-       }
 
        LOAD_OPLINE();
 
index 9f7d4c3a1a2ad9ae9e7940edc2e9e42f34875b26..543c1c25e64507c00c5e24256dde3341aef34cb8 100644 (file)
@@ -509,22 +509,6 @@ static int ZEND_FASTCALL  ZEND_DO_FCALL_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
                        }
                }
        }
-       if (fbc->common.scope &&
-               !(fbc->common.fn_flags & ZEND_ACC_STATIC) &&
-               !object) {
-
-               if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
-                       /* FIXME: output identifiers properly */
-                       zend_error(E_STRICT, "Non-static method %s::%s() should not be called statically", fbc->common.scope->name->val, fbc->common.function_name->val);
-                       if (UNEXPECTED(EG(exception) != NULL)) {
-                               HANDLE_EXCEPTION();
-                       }
-               } else {
-                       /* FIXME: output identifiers properly */
-                       /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
-                       zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically", fbc->common.scope->name->val, fbc->common.function_name->val);
-               }
-       }
 
        LOAD_OPLINE();
 
@@ -1606,6 +1590,18 @@ static int ZEND_FASTCALL  ZEND_INIT_FCALL_BY_NAME_SPEC_CONST_HANDLER(ZEND_OPCODE
                                if (UNEXPECTED(fbc == NULL)) {
                                        zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", called_scope->name->val, Z_STRVAL_P(method));
                                }
+                               if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
+                                       if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
+                                               zend_error(E_STRICT,
+                                               "Non-static method %s::%s() should not be called statically",
+                                               fbc->common.scope->name->val, fbc->common.function_name->val);
+                                       } else {
+                                               zend_error_noreturn(
+                                                       E_ERROR,
+                                                       "Non-static method %s::%s() cannot be called statically",
+                                                       fbc->common.scope->name->val, fbc->common.function_name->val);
+                                       }
+                               }
                        } else {
                                called_scope = Z_OBJCE_P(obj);
                                object = Z_OBJ_P(obj);
@@ -1931,6 +1927,18 @@ static int ZEND_FASTCALL  ZEND_INIT_FCALL_BY_NAME_SPEC_TMP_HANDLER(ZEND_OPCODE_H
                                if (UNEXPECTED(fbc == NULL)) {
                                        zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", called_scope->name->val, Z_STRVAL_P(method));
                                }
+                               if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
+                                       if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
+                                               zend_error(E_STRICT,
+                                               "Non-static method %s::%s() should not be called statically",
+                                               fbc->common.scope->name->val, fbc->common.function_name->val);
+                                       } else {
+                                               zend_error_noreturn(
+                                                       E_ERROR,
+                                                       "Non-static method %s::%s() cannot be called statically",
+                                                       fbc->common.scope->name->val, fbc->common.function_name->val);
+                                       }
+                               }
                        } else {
                                called_scope = Z_OBJCE_P(obj);
                                object = Z_OBJ_P(obj);
@@ -2105,6 +2113,18 @@ static int ZEND_FASTCALL  ZEND_INIT_FCALL_BY_NAME_SPEC_VAR_HANDLER(ZEND_OPCODE_H
                                if (UNEXPECTED(fbc == NULL)) {
                                        zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", called_scope->name->val, Z_STRVAL_P(method));
                                }
+                               if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
+                                       if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
+                                               zend_error(E_STRICT,
+                                               "Non-static method %s::%s() should not be called statically",
+                                               fbc->common.scope->name->val, fbc->common.function_name->val);
+                                       } else {
+                                               zend_error_noreturn(
+                                                       E_ERROR,
+                                                       "Non-static method %s::%s() cannot be called statically",
+                                                       fbc->common.scope->name->val, fbc->common.function_name->val);
+                                       }
+                               }
                        } else {
                                called_scope = Z_OBJCE_P(obj);
                                object = Z_OBJ_P(obj);
@@ -2316,6 +2336,18 @@ static int ZEND_FASTCALL  ZEND_INIT_FCALL_BY_NAME_SPEC_CV_HANDLER(ZEND_OPCODE_HA
                                if (UNEXPECTED(fbc == NULL)) {
                                        zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", called_scope->name->val, Z_STRVAL_P(method));
                                }
+                               if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
+                                       if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
+                                               zend_error(E_STRICT,
+                                               "Non-static method %s::%s() should not be called statically",
+                                               fbc->common.scope->name->val, fbc->common.function_name->val);
+                                       } else {
+                                               zend_error_noreturn(
+                                                       E_ERROR,
+                                                       "Non-static method %s::%s() cannot be called statically",
+                                                       fbc->common.scope->name->val, fbc->common.function_name->val);
+                                       }
+                               }
                        } else {
                                called_scope = Z_OBJCE_P(obj);
                                object = Z_OBJ_P(obj);
@@ -4129,16 +4161,25 @@ static int ZEND_FASTCALL  ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_CONST_HANDLER(
                if (Z_OBJ(EX(This))) {
                        object = Z_OBJ(EX(This));
                        GC_REFCOUNT(object)++;
-                       if (object->handlers->get_class_entry &&
-                           !instanceof_function(zend_get_class_entry(object TSRMLS_CC), ce TSRMLS_CC)) {
-                           /* We are calling method of the other (incompatible) class,
-                              but passing $this. This is done for compatibility with php-4. */
-                               if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
-                                       zend_error(E_DEPRECATED, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", fbc->common.scope->name->val, fbc->common.function_name->val);
-                               } else {
-                                       /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
-                                       zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", fbc->common.scope->name->val, fbc->common.function_name->val);
-                               }
+               }
+               if (!object ||
+                   (object->handlers->get_class_entry &&
+                    !instanceof_function(zend_get_class_entry(object TSRMLS_CC), ce TSRMLS_CC))) {
+                   /* We are calling method of the other (incompatible) class,
+                      but passing $this. This is done for compatibility with php-4. */
+                       if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
+                               zend_error(
+                                       object ? E_DEPRECATED : E_STRICT,
+                                       "Non-static method %s::%s() should not be called statically%s",
+                                       fbc->common.scope->name->val, fbc->common.function_name->val,
+                                       object ? ", assuming $this from incompatible context" : "");
+                       } else {
+                               /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
+                               zend_error_noreturn(
+                                       E_ERROR,
+                                       "Non-static method %s::%s() cannot be called statically%s",
+                                       fbc->common.scope->name->val, fbc->common.function_name->val,
+                                       object ? ", assuming $this from incompatible context" : "");
                        }
                }
        }
@@ -4186,6 +4227,18 @@ static int ZEND_FASTCALL  ZEND_INIT_USER_CALL_SPEC_CONST_CONST_HANDLER(ZEND_OPCO
                object = fcc.object;
                if (object) {
                        GC_REFCOUNT(object)++; /* For $this pointer */
+               } else if (func->common.scope &&
+                          !(func->common.fn_flags & ZEND_ACC_STATIC)) {
+                       if (func->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
+                               zend_error(E_STRICT,
+                               "Non-static method %s::%s() should not be called statically",
+                               func->common.scope->name->val, func->common.function_name->val);
+                       } else {
+                               zend_error_noreturn(
+                                       E_ERROR,
+                                       "Non-static method %s::%s() cannot be called statically",
+                                       func->common.scope->name->val, func->common.function_name->val);
+                       }
                }
        } else {
                zend_error(E_WARNING, "%s() expects parameter 1 to be a valid callback, %s", Z_STRVAL_P(opline->op1.zv), error);
@@ -5435,16 +5488,25 @@ static int ZEND_FASTCALL  ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_TMP_HANDLER(ZE
                if (Z_OBJ(EX(This))) {
                        object = Z_OBJ(EX(This));
                        GC_REFCOUNT(object)++;
-                       if (object->handlers->get_class_entry &&
-                           !instanceof_function(zend_get_class_entry(object TSRMLS_CC), ce TSRMLS_CC)) {
-                           /* We are calling method of the other (incompatible) class,
-                              but passing $this. This is done for compatibility with php-4. */
-                               if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
-                                       zend_error(E_DEPRECATED, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", fbc->common.scope->name->val, fbc->common.function_name->val);
-                               } else {
-                                       /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
-                                       zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", fbc->common.scope->name->val, fbc->common.function_name->val);
-                               }
+               }
+               if (!object ||
+                   (object->handlers->get_class_entry &&
+                    !instanceof_function(zend_get_class_entry(object TSRMLS_CC), ce TSRMLS_CC))) {
+                   /* We are calling method of the other (incompatible) class,
+                      but passing $this. This is done for compatibility with php-4. */
+                       if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
+                               zend_error(
+                                       object ? E_DEPRECATED : E_STRICT,
+                                       "Non-static method %s::%s() should not be called statically%s",
+                                       fbc->common.scope->name->val, fbc->common.function_name->val,
+                                       object ? ", assuming $this from incompatible context" : "");
+                       } else {
+                               /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
+                               zend_error_noreturn(
+                                       E_ERROR,
+                                       "Non-static method %s::%s() cannot be called statically%s",
+                                       fbc->common.scope->name->val, fbc->common.function_name->val,
+                                       object ? ", assuming $this from incompatible context" : "");
                        }
                }
        }
@@ -5492,6 +5554,18 @@ static int ZEND_FASTCALL  ZEND_INIT_USER_CALL_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE
                object = fcc.object;
                if (object) {
                        GC_REFCOUNT(object)++; /* For $this pointer */
+               } else if (func->common.scope &&
+                          !(func->common.fn_flags & ZEND_ACC_STATIC)) {
+                       if (func->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
+                               zend_error(E_STRICT,
+                               "Non-static method %s::%s() should not be called statically",
+                               func->common.scope->name->val, func->common.function_name->val);
+                       } else {
+                               zend_error_noreturn(
+                                       E_ERROR,
+                                       "Non-static method %s::%s() cannot be called statically",
+                                       func->common.scope->name->val, func->common.function_name->val);
+                       }
                }
        } else {
                zend_error(E_WARNING, "%s() expects parameter 1 to be a valid callback, %s", Z_STRVAL_P(opline->op1.zv), error);
@@ -6611,16 +6685,25 @@ static int ZEND_FASTCALL  ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_VAR_HANDLER(ZE
                if (Z_OBJ(EX(This))) {
                        object = Z_OBJ(EX(This));
                        GC_REFCOUNT(object)++;
-                       if (object->handlers->get_class_entry &&
-                           !instanceof_function(zend_get_class_entry(object TSRMLS_CC), ce TSRMLS_CC)) {
-                           /* We are calling method of the other (incompatible) class,
-                              but passing $this. This is done for compatibility with php-4. */
-                               if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
-                                       zend_error(E_DEPRECATED, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", fbc->common.scope->name->val, fbc->common.function_name->val);
-                               } else {
-                                       /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
-                                       zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", fbc->common.scope->name->val, fbc->common.function_name->val);
-                               }
+               }
+               if (!object ||
+                   (object->handlers->get_class_entry &&
+                    !instanceof_function(zend_get_class_entry(object TSRMLS_CC), ce TSRMLS_CC))) {
+                   /* We are calling method of the other (incompatible) class,
+                      but passing $this. This is done for compatibility with php-4. */
+                       if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
+                               zend_error(
+                                       object ? E_DEPRECATED : E_STRICT,
+                                       "Non-static method %s::%s() should not be called statically%s",
+                                       fbc->common.scope->name->val, fbc->common.function_name->val,
+                                       object ? ", assuming $this from incompatible context" : "");
+                       } else {
+                               /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
+                               zend_error_noreturn(
+                                       E_ERROR,
+                                       "Non-static method %s::%s() cannot be called statically%s",
+                                       fbc->common.scope->name->val, fbc->common.function_name->val,
+                                       object ? ", assuming $this from incompatible context" : "");
                        }
                }
        }
@@ -6668,6 +6751,18 @@ static int ZEND_FASTCALL  ZEND_INIT_USER_CALL_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE
                object = fcc.object;
                if (object) {
                        GC_REFCOUNT(object)++; /* For $this pointer */
+               } else if (func->common.scope &&
+                          !(func->common.fn_flags & ZEND_ACC_STATIC)) {
+                       if (func->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
+                               zend_error(E_STRICT,
+                               "Non-static method %s::%s() should not be called statically",
+                               func->common.scope->name->val, func->common.function_name->val);
+                       } else {
+                               zend_error_noreturn(
+                                       E_ERROR,
+                                       "Non-static method %s::%s() cannot be called statically",
+                                       func->common.scope->name->val, func->common.function_name->val);
+                       }
                }
        } else {
                zend_error(E_WARNING, "%s() expects parameter 1 to be a valid callback, %s", Z_STRVAL_P(opline->op1.zv), error);
@@ -7538,16 +7633,25 @@ static int ZEND_FASTCALL  ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_UNUSED_HANDLER
                if (Z_OBJ(EX(This))) {
                        object = Z_OBJ(EX(This));
                        GC_REFCOUNT(object)++;
-                       if (object->handlers->get_class_entry &&
-                           !instanceof_function(zend_get_class_entry(object TSRMLS_CC), ce TSRMLS_CC)) {
-                           /* We are calling method of the other (incompatible) class,
-                              but passing $this. This is done for compatibility with php-4. */
-                               if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
-                                       zend_error(E_DEPRECATED, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", fbc->common.scope->name->val, fbc->common.function_name->val);
-                               } else {
-                                       /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
-                                       zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", fbc->common.scope->name->val, fbc->common.function_name->val);
-                               }
+               }
+               if (!object ||
+                   (object->handlers->get_class_entry &&
+                    !instanceof_function(zend_get_class_entry(object TSRMLS_CC), ce TSRMLS_CC))) {
+                   /* We are calling method of the other (incompatible) class,
+                      but passing $this. This is done for compatibility with php-4. */
+                       if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
+                               zend_error(
+                                       object ? E_DEPRECATED : E_STRICT,
+                                       "Non-static method %s::%s() should not be called statically%s",
+                                       fbc->common.scope->name->val, fbc->common.function_name->val,
+                                       object ? ", assuming $this from incompatible context" : "");
+                       } else {
+                               /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
+                               zend_error_noreturn(
+                                       E_ERROR,
+                                       "Non-static method %s::%s() cannot be called statically%s",
+                                       fbc->common.scope->name->val, fbc->common.function_name->val,
+                                       object ? ", assuming $this from incompatible context" : "");
                        }
                }
        }
@@ -8522,16 +8626,25 @@ static int ZEND_FASTCALL  ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_CV_HANDLER(ZEN
                if (Z_OBJ(EX(This))) {
                        object = Z_OBJ(EX(This));
                        GC_REFCOUNT(object)++;
-                       if (object->handlers->get_class_entry &&
-                           !instanceof_function(zend_get_class_entry(object TSRMLS_CC), ce TSRMLS_CC)) {
-                           /* We are calling method of the other (incompatible) class,
-                              but passing $this. This is done for compatibility with php-4. */
-                               if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
-                                       zend_error(E_DEPRECATED, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", fbc->common.scope->name->val, fbc->common.function_name->val);
-                               } else {
-                                       /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
-                                       zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", fbc->common.scope->name->val, fbc->common.function_name->val);
-                               }
+               }
+               if (!object ||
+                   (object->handlers->get_class_entry &&
+                    !instanceof_function(zend_get_class_entry(object TSRMLS_CC), ce TSRMLS_CC))) {
+                   /* We are calling method of the other (incompatible) class,
+                      but passing $this. This is done for compatibility with php-4. */
+                       if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
+                               zend_error(
+                                       object ? E_DEPRECATED : E_STRICT,
+                                       "Non-static method %s::%s() should not be called statically%s",
+                                       fbc->common.scope->name->val, fbc->common.function_name->val,
+                                       object ? ", assuming $this from incompatible context" : "");
+                       } else {
+                               /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
+                               zend_error_noreturn(
+                                       E_ERROR,
+                                       "Non-static method %s::%s() cannot be called statically%s",
+                                       fbc->common.scope->name->val, fbc->common.function_name->val,
+                                       object ? ", assuming $this from incompatible context" : "");
                        }
                }
        }
@@ -8579,6 +8692,18 @@ static int ZEND_FASTCALL  ZEND_INIT_USER_CALL_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_
                object = fcc.object;
                if (object) {
                        GC_REFCOUNT(object)++; /* For $this pointer */
+               } else if (func->common.scope &&
+                          !(func->common.fn_flags & ZEND_ACC_STATIC)) {
+                       if (func->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
+                               zend_error(E_STRICT,
+                               "Non-static method %s::%s() should not be called statically",
+                               func->common.scope->name->val, func->common.function_name->val);
+                       } else {
+                               zend_error_noreturn(
+                                       E_ERROR,
+                                       "Non-static method %s::%s() cannot be called statically",
+                                       func->common.scope->name->val, func->common.function_name->val);
+                       }
                }
        } else {
                zend_error(E_WARNING, "%s() expects parameter 1 to be a valid callback, %s", Z_STRVAL_P(opline->op1.zv), error);
@@ -18536,16 +18661,25 @@ static int ZEND_FASTCALL  ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_CONST_HANDLER(ZE
                if (Z_OBJ(EX(This))) {
                        object = Z_OBJ(EX(This));
                        GC_REFCOUNT(object)++;
-                       if (object->handlers->get_class_entry &&
-                           !instanceof_function(zend_get_class_entry(object TSRMLS_CC), ce TSRMLS_CC)) {
-                           /* We are calling method of the other (incompatible) class,
-                              but passing $this. This is done for compatibility with php-4. */
-                               if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
-                                       zend_error(E_DEPRECATED, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", fbc->common.scope->name->val, fbc->common.function_name->val);
-                               } else {
-                                       /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
-                                       zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", fbc->common.scope->name->val, fbc->common.function_name->val);
-                               }
+               }
+               if (!object ||
+                   (object->handlers->get_class_entry &&
+                    !instanceof_function(zend_get_class_entry(object TSRMLS_CC), ce TSRMLS_CC))) {
+                   /* We are calling method of the other (incompatible) class,
+                      but passing $this. This is done for compatibility with php-4. */
+                       if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
+                               zend_error(
+                                       object ? E_DEPRECATED : E_STRICT,
+                                       "Non-static method %s::%s() should not be called statically%s",
+                                       fbc->common.scope->name->val, fbc->common.function_name->val,
+                                       object ? ", assuming $this from incompatible context" : "");
+                       } else {
+                               /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
+                               zend_error_noreturn(
+                                       E_ERROR,
+                                       "Non-static method %s::%s() cannot be called statically%s",
+                                       fbc->common.scope->name->val, fbc->common.function_name->val,
+                                       object ? ", assuming $this from incompatible context" : "");
                        }
                }
        }
@@ -20752,16 +20886,25 @@ static int ZEND_FASTCALL  ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_TMP_HANDLER(ZEND
                if (Z_OBJ(EX(This))) {
                        object = Z_OBJ(EX(This));
                        GC_REFCOUNT(object)++;
-                       if (object->handlers->get_class_entry &&
-                           !instanceof_function(zend_get_class_entry(object TSRMLS_CC), ce TSRMLS_CC)) {
-                           /* We are calling method of the other (incompatible) class,
-                              but passing $this. This is done for compatibility with php-4. */
-                               if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
-                                       zend_error(E_DEPRECATED, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", fbc->common.scope->name->val, fbc->common.function_name->val);
-                               } else {
-                                       /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
-                                       zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", fbc->common.scope->name->val, fbc->common.function_name->val);
-                               }
+               }
+               if (!object ||
+                   (object->handlers->get_class_entry &&
+                    !instanceof_function(zend_get_class_entry(object TSRMLS_CC), ce TSRMLS_CC))) {
+                   /* We are calling method of the other (incompatible) class,
+                      but passing $this. This is done for compatibility with php-4. */
+                       if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
+                               zend_error(
+                                       object ? E_DEPRECATED : E_STRICT,
+                                       "Non-static method %s::%s() should not be called statically%s",
+                                       fbc->common.scope->name->val, fbc->common.function_name->val,
+                                       object ? ", assuming $this from incompatible context" : "");
+                       } else {
+                               /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
+                               zend_error_noreturn(
+                                       E_ERROR,
+                                       "Non-static method %s::%s() cannot be called statically%s",
+                                       fbc->common.scope->name->val, fbc->common.function_name->val,
+                                       object ? ", assuming $this from incompatible context" : "");
                        }
                }
        }
@@ -22934,16 +23077,25 @@ static int ZEND_FASTCALL  ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_VAR_HANDLER(ZEND
                if (Z_OBJ(EX(This))) {
                        object = Z_OBJ(EX(This));
                        GC_REFCOUNT(object)++;
-                       if (object->handlers->get_class_entry &&
-                           !instanceof_function(zend_get_class_entry(object TSRMLS_CC), ce TSRMLS_CC)) {
-                           /* We are calling method of the other (incompatible) class,
-                              but passing $this. This is done for compatibility with php-4. */
-                               if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
-                                       zend_error(E_DEPRECATED, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", fbc->common.scope->name->val, fbc->common.function_name->val);
-                               } else {
-                                       /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
-                                       zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", fbc->common.scope->name->val, fbc->common.function_name->val);
-                               }
+               }
+               if (!object ||
+                   (object->handlers->get_class_entry &&
+                    !instanceof_function(zend_get_class_entry(object TSRMLS_CC), ce TSRMLS_CC))) {
+                   /* We are calling method of the other (incompatible) class,
+                      but passing $this. This is done for compatibility with php-4. */
+                       if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
+                               zend_error(
+                                       object ? E_DEPRECATED : E_STRICT,
+                                       "Non-static method %s::%s() should not be called statically%s",
+                                       fbc->common.scope->name->val, fbc->common.function_name->val,
+                                       object ? ", assuming $this from incompatible context" : "");
+                       } else {
+                               /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
+                               zend_error_noreturn(
+                                       E_ERROR,
+                                       "Non-static method %s::%s() cannot be called statically%s",
+                                       fbc->common.scope->name->val, fbc->common.function_name->val,
+                                       object ? ", assuming $this from incompatible context" : "");
                        }
                }
        }
@@ -24401,16 +24553,25 @@ static int ZEND_FASTCALL  ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_UNUSED_HANDLER(Z
                if (Z_OBJ(EX(This))) {
                        object = Z_OBJ(EX(This));
                        GC_REFCOUNT(object)++;
-                       if (object->handlers->get_class_entry &&
-                           !instanceof_function(zend_get_class_entry(object TSRMLS_CC), ce TSRMLS_CC)) {
-                           /* We are calling method of the other (incompatible) class,
-                              but passing $this. This is done for compatibility with php-4. */
-                               if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
-                                       zend_error(E_DEPRECATED, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", fbc->common.scope->name->val, fbc->common.function_name->val);
-                               } else {
-                                       /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
-                                       zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", fbc->common.scope->name->val, fbc->common.function_name->val);
-                               }
+               }
+               if (!object ||
+                   (object->handlers->get_class_entry &&
+                    !instanceof_function(zend_get_class_entry(object TSRMLS_CC), ce TSRMLS_CC))) {
+                   /* We are calling method of the other (incompatible) class,
+                      but passing $this. This is done for compatibility with php-4. */
+                       if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
+                               zend_error(
+                                       object ? E_DEPRECATED : E_STRICT,
+                                       "Non-static method %s::%s() should not be called statically%s",
+                                       fbc->common.scope->name->val, fbc->common.function_name->val,
+                                       object ? ", assuming $this from incompatible context" : "");
+                       } else {
+                               /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
+                               zend_error_noreturn(
+                                       E_ERROR,
+                                       "Non-static method %s::%s() cannot be called statically%s",
+                                       fbc->common.scope->name->val, fbc->common.function_name->val,
+                                       object ? ", assuming $this from incompatible context" : "");
                        }
                }
        }
@@ -26302,16 +26463,25 @@ static int ZEND_FASTCALL  ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_CV_HANDLER(ZEND_
                if (Z_OBJ(EX(This))) {
                        object = Z_OBJ(EX(This));
                        GC_REFCOUNT(object)++;
-                       if (object->handlers->get_class_entry &&
-                           !instanceof_function(zend_get_class_entry(object TSRMLS_CC), ce TSRMLS_CC)) {
-                           /* We are calling method of the other (incompatible) class,
-                              but passing $this. This is done for compatibility with php-4. */
-                               if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
-                                       zend_error(E_DEPRECATED, "Non-static method %s::%s() should not be called statically, assuming $this from incompatible context", fbc->common.scope->name->val, fbc->common.function_name->val);
-                               } else {
-                                       /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
-                                       zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context", fbc->common.scope->name->val, fbc->common.function_name->val);
-                               }
+               }
+               if (!object ||
+                   (object->handlers->get_class_entry &&
+                    !instanceof_function(zend_get_class_entry(object TSRMLS_CC), ce TSRMLS_CC))) {
+                   /* We are calling method of the other (incompatible) class,
+                      but passing $this. This is done for compatibility with php-4. */
+                       if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
+                               zend_error(
+                                       object ? E_DEPRECATED : E_STRICT,
+                                       "Non-static method %s::%s() should not be called statically%s",
+                                       fbc->common.scope->name->val, fbc->common.function_name->val,
+                                       object ? ", assuming $this from incompatible context" : "");
+                       } else {
+                               /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
+                               zend_error_noreturn(
+                                       E_ERROR,
+                                       "Non-static method %s::%s() cannot be called statically%s",
+                                       fbc->common.scope->name->val, fbc->common.function_name->val,
+                                       object ? ", assuming $this from incompatible context" : "");
                        }
                }
        }
index 52ddeebd1c2b72b2c83fb6aad8c4b04f74a352ee..b90f0ce9127059ddd65f29ba710e5662720cb739 100644 (file)
@@ -144,7 +144,7 @@ var_dump($u1, $u2);
 ?>
 --EXPECTF--
 
- ---- Pass by ref / pass by val: functions ----
+---- Pass by ref / pass by val: functions ----
 
 Notice: Undefined variable: u1 in %s on line 72
 
@@ -179,40 +179,40 @@ string(12) "Ref2 changed"
 
  ---- Pass by ref / pass by val: static method calls ----
 
-Notice: Undefined variable: u1 in %s on line 95
-
 Strict Standards: Non-static method C::v() should not be called statically in %s on line 95
 
+Notice: Undefined variable: u1 in %s on line 95
+
 Strict Standards: Non-static method C::r() should not be called statically in %s on line 96
 
 Notice: Undefined variable: u1 in %s on line 97
 NULL
 string(11) "Ref changed"
 
+Strict Standards: Non-static method C::vv() should not be called statically in %s on line 100
+
 Notice: Undefined variable: u1 in %s on line 100
 
 Notice: Undefined variable: u2 in %s on line 100
 
-Strict Standards: Non-static method C::vv() should not be called statically in %s on line 100
-
 Notice: Undefined variable: u1 in %s on line 101
 
 Notice: Undefined variable: u2 in %s on line 101
 NULL
 NULL
 
-Notice: Undefined variable: u1 in %s on line 104
-
 Strict Standards: Non-static method C::vr() should not be called statically in %s on line 104
 
+Notice: Undefined variable: u1 in %s on line 104
+
 Notice: Undefined variable: u1 in %s on line 105
 NULL
 string(11) "Ref changed"
 
-Notice: Undefined variable: u2 in %s on line 108
-
 Strict Standards: Non-static method C::rv() should not be called statically in %s on line 108
 
+Notice: Undefined variable: u2 in %s on line 108
+
 Notice: Undefined variable: u2 in %s on line 109
 string(11) "Ref changed"
 NULL
@@ -258,4 +258,4 @@ Notice: Undefined variable: u2 in %s on line 135
 string(11) "Ref changed"
 NULL
 string(12) "Ref1 changed"
-string(12) "Ref2 changed"
\ No newline at end of file
+string(12) "Ref2 changed"