xref: /PHP-7.1/ext/spl/tests/bug71617.phpt (revision 0bd64b50)
1--TEST--
2Bug #71617: private properties lost when unserializing ArrayObject
3--FILE--
4<?php
5
6class Test extends ArrayObject
7{
8
9	private $name = null;
10
11	public function __construct(array $input)
12	{
13		parent::__construct($input, ArrayObject::ARRAY_AS_PROPS);
14	}
15
16	public function setName($name)
17	{
18		$this->name = $name;
19		return $this;
20	}
21
22	public function getName()
23	{
24		return $this->name;
25	}
26}
27
28$test = new Test(['a' => 'a', 'b' => 'b']);
29$test->setName('ok');
30
31$ser = serialize($test);
32$unSer = unserialize($ser);
33
34var_dump($unSer->getName());
35var_dump($unSer);
36
37?>
38--EXPECT--
39string(2) "ok"
40object(Test)#2 (2) {
41  ["name":"Test":private]=>
42  string(2) "ok"
43  ["storage":"ArrayObject":private]=>
44  array(2) {
45    ["a"]=>
46    string(1) "a"
47    ["b"]=>
48    string(1) "b"
49  }
50}
51