xref: /PHP-7.2/ext/spl/tests/bug70730.phpt (revision e2d60900)
1--TEST--
2Bug #70730 (Incorrect ArrayObject serialization if unset is called in serialize())
3--FILE--
4<?php
5class A extends \ArrayObject
6{
7	protected $foo;
8
9	public function __construct()
10	{
11		$this->foo = 'bar';
12	}
13
14	public function serialize()
15	{
16		unset($this->foo);
17		$result = parent::serialize();
18		$this->foo = 'bar';
19		return $result;
20	}
21}
22
23$a = new A();
24$a->append('item1');
25$a->append('item2');
26$a->append('item3');
27$b = new A();
28$b->unserialize($a->serialize());
29var_dump($b);
30?>
31--EXPECTF--
32object(A)#%d (2) {
33  ["foo":protected]=>
34  string(3) "bar"
35  ["storage":"ArrayObject":private]=>
36  array(3) {
37    [0]=>
38    string(5) "item1"
39    [1]=>
40    string(5) "item2"
41    [2]=>
42    string(5) "item3"
43  }
44}
45