xref: /PHP-8.2/Zend/tests/gc_041.phpt (revision f8d79582)
1--TEST--
2GC 041: Handling of references in nested data of objects with destructor
3--INI--
4zend.enable_gc = 1
5--FILE--
6<?php
7class ryat {
8        var $ryat;
9        var $chtg;
10        var $nested;
11        function __destruct() {
12                $GLOBALS['x'] = $this;
13        }
14}
15$o = new ryat;
16$o->nested = [];
17$o->nested[] =& $o->nested;
18$o->ryat = $o;
19$x =& $o->chtg;
20unset($o);
21var_dump(gc_collect_cycles());
22var_dump($x);
23?>
24--EXPECT--
25int(0)
26object(ryat)#1 (3) {
27  ["ryat"]=>
28  *RECURSION*
29  ["chtg"]=>
30  *RECURSION*
31  ["nested"]=>
32  &array(1) {
33    [0]=>
34    *RECURSION*
35  }
36}
37