1--TEST--
2Cannot resume fiber within destructor
3--FILE--
4<?php
5
6$fiber = new Fiber(function () {
7    Fiber::suspend();
8});
9$fiber->start();
10
11return new class ($fiber) {
12    private $fiber;
13
14    public function __construct(Fiber $fiber) {
15        $this->fiber = $fiber;
16    }
17
18    public function __destruct() {
19        $this->fiber->resume(1);
20    }
21};
22
23?>
24--EXPECTF--
25Fatal error: Uncaught FiberError: Cannot switch fibers in current execution context in %sno-switch-dtor-resume.php:%d
26Stack trace:
27#0 %sno-switch-dtor-resume.php(%d): Fiber->resume(1)
28#1 %sno-switch-dtor-resume.php(%d): class@anonymous->__destruct()
29#2 {main}
30  thrown in %sno-switch-dtor-resume.php on line %d
31