xref: /PHP-5.6/Zend/tests/gc_017.phpt (revision e24fff2d)
1--TEST--
2GC 017: GC and destructors with unset
3--INI--
4zend.enable_gc=1
5--FILE--
6<?php
7class Node {
8	public $name;
9	public $children;
10	public $parent;
11	function __construct($name) {
12		$this->name = $name;
13		$this->children = array();
14		$this->parent = null;
15	}
16	function insert($node) {
17		$node->parent = $this;
18		$this->children[] = $node;
19	}
20	function __destruct() {
21		var_dump($this->name);
22		unset($this->name);
23		unset($this->children);
24		unset($this->parent);
25	}
26}
27$a = new Node('A');
28$b = new Node('B');
29$c = new Node('C');
30$a->insert($b);
31$a->insert($c);
32unset($a);
33unset($b);
34unset($c);
35var_dump(gc_collect_cycles());
36echo "ok\n"
37?>
38--EXPECTF--
39string(1) "%s"
40string(1) "%s"
41string(1) "%s"
42int(10)
43ok
44