1--TEST-- 2Multiple WeakMaps / WeakRefs on the same object 3--FILE-- 4<?php 5 6$obj = new stdClass; 7 8$ref = WeakReference::create($obj); 9$map = new WeakMap; 10$map[$obj] = 1; 11$map2 = new WeakMap; 12$map2[$obj] = 1; 13$map3 = clone $map2; 14 15var_dump($ref === WeakReference::create($obj)); 16var_dump($ref->get(), $map, $map2, $map3); 17unset($obj); 18var_dump($ref->get(), $map, $map2, $map3); 19unset($ref, $map, $map2); 20 21$obj = new stdClass; 22$ref = WeakReference::create($obj); 23$map = new WeakMap; 24$map[$obj] = 1; 25$map2 = new WeakMap; 26$map2[$obj] = 1; 27$map3 = clone $map2; 28 29unset($ref, $map, $map2, $map3); 30var_dump($obj); 31unset($obj); 32 33?> 34--EXPECT-- 35bool(true) 36object(stdClass)#1 (0) { 37} 38object(WeakMap)#3 (1) { 39 [0]=> 40 array(2) { 41 ["key"]=> 42 object(stdClass)#1 (0) { 43 } 44 ["value"]=> 45 int(1) 46 } 47} 48object(WeakMap)#4 (1) { 49 [0]=> 50 array(2) { 51 ["key"]=> 52 object(stdClass)#1 (0) { 53 } 54 ["value"]=> 55 int(1) 56 } 57} 58object(WeakMap)#5 (1) { 59 [0]=> 60 array(2) { 61 ["key"]=> 62 object(stdClass)#1 (0) { 63 } 64 ["value"]=> 65 int(1) 66 } 67} 68NULL 69object(WeakMap)#3 (0) { 70} 71object(WeakMap)#4 (0) { 72} 73object(WeakMap)#5 (0) { 74} 75object(stdClass)#4 (0) { 76} 77