ID: 48355 Updated by: [email protected] Reported By: gaj dot capuder at spletna-postaja dot com -Status: Open +Status: Bogus Bug Type: Feature/Change Request Operating System: Vista PHP Version: 5.3.0RC2 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php . Previous Comments: ------------------------------------------------------------------------ [2009-05-21 12:58:47] gaj dot capuder at spletna-postaja dot com Description: ------------ When accessing object properties directly witin object's parent (the one which object extends) the property acts as if it was public (no error). Similar thing happens with protected constructors where new instance of a certain class can be created using "new" when the call is made inside of an object which is the parent or which extends the same parent. Reproduce code: --------------- class A { public function access() { $b = new B; echo $b->property; } } class B extends A { protected $property = 'Should be protected'; } class C extends A { } $c = new C; $c->access(); $b = new B; echo $b->property; Expected result: ---------------- Fatal error: Cannot access protected property B::$property Actual result: -------------- Protection is broken Fatal error: Cannot access protected property B::$property ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48355&edit=1
