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->parent = null; 14 } 15 function insert($node) { 16 $node->parent = $this; 17 $this->children[] = $node; 18 } 19 function __destruct() { 20 var_dump($this->name); 21 unset($this->name); 22 unset($this->children); 23 unset($this->parent); 24 } 25} 26$a = new Node('A'); 27$b = new Node('B'); 28$c = new Node('C'); 29$a->insert($b); 30$a->insert($c); 31unset($a); 32unset($b); 33unset($c); 34var_dump(gc_collect_cycles()); 35var_dump(gc_collect_cycles()); 36echo "ok\n" 37?> 38--EXPECTF-- 39string(1) "%s" 40string(1) "%s" 41string(1) "%s" 42int(0) 43int(1) 44ok 45