Browse Source

Fixed bug #30820 (static member conflict with $this->member silently ignored)

PHP-5.1
Dmitry Stogov 21 years ago
parent
commit
d02d270f48
  1. 27
      Zend/tests/bug30820.phpt
  2. 3
      Zend/zend_object_handlers.c

27
Zend/tests/bug30820.phpt

@ -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

3
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 {

Loading…
Cancel
Save