1--TEST--
2Self-referencing map entry GC - 005
3--FILE--
4<?php
5
6class Value {
7    public function __construct(public readonly string $value) {
8    }
9}
10
11$map = new WeakMap();
12$obj = new Value('a');
13$value = [$obj];
14$map[$obj] = $value;
15$obj = null;
16
17gc_collect_cycles();
18
19var_dump($map);
20
21gc_collect_cycles();
22
23$value = null;
24
25gc_collect_cycles();
26
27var_dump($map);
28
29?>
30--EXPECTF--
31object(WeakMap)#%d (1) {
32  [0]=>
33  array(2) {
34    ["key"]=>
35    object(Value)#%d (1) {
36      ["value"]=>
37      string(1) "a"
38    }
39    ["value"]=>
40    array(1) {
41      [0]=>
42      object(Value)#%d (1) {
43        ["value"]=>
44        string(1) "a"
45      }
46    }
47  }
48}
49object(WeakMap)#1 (0) {
50}
51