|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44143 .
Submitted: 2008-02-17 18:04 UTC Modified: 2008-02-18 16:19 UTC
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: elias at adaptiveinstance dot org Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.3CVS-2008-02-17 (snap) OS: Linux ubuntu 2.6.22-14-386
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: elias at adaptiveinstance dot org
New email:
PHP Version: OS:


 [2008-02-17 18:04 UTC] elias at adaptiveinstance dot org
__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) {
  string(3) "bar"
object(B)#2 (2) {
  string(3) "bar"

Actual result:
object(A)#1 (1) {
  string(3) "bar"
object(B)#2 (2) {
  string(3) "foo"
  string(3) "bar"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-17 19:08 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

 [2008-02-18 16:19 UTC] elias at adaptiveinstance dot org
ok, i see my mistake. explanation for other's who put a foot in it:

this behaviour is intended by the class system. private properties
are scoped to their class you can redefine them (also dynamically) in
any extending class. so it's really a feature and not a bug. :)

maybe a note of this side effect in the var_export documentation could
help others.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jul 18 14:01:29 2024 UTC