|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-04-28 13:57 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 22 17:00:01 2025 UTC |
Description: ------------ In some cases, PHP doesn't handle the visibility correctly, allowing a private or protected member to be directly accessed via $obj->prop This seems to happen when a class stores instances of itself and tries to access their properties. Reproduce code: --------------- <?php class bar { private $a; private $children = array(); public function __construct($infiniteDepth) { $this->a = 'foo'; if ($infiniteDepth) $this->children[] = new self(false); } public function privateAcces() { foreach ($this->children as $child) { echo $child->a; // here is the bug } } } $t = new toto(true); $t->privateAcces(); Expected result: ---------------- fatal error as we access the private 'a' property from a non-$this context Actual result: -------------- the property gets read correctly, as if it was public