1--TEST--
2Self-referencing map entry GC - 001
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    object(Value)#%d (1) {
36      ["value"]=>
37      string(1) "a"
38    }
39  }
40}
41object(WeakMap)#%d (0) {
42}
43