#43698 [Opn->Bgs]: Assignment to inaccessible private property in __set() has no effect.
| From: | iliaa@php.net | Date: | Sun, 30 Dec 2007 16:26:02 +0000 |
| Subject: | #43698 [Opn->Bgs]: Assignment to inaccessible private property in __set() has no effect. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-120943@lists.php.net to get a copy of this message | ||
ID: 43698
Updated by: iliaa@php.net
Reported By: robin_fernandes at uk dot ibm dot com
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Windows
PHP Version: 5.3CVS-2007-12-28 (snap)
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-12-28 16:20:49] robin_fernandes at uk dot ibm dot com
Description:
------------
The assignment in the __set() method below is caught by the setter
recursion guard. Subsequently, I would expect it to be treated like a
direct assignment, and therefore to fail due to an attempt to write to
another class's private property.
Instead, nothing happens at all.
I believe this is related to bug 38461, whereby a crash caused by a
similar testcase was fixed, but the expected result of the assignment
was not discussed.
Reproduce code:
---------------
<?php
class C {
function __set($name, $value) {
echo "In " . __METHOD__ . "('$name', '$value')\n";
$this->$name = $value;
}
}
class D extends C {
private $hidden = "Original Value";
}
$d = new D;
$d->hidden = "New Value";
var_dump($d);
?>
Expected result:
----------------
In C::__set('hidden', 'New Value')
Fatal error: Cannot access private property D::$hidden in %s on line 5
Actual result:
--------------
In C::__set('hidden', 'New Value')
object(D)#1 (1) {
["hidden":"D":private]=>
string(14) "Original Value"
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43698&edit=1