1--TEST--
2GC can cleanup cycle when fiber result references fiber
3--FILE--
4<?php
5
6$fiber = null;
7$fiber = new Fiber(function () use (&$fiber) {
8    return new class($fiber) {
9        private $fiber;
10
11        public function __construct($fiber) {
12            $this->fiber = $fiber;
13        }
14
15        public function __destruct() {
16            var_dump('DTOR');
17        }
18    };
19});
20
21$fiber->start();
22
23var_dump('COLLECT CYCLES');
24gc_collect_cycles();
25var_dump('DONE');
26
27var_dump($fiber->isTerminated());
28
29unset($fiber);
30
31var_dump('COLLECT CYCLES');
32gc_collect_cycles();
33var_dump('DONE');
34
35?>
36--EXPECT--
37string(14) "COLLECT CYCLES"
38string(4) "DONE"
39bool(true)
40string(14) "COLLECT CYCLES"
41string(4) "DTOR"
42string(4) "DONE"
43