xref: /PHP-7.2/Zend/tests/gc_028.phpt (revision e24fff2d)
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());
31?>
32--EXPECT--
33int(2)
34