#44143 [Opn->Bgs]: __set_state can't assign to inherited private properties
ID: 44143
Updated by: johannes@php.net
Reported By: elias at adaptiveinstance dot org
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
Operating System: Linux ubuntu 2.6.22-14-386
PHP Version: 5.3CVS-2008-02-17 (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:
------------------------------------------------------------------------
[2008-02-17 18:04:39] elias at adaptiveinstance dot org
Description:
------------
__set_state can't assign to inherited private properties but creates an
new dynamic property.
Reproduce code:
---------------
class A {
private $foo = 'foo';
public static function __set_state($state) {
$a = new A();
$a->foo = 'bar';
return $a;
}
}
class B extends A {
public static function __set_state($state) {
$b = new B();
$b->foo = 'bar';
return $b;
}
}
$a = A::__set_state(array());
$b = B::__set_state(array());
var_dump($a, $b);
Expected result:
----------------
object(A)#1 (1) {
["foo":"A":private]=>
string(3) "bar"
}
object(B)#2 (2) {
["foo":"A":private]=>
string(3) "bar"
}
Actual result:
--------------
object(A)#1 (1) {
["foo":"A":private]=>
string(3) "bar"
}
object(B)#2 (2) {
["foo":"A":private]=>
string(3) "foo"
["foo"]=>
string(3) "bar"
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=44143&edit=1
Thread (3 messages)