1--TEST-- 2Fibers in destructors 003: Resume in destructor 3--FILE-- 4<?php 5 6register_shutdown_function(function () { 7 printf("Shutdown\n"); 8}); 9 10class Cycle { 11 public static $counter = 0; 12 public $self; 13 public function __construct() { 14 $this->self = $this; 15 } 16 public function __destruct() { 17 $id = self::$counter++; 18 printf("%d: Start destruct\n", $id); 19 global $f; 20 $f->resume(); 21 printf("%d: End destruct\n", $id); 22 } 23} 24 25$f = new Fiber(function () { 26 while (true) { 27 Fiber::suspend(); 28 } 29}); 30$f->start(); 31 32new Cycle(); 33new Cycle(); 34gc_collect_cycles(); 35 36?> 37--EXPECT-- 380: Start destruct 390: End destruct 401: Start destruct 411: End destruct 42Shutdown 43