xref: /ext-fiber/tests/fiber-in-destruct.phpt (revision 068e4ea3)
1--TEST--
2Pause fiber in destruct
3--EXTENSIONS--
4fiber
5--FILE--
6<?php
7
8$fiber = new Fiber(function (): int {
9    $object = new class() {
10        public function __destruct()
11        {
12            Fiber::suspend(2);
13        }
14    };
15
16    Fiber::suspend(1);
17
18    unset($object);
19
20    Fiber::suspend(3);
21
22    return 4;
23});
24
25var_dump($fiber->start());
26var_dump($fiber->resume());
27var_dump($fiber->resume());
28var_dump($fiber->resume());
29var_dump($fiber->getReturn());
30
31?>
32--EXPECT--
33int(1)
34int(2)
35int(3)
36NULL
37int(4)
38