]> granicus.if.org Git - php/commitdiff
Added E_STRICT warning in case of calling non-static method from incompatible context...
authorDmitry Stogov <dmitry@php.net>
Wed, 15 Mar 2006 11:15:20 +0000 (11:15 +0000)
committerDmitry Stogov <dmitry@php.net>
Wed, 15 Mar 2006 11:15:20 +0000 (11:15 +0000)
Zend/zend_vm_def.h
Zend/zend_vm_execute.h

index 85a6497004199c16330347415e5bfd60e8e6e85c..e0333793fb91c457cf7d34cb09e47430c75c1e16 100644 (file)
@@ -1753,6 +1753,15 @@ ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_METHOD_CALL, ANY, CONST|TMP|VAR|UNUSED|CV)
        if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) {
                EX(object) = NULL;
        } else {
+               if (OP2_TYPE != IS_UNUSED &&
+                   EG(This) &&
+                   Z_OBJ_HT_P(EG(This))->get_class_entry &&
+                   !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);
+
+               }
                if ((EX(object) = EG(This))) {
                        EX(object)->refcount++;
                }
index b582775aec4e15d0a99b5c194a42fcee508121e0..2cc92ec21217fddb0ec646ba577dfcce26a9afec 100644 (file)
@@ -687,6 +687,15 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_A
        if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) {
                EX(object) = NULL;
        } else {
+               if (IS_CONST != IS_UNUSED &&
+                   EG(This) &&
+                   Z_OBJ_HT_P(EG(This))->get_class_entry &&
+                   !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);
+
+               }
                if ((EX(object) = EG(This))) {
                        EX(object)->refcount++;
                }
@@ -896,6 +905,15 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG
        if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) {
                EX(object) = NULL;
        } else {
+               if (IS_TMP_VAR != IS_UNUSED &&
+                   EG(This) &&
+                   Z_OBJ_HT_P(EG(This))->get_class_entry &&
+                   !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);
+
+               }
                if ((EX(object) = EG(This))) {
                        EX(object)->refcount++;
                }
@@ -1020,6 +1038,15 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG
        if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) {
                EX(object) = NULL;
        } else {
+               if (IS_VAR != IS_UNUSED &&
+                   EG(This) &&
+                   Z_OBJ_HT_P(EG(This))->get_class_entry &&
+                   !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);
+
+               }
                if ((EX(object) = EG(This))) {
                        EX(object)->refcount++;
                }
@@ -1143,6 +1170,15 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_
        if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) {
                EX(object) = NULL;
        } else {
+               if (IS_UNUSED != IS_UNUSED &&
+                   EG(This) &&
+                   Z_OBJ_HT_P(EG(This))->get_class_entry &&
+                   !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);
+
+               }
                if ((EX(object) = EG(This))) {
                        EX(object)->refcount++;
                }
@@ -1224,6 +1260,15 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS
        if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) {
                EX(object) = NULL;
        } else {
+               if (IS_CV != IS_UNUSED &&
+                   EG(This) &&
+                   Z_OBJ_HT_P(EG(This))->get_class_entry &&
+                   !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);
+
+               }
                if ((EX(object) = EG(This))) {
                        EX(object)->refcount++;
                }