1--TEST-- 2Fibers in destructors 006: multiple GC runs 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 if ($id === 0) { 20 global $f2; 21 $f2 = Fiber::getCurrent(); 22 Fiber::suspend(new stdClass); 23 } 24 printf("%d: End destruct\n", $id); 25 } 26} 27 28$f = new Fiber(function () { 29 new Cycle(); 30 new Cycle(); 31 gc_collect_cycles(); 32}); 33 34$f->start(); 35 36new Cycle(); 37new Cycle(); 38gc_collect_cycles(); 39 40$f2->resume(); 41 42?> 43--EXPECT-- 440: Start destruct 451: Start destruct 461: End destruct 472: Start destruct 482: End destruct 493: Start destruct 503: End destruct 510: End destruct 52Shutdown 53