xref: /PHP-7.2/Zend/tests/gc_029_zts.phpt (revision 17ccbeec)
1--TEST--
2GC 029: GC and destructors
3--SKIPIF--
4<?php if (!PHP_ZTS) { print "skip only for zts build"; }
5--INI--
6zend.enable_gc=1
7--FILE--
8<?php
9class Foo {
10	public $bar;
11	public $x = array(1,2,3);
12	function __destruct() {
13		if ($this->bar !== null) {
14			$this->x = null;
15			unset($this->bar);
16		}
17	}
18}
19class Bar {
20	public $foo;
21        function __destruct() {
22                if ($this->foo !== null) {
23                        unset($this->foo);
24                }
25        }
26
27}
28$foo = new Foo();
29$bar = new Bar();
30$foo->bar = $bar;
31$bar->foo = $foo;
32unset($foo);
33unset($bar);
34var_dump(gc_collect_cycles());
35?>
36--EXPECT--
37int(6)
38