1--TEST-- 2Fibers in destructors 010: Destructor resurrects object, suspends, unrefs 3--FILE-- 4<?php 5 6register_shutdown_function(function () { 7 printf("Shutdown\n"); 8}); 9 10class Cycle { 11 public $self; 12 public function __construct() { 13 $this->self = $this; 14 } 15 public function __destruct() { 16 global $ref, $f2; 17 $ref = $this; 18 $f2 = Fiber::getCurrent(); 19 Fiber::suspend(); 20 $ref = null; 21 } 22} 23 24$f = new Fiber(function () { 25 global $weakRef; 26 $weakRef = WeakReference::create(new Cycle()); 27 gc_collect_cycles(); 28}); 29 30$f->start(); 31var_dump((bool) $weakRef->get()); 32gc_collect_cycles(); 33$f2->resume(); 34gc_collect_cycles(); 35var_dump((bool) $weakRef->get()); 36?> 37--EXPECT-- 38bool(true) 39bool(false) 40Shutdown 41