xref: /PHP-8.3/ext/spl/tests/bug53071.phpt (revision f8d79582)
1--TEST--
2Bug #53071 (Usage of SPLObjectStorage defeats gc_collect_cycles)
3--FILE--
4<?php
5gc_enable();
6class myClass
7{
8    public $member;
9}
10function LimitedScope()
11{
12    $myA = new myClass();
13    $myB = new SplObjectStorage();
14    $myC = new myClass();
15    $myC->member = $myA; // myC has a reference to myA
16    $myB->Attach($myC);  // myB attaches myC
17    $myA->member = $myB; // myA has myB, comleting the cycle
18}
19LimitedScope();
20var_dump(gc_collect_cycles());
21
22echo "Done.\n";
23
24?>
25--EXPECT--
26int(3)
27Done.
28