]> granicus.if.org Git - php/commitdiff
Fixed bug #30820 (static member conflict with $this->member silently ignored)
authorDmitry Stogov <dmitry@php.net>
Wed, 8 Jun 2005 08:05:27 +0000 (08:05 +0000)
committerDmitry Stogov <dmitry@php.net>
Wed, 8 Jun 2005 08:05:27 +0000 (08:05 +0000)
NEWS
Zend/tests/bug30820.phpt [new file with mode: 0755]
Zend/zend_object_handlers.c

diff --git a/NEWS b/NEWS
index f08cdd3b4a64b4bd734bb95c93952d2b0896a712..a89f7de0eb70942eb5442080e70e41224c00713a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -129,6 +129,8 @@ PHP                                                                        NEWS
   (Dmitry)
 - Fixed bug #30889 (Conflict between __get/__set and ++ operator). (Dmitry)
 - Fixed bug #30833 (array_count_values() modifying input array). (Tony)
+- Fixed bug #30820 (static member conflict with $this->member silently
+  ignored). (Dmitry)
 - Fixed bug #30819 (Better support for LDAP SASL bind). (Jani)
 - Fixed bug #30791 (magic methods (__sleep/__wakeup/__toString) call __call if
   object is overloaded). (Dmitry)
diff --git a/Zend/tests/bug30820.phpt b/Zend/tests/bug30820.phpt
new file mode 100755 (executable)
index 0000000..97e46e9
--- /dev/null
@@ -0,0 +1,27 @@
+--TEST--
+Bug #30820 (static member conflict with $this->member silently ignored)
+--INI--
+error_reporting=4095
+--FILE--
+<?php
+class Blah {
+    private static $x;
+
+    public function show() {
+        Blah::$x = 1;
+        $this->x = 5; // no warning, but refers to different variable
+
+        echo 'Blah::$x = '. Blah::$x ."\n";
+        echo '$this->x = '. $this->x ."\n";
+    }
+}
+
+$b = new Blah();
+$b->show();
+?>
+--EXPECTF--
+Strict Standards: Accessing static property Blah::$x as non static in %sbug30820.php on line 7
+Blah::$x = 1
+
+Strict Standards: Accessing static property Blah::$x as non static in %sbug30820.php on line 10
+$this->x = 5
index cb3c865d14f72cd99d360dac19c7923d2a9d090e..43afc6ec2b53628debfee5c91b342670955dcf16 100644 (file)
@@ -214,6 +214,9 @@ static inline zend_property_info *zend_get_property_info(zend_object *zobj, zval
                                 * continue checking below...
                                 */
                        } else {
+                               if (!silent && (property_info->flags & ZEND_ACC_STATIC)) {
+                                       zend_error(E_STRICT, "Accessing static property %s::$%s as non static", zobj->ce->name, Z_STRVAL_P(member));
+                               }
                                return property_info;
                        }
                } else {