#40402 [Opn->Bgs]: manipulate private and protected properties
| From: | tony2001@php.net | Date: | Thu, 08 Feb 2007 12:56:31 +0000 |
| Subject: | #40402 [Opn->Bgs]: manipulate private and protected properties | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-108581@lists.php.net to get a copy of this message | ||
ID: 40402
Updated by: tony2001@php.net
Reported By: jpieper at intergenia dot de
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
Operating System: Irrelevant
PHP Version: 5.2.1RC4
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:
------------------------------------------------------------------------
[2007-02-08 12:53:02] jpieper at intergenia dot de
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"
}
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40402&edit=1