#44143 [NEW]: __set_state can't assign to inherited private properties

From: Date: Sun, 17 Feb 2008 18:04:39 +0000
Subject: #44143 [NEW]: __set_state can't assign to inherited private properties
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-122365@lists.php.net to get a copy of this message
From:             elias at adaptiveinstance dot org
Operating system: Linux ubuntu 2.6.22-14-386
PHP version:      5.3CVS-2008-02-17 (snap)
PHP Bug Type:     Class/Object related
Bug description:  __set_state can't assign to inherited private properties

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 bug report at http://bugs.php.net/?id=44143&edit=1
-- 
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44143&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44143&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44143&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=44143&r=fixedcvs
Fixed in release:             http://bugs.php.net/fix.php?id=44143&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=44143&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=44143&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=44143&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=44143&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=44143&r=notwrong
Not enough info:              http://bugs.php.net/fix.php?id=44143&r=notenoughinfo
Submitted twice:              http://bugs.php.net/fix.php?id=44143&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=44143&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=44143&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=44143&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=44143&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=44143&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=44143&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=44143&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=44143&r=mysqlcfg


Thread (3 messages)

« previous php.bugs (#122365) next »