From: drm at melp dot nl Operating system: Windows XP PHP version: 5.0.0b2 (beta2) PHP Bug Type: Feature/Change Request Bug description: At least a notice when accessing private members in a derived class?
Description: ------------ Hi :) I read in the new features list of Zend Engine 2 that access modifiers like private/protected are introduced, but something really weird comes in mind when reading carefully. Private members are returned _empty_ wheing tried to be accessed from derived classes. "Intended behaviour", is said. OK, i can live with that. But even when i turned on notices with error_reporting, nothing is noticed? The case grows when looking at the following code sample. This could produce very weird bugs when writing PHP code (i hope you can see that ;)), so I would like to convince you all to at least implement a Notice when trying to access (non-defined) private (parent) members? It would do the coders not using E_ALL no harm :) Please consider this :) Reproduce code: --------------- error_reporting ( E_ALL ); class Test { private $member; function __construct () { $this->member = "Test constructor"; } function __toString () { return "Member contains: {$this->member}"; } function getMember () { return $this->member; } function setMember ( $m ) { $this->member = $m; } } class DeriveTest extends Test { function __construct () { parent::__construct (); } function __toString () { return "Member contains: {$this->member}, though getMember() says: " . $this->getMember() ."?"; } function setMember ( $m ) { $this->member = $m; } } $o = new DeriveTest (); echo $o, '<br>'; $o->setMember ( "a" ); echo $o, '<br>'; Expected result: ---------------- The expected result would be for me: Notice: undefined member ``DeriveTest::$member'' in ...\test.php on line 12 Member contains: , though getMember() says: Test constructor? Member contains: a, though getMember() says: Test constructor? or something of the sort Actual result: -------------- The actual result is: Member contains: , though getMember() says: Test constructor? Member contains: a, though getMember() says: Test constructor? -- Edit bug report at http://bugs.php.net/?id=26325&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26325&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26325&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=26325&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=26325&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=26325&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=26325&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=26325&r=support Expected behavior: http://bugs.php.net/fix.php?id=26325&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=26325&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=26325&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=26325&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26325&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=26325&r=dst IIS Stability: http://bugs.php.net/fix.php?id=26325&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=26325&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=26325&r=float