1--TEST-- 2Unset property where unset will recursively access property again 3--FILE-- 4<?php 5class Node { 6 public $parent = null; 7 public $children = []; 8 function insert(Node $node) { 9 $node->parent = $this; 10 $this->children[] = $node; 11 } 12 function __destruct() { 13 var_dump($this); 14 unset($this->children); 15 } 16} 17 18$a = new Node; 19$a->insert(new Node); 20$a->insert(new Node); 21?> 22--EXPECT-- 23object(Node)#1 (2) { 24 ["parent"]=> 25 NULL 26 ["children"]=> 27 array(2) { 28 [0]=> 29 object(Node)#2 (2) { 30 ["parent"]=> 31 *RECURSION* 32 ["children"]=> 33 array(0) { 34 } 35 } 36 [1]=> 37 object(Node)#3 (2) { 38 ["parent"]=> 39 *RECURSION* 40 ["children"]=> 41 array(0) { 42 } 43 } 44 } 45} 46object(Node)#2 (2) { 47 ["parent"]=> 48 object(Node)#1 (2) { 49 ["parent"]=> 50 NULL 51 } 52 ["children"]=> 53 array(0) { 54 } 55} 56object(Node)#3 (2) { 57 ["parent"]=> 58 object(Node)#1 (2) { 59 ["parent"]=> 60 NULL 61 } 62 ["children"]=> 63 array(0) { 64 } 65} 66