1--TEST--
2Self-referencing map entry GC - 002
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$map[$obj] = [$obj];
14
15gc_collect_cycles();
16
17var_dump($map);
18
19$obj = null;
20gc_collect_cycles();
21
22var_dump($map);
23
24?>
25--EXPECTF--
26object(WeakMap)#%d (1) {
27  [0]=>
28  array(2) {
29    ["key"]=>
30    object(Value)#%d (1) {
31      ["value"]=>
32      string(1) "a"
33    }
34    ["value"]=>
35    array(1) {
36      [0]=>
37      object(Value)#%d (1) {
38        ["value"]=>
39        string(1) "a"
40      }
41    }
42  }
43}
44object(WeakMap)#1 (0) {
45}
46