From: Dmitry Stogov Date: Wed, 8 Jun 2005 08:05:27 +0000 (+0000) Subject: Fixed bug #30820 (static member conflict with $this->member silently ignored) X-Git-Tag: php-5.0.5RC1~185 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bfc4de7e6f393527c992f6904cdd884abbadf233;p=php Fixed bug #30820 (static member conflict with $this->member silently ignored) --- diff --git a/NEWS b/NEWS index f08cdd3b4a..a89f7de0eb 100644 --- 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 index 0000000000..97e46e9287 --- /dev/null +++ b/Zend/tests/bug30820.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #30820 (static member conflict with $this->member silently ignored) +--INI-- +error_reporting=4095 +--FILE-- +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 diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index cb3c865d14..43afc6ec2b 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -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 {