From d02d270f48699a81ff950df8c07e13d7964b3ba3 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 8 Jun 2005 08:08:18 +0000 Subject: [PATCH] Fixed bug #30820 (static member conflict with $this->member silently ignored) --- Zend/tests/bug30820.phpt | 27 +++++++++++++++++++++++++++ Zend/zend_object_handlers.c | 3 +++ 2 files changed, 30 insertions(+) create mode 100755 Zend/tests/bug30820.phpt diff --git a/Zend/tests/bug30820.phpt b/Zend/tests/bug30820.phpt new file mode 100755 index 00000000000..97e46e9287b --- /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 83e80428d69..a0348a1ac45 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -168,6 +168,9 @@ ZEND_API struct _zend_property_info *zend_get_property_info(zend_class_entry *ce * continue checking below... */ } else { + if (!silent && (property_info->flags & ZEND_ACC_STATIC)) { + zend_error(E_STRICT, "Accessing static property %s::$%s as non static", ce->name, Z_STRVAL_P(member)); + } return property_info; } } else {