1--TEST--
2Fibers in destructors 009: Destructor resurrects object, suspends
3--FILE--
4<?php
5
6register_shutdown_function(function () {
7    printf("Shutdown\n");
8});
9
10class Cycle {
11    public $self;
12    public function __construct() {
13        $this->self = $this;
14    }
15    public function __destruct() {
16        global $ref, $f2;
17        $ref = $this;
18        $f2 = Fiber::getCurrent();
19        Fiber::suspend();
20    }
21}
22
23$f = new Fiber(function () {
24    global $weakRef;
25    $weakRef = WeakReference::create(new Cycle());
26    gc_collect_cycles();
27});
28
29$f->start();
30var_dump((bool) $weakRef->get());
31gc_collect_cycles();
32$f2->resume();
33gc_collect_cycles();
34var_dump((bool) $weakRef->get());
35?>
36--EXPECT--
37bool(true)
38bool(true)
39Shutdown
40