xref: /PHP-7.4/Zend/tests/gc_028.phpt (revision 60a7e60b)
1--TEST--
2GC 028: GC and destructors
3--INI--
4zend.enable_gc=1
5--FILE--
6<?php
7class Foo {
8	public $bar;
9	function __destruct() {
10		if ($this->bar !== null) {
11			unset($this->bar);
12		}
13	}
14}
15class Bar {
16	public $foo;
17        function __destruct() {
18                if ($this->foo !== null) {
19                        unset($this->foo);
20                }
21        }
22
23}
24$foo = new Foo();
25$bar = new Bar();
26$foo->bar = $bar;
27$bar->foo = $foo;
28unset($foo);
29unset($bar);
30var_dump(gc_collect_cycles());
31var_dump(gc_collect_cycles());
32?>
33--EXPECT--
34int(0)
35int(1)
36