|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-02-08 12:56 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 04:00:01 2025 UTC |
Description: ------------ After typecasting an object to an array you can iterate over the properties and manipulate private/protected properties. Reproduce code: --------------- <?php class Foobar { private $oObject; public function __construct() { $this->oObject = new stdClass; } } $oFoobar = new Foobar; $aProperties = (array)$oFoobar; foreach ($aProperties as $mProperty) { if (is_object($mProperty) && ($mProperty instanceof stdClass)) { $mProperty->blaaa = 'fooo'; } } var_dump($oFoobar); ?> Expected result: ---------------- error because you must not access and rewrite/manipulate private/protected properties. Actual result: -------------- object(Foobar)#1 (1) { ["oObject:private"]=> object(stdClass)#2 (1) { ["blaaa"]=> string(4) "fooo" } }