From: marvinpaul at mapkreke dot com Operating system: Windows Vista PHP version: 5.2.5 PHP Bug Type: Class/Object related Bug description: "Undefined property" notice when accessing property in __get and __set
Description: ------------ If you have a child class that inherits from a parent class that implements __get and __set and you access a private property from within these functions, then you will get a notice "Undefined property" when trying to access this property from an instance of the child class. If you try accessing the properties from an instance of the parent class, it works as expected. Reproduce code: --------------- class ParentClass { private $parentMessage = "Hello, from parent!"; private function __get($property) { echo "__get($$property)\n"; return $this->$property; } private function __set($property, $value) { echo "__set($$property, $value)\n"; $this->$property = $value; } } class ChildClass extends ParentClass { private $childMessage = "Hello, from child!"; } $parent = new ParentClass(); echo $parent->parentMessage . "\n"; $child = new ChildClass(); echo $child->childMessage . "\n"; Expected result: ---------------- __get($parentMessage) Hello, from parent! __get($childMessage) Hello, from child! Actual result: -------------- __get($parentMessage) Hello, from parent! __get($childMessage) Notice: Undefined property: ChildClass::$childMessage in C:\www\bug.php on line 11 -- Edit bug report at http://bugs.php.net/?id=44784&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44784&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44784&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44784&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=44784&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=44784&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=44784&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=44784&r=needscript Try newer version: http://bugs.php.net/fix.php?id=44784&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=44784&r=support Expected behavior: http://bugs.php.net/fix.php?id=44784&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=44784&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=44784&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=44784&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44784&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=44784&r=dst IIS Stability: http://bugs.php.net/fix.php?id=44784&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=44784&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=44784&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=44784&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=44784&r=mysqlcfg