|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-05-24 18:10 UTC] johannes@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Fri Mar 13 21:00:01 2026 UTC |
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