]> granicus.if.org Git - php/commitdiff
Fixed bug #70997 (When using parentClass:: instead of parent::, static context changed)
authorDmitry Stogov <dmitry@zend.com>
Mon, 30 Nov 2015 13:52:57 +0000 (16:52 +0300)
committerDmitry Stogov <dmitry@zend.com>
Mon, 30 Nov 2015 13:52:57 +0000 (16:52 +0300)
NEWS
Zend/tests/bug70997.phpt [new file with mode: 0644]
Zend/zend_vm_def.h
Zend/zend_vm_execute.h

diff --git a/NEWS b/NEWS
index c5aa1f30fddbab41cb6a3f18b5c65c4182febc02..e74a35181b460c7d26478420ca7564cf7aa4dcfd 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ PHP                                                                        NEWS
 ?? ??? 2015, PHP 7.0.1
 
 - Core:
+  . Fixed bug #70997 (When using parentClass:: instead of parent::, static
+    context changed). (Dmitry)
   . Fixed bug #70970 (Segfault when combining error handler with output
        buffering). (Laruence)
   . Fixed bug #70967 (Weird error handling for __toString when Error is
diff --git a/Zend/tests/bug70997.phpt b/Zend/tests/bug70997.phpt
new file mode 100644 (file)
index 0000000..bdb3377
--- /dev/null
@@ -0,0 +1,26 @@
+--TEST--
+Bug #70997 (When using parentClass:: instead of parent::, static context changed)
+--FILE--
+<?php
+class A {
+    const TEST = false;
+    
+    public function test()
+    {
+        var_dump(static::TEST);
+    }
+}
+
+class B extends A {
+    const TEST = true;
+    
+    public function test()
+    {
+        A::test();
+    }
+}
+
+$b = new B;
+$b->test();
+--EXPECT--
+bool(true)
index 8fae72b2f66e062714d90d722e99c81261eb8e3c..bc41a0bacf0fe7899c23adacbcee99136e44014a 100644 (file)
@@ -3102,8 +3102,8 @@ ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_METHOD_CALL, CONST|VAR, CONST|TMPVAR|UNUSE
        if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
                if (Z_OBJ(EX(This)) && instanceof_function(Z_OBJCE(EX(This)), ce)) {
                        object = Z_OBJ(EX(This));
-               }
-               if (!object) {
+                       ce = object->ce;
+               } else {
                        if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
                                /* Allowed for PHP 4 compatibility. */
                                zend_error(
index 5f02d4357e4bbef7a3daed9f4ab854b509a8d45c..74adfe4da0ad3250210008fe3a0880513f42d94b 100644 (file)
@@ -5692,8 +5692,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_C
        if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
                if (Z_OBJ(EX(This)) && instanceof_function(Z_OBJCE(EX(This)), ce)) {
                        object = Z_OBJ(EX(This));
-               }
-               if (!object) {
+                       ce = object->ce;
+               } else {
                        if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
                                /* Allowed for PHP 4 compatibility. */
                                zend_error(
@@ -7667,8 +7667,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_C
        if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
                if (Z_OBJ(EX(This)) && instanceof_function(Z_OBJCE(EX(This)), ce)) {
                        object = Z_OBJ(EX(This));
-               }
-               if (!object) {
+                       ce = object->ce;
+               } else {
                        if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
                                /* Allowed for PHP 4 compatibility. */
                                zend_error(
@@ -9410,8 +9410,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_C
        if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
                if (Z_OBJ(EX(This)) && instanceof_function(Z_OBJCE(EX(This)), ce)) {
                        object = Z_OBJ(EX(This));
-               }
-               if (!object) {
+                       ce = object->ce;
+               } else {
                        if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
                                /* Allowed for PHP 4 compatibility. */
                                zend_error(
@@ -11218,8 +11218,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_C
        if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
                if (Z_OBJ(EX(This)) && instanceof_function(Z_OBJCE(EX(This)), ce)) {
                        object = Z_OBJ(EX(This));
-               }
-               if (!object) {
+                       ce = object->ce;
+               } else {
                        if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
                                /* Allowed for PHP 4 compatibility. */
                                zend_error(
@@ -17547,8 +17547,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_V
        if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
                if (Z_OBJ(EX(This)) && instanceof_function(Z_OBJCE(EX(This)), ce)) {
                        object = Z_OBJ(EX(This));
-               }
-               if (!object) {
+                       ce = object->ce;
+               } else {
                        if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
                                /* Allowed for PHP 4 compatibility. */
                                zend_error(
@@ -19175,8 +19175,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_V
        if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
                if (Z_OBJ(EX(This)) && instanceof_function(Z_OBJCE(EX(This)), ce)) {
                        object = Z_OBJ(EX(This));
-               }
-               if (!object) {
+                       ce = object->ce;
+               } else {
                        if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
                                /* Allowed for PHP 4 compatibility. */
                                zend_error(
@@ -20796,8 +20796,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_V
        if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
                if (Z_OBJ(EX(This)) && instanceof_function(Z_OBJCE(EX(This)), ce)) {
                        object = Z_OBJ(EX(This));
-               }
-               if (!object) {
+                       ce = object->ce;
+               } else {
                        if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
                                /* Allowed for PHP 4 compatibility. */
                                zend_error(
@@ -22366,8 +22366,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_V
        if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
                if (Z_OBJ(EX(This)) && instanceof_function(Z_OBJCE(EX(This)), ce)) {
                        object = Z_OBJ(EX(This));
-               }
-               if (!object) {
+                       ce = object->ce;
+               } else {
                        if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
                                /* Allowed for PHP 4 compatibility. */
                                zend_error(