1--TEST-- 2Object properties HT may need to be removed from nested data 3--FILE-- 4<?php 5 6class Test { 7 public function __destruct() { 8 $GLOBALS['x'] = $this; 9 } 10} 11 12$t = new Test; 13$t->x = new stdClass; 14$t->x->t = $t; 15$a = (array) $t->x; 16unset($t, $a); 17gc_collect_cycles(); 18var_dump($x); 19 20// TODO: The destructor *should* be running here, but doesn't. 21// This works in PHP >= 7.3 though. 22 23?> 24--EXPECTF-- 25Notice: Undefined variable: x in %s on line %d 26NULL 27