]> granicus.if.org Git - php/commitdiff
Additional fix for bug #76860.
authorDmitry Stogov <dmitry@zend.com>
Tue, 11 Sep 2018 15:29:27 +0000 (18:29 +0300)
committerDmitry Stogov <dmitry@zend.com>
Tue, 11 Sep 2018 15:29:27 +0000 (18:29 +0300)
Zend/tests/bug76860_2.phpt [new file with mode: 0644]
Zend/zend_object_handlers.c

diff --git a/Zend/tests/bug76860_2.phpt b/Zend/tests/bug76860_2.phpt
new file mode 100644 (file)
index 0000000..bc92702
--- /dev/null
@@ -0,0 +1,34 @@
+--TEST--
+Bug #76860 (Missed "Accessing static property as non static" warning)
+--FILE--
+<?php
+class A {
+    private static $a = "a";
+    private static $b = "b";
+    private static $c = "c";
+    public function __construct() {
+       var_dump($this->a, $this->b, $this->c);
+    }
+}
+class B extends A {
+    private static $a = "a1";
+    protected static $b = "b1";
+    public static $c = "c1";
+}
+new B;
+?>
+--EXPECTF--
+Notice: Accessing static property B::$a as non static in %sbug76860_2.php on line 7
+
+Notice: Undefined property: B::$a in %sbug76860_2.php on line 7
+
+Notice: Accessing static property B::$b as non static in %sbug76860_2.php on line 7
+
+Notice: Undefined property: B::$b in %sbug76860_2.php on line 7
+
+Notice: Accessing static property B::$c as non static in %sbug76860_2.php on line 7
+
+Notice: Undefined property: B::$c in %sbug76860_2.php on line 7
+NULL
+NULL
+NULL
index 3ab2a0e4be490682aad44dbae0809b91c5c651be..4e982baac1ae38bc3fff8bc74dae72ac145411d2 100644 (file)
@@ -378,7 +378,7 @@ static zend_always_inline uintptr_t zend_get_property_offset(zend_class_entry *c
                if (flags & ZEND_ACC_PUBLIC) {
                        if (!(flags & ZEND_ACC_CHANGED)) {
 no_changed:
-                               if (UNEXPECTED((flags & ZEND_ACC_STATIC) != 0)) {
+                               if (UNEXPECTED((property_info->flags & ZEND_ACC_STATIC) != 0)) {
                                        if (!silent) {
                                                zend_error(E_NOTICE, "Accessing static property %s::$%s as non static", ZSTR_VAL(ce->name), ZSTR_VAL(member));
                                        }
@@ -431,9 +431,7 @@ check_scope:
                && ((zend_property_info*)Z_PTR_P(zv))->flags & ZEND_ACC_PRIVATE
                && ((zend_property_info*)Z_PTR_P(zv))->ce == scope) {
                property_info = (zend_property_info*)Z_PTR_P(zv);
-               if (UNEXPECTED((property_info->flags & ZEND_ACC_STATIC) != 0)) {
-                       return ZEND_DYNAMIC_PROPERTY_OFFSET;
-               }
+               goto no_changed;
        } else if (UNEXPECTED(property_info == NULL)) {
 exit_dynamic:
                if (UNEXPECTED(ZSTR_VAL(member)[0] == '\0' && ZSTR_LEN(member) != 0)) {
@@ -481,7 +479,7 @@ ZEND_API zend_property_info *zend_get_property_info(zend_class_entry *ce, zend_s
                if (flags & ZEND_ACC_PUBLIC) {
                        if (!(flags & ZEND_ACC_CHANGED)) {
 no_changed:
-                               if (UNEXPECTED((flags & ZEND_ACC_STATIC) != 0)) {
+                               if (UNEXPECTED((property_info->flags & ZEND_ACC_STATIC) != 0)) {
                                        if (!silent) {
                                                zend_error(E_NOTICE, "Accessing static property %s::$%s as non static", ZSTR_VAL(ce->name), ZSTR_VAL(member));
                                        }
@@ -533,6 +531,7 @@ check_scope:
                && ((zend_property_info*)Z_PTR_P(zv))->flags & ZEND_ACC_PRIVATE
                && ((zend_property_info*)Z_PTR_P(zv))->ce == scope) {
                property_info = (zend_property_info*)Z_PTR_P(zv);
+               goto no_changed;
        } else if (UNEXPECTED(property_info == NULL)) {
 exit_dynamic:
                if (UNEXPECTED(ZSTR_VAL(member)[0] == '\0' && ZSTR_LEN(member) != 0)) {