1--TEST--
2Fibers in destructors 008: Fibers in shutdown sequence
3--FILE--
4<?php
5
6register_shutdown_function(function () {
7    printf("Shutdown\n");
8});
9
10class C {
11    public static $instance;
12    public function __destruct() {
13        $f = new Fiber(function () {
14            printf("Started\n");
15            Fiber::suspend();
16            printf("Resumed\n");
17            Fiber::suspend();
18        });
19        $f->start();
20        $f->resume();
21        // Can not suspend main fiber
22        Fiber::suspend();
23    }
24}
25
26C::$instance = new C();
27
28?>
29--EXPECTF--
30Shutdown
31Started
32Resumed
33
34Fatal error: Uncaught FiberError: Cannot suspend outside of a fiber in %s:%d
35Stack trace:
36#0 %s(%d): Fiber::suspend()
37#1 [internal function]: C->__destruct()
38#2 {main}
39  thrown in %s on line %d
40