1--TEST--
2SPL: ArrayObject::exchangeArray() and copy-on-write references
3--FILE--
4<?php
5$ao = new ArrayObject();
6$swapIn = array();
7$cowRef = $swapIn; // create a copy-on-write ref to $swapIn
8$ao->exchangeArray($swapIn);
9
10$ao['a'] = 'adding element to $ao';
11$swapIn['b'] = 'adding element to $swapIn';
12$ao['c'] = 'adding another element to $ao';
13
14echo "\n--> swapIn:  ";
15var_dump($swapIn);
16
17echo "\n--> cowRef:  ";
18var_dump($cowRef);
19
20echo "\n--> ao:  ";
21var_dump($ao);
22?>
23--EXPECTF--
24--> swapIn:  array(1) {
25  ["b"]=>
26  string(25) "adding element to $swapIn"
27}
28
29--> cowRef:  array(0) {
30}
31
32--> ao:  object(ArrayObject)#%d (1) {
33  ["storage":"ArrayObject":private]=>
34  array(2) {
35    ["a"]=>
36    string(21) "adding element to $ao"
37    ["c"]=>
38    string(29) "adding another element to $ao"
39  }
40}
41