1--TEST--
2Fiber interaction with custom fiber implementation 4
3--EXTENSIONS--
4zend_test
5--FILE--
6<?php
7$fiber = new Fiber(function (): int {
8    $test = new _ZendTestFiber(function (): void {
9        $value = Fiber::suspend(1);
10        var_dump($value); // int(2)
11        $value = _ZendTestFiber::suspend(3);
12        var_dump($value); // int(6)
13        $value = Fiber::suspend(4);
14        var_dump($value); // int(8)
15        _ZendTestFiber::suspend(5);
16        echo "unreachable\n"; // Test fiber is not resumed.
17    });
18    $value = $test->start();
19    var_dump($value); // int(3)
20    var_dump($test->resume(2 * $value)); // int(5)
21    return -1;
22});
23$value = $fiber->start();
24var_dump($value); // int(1)
25$value = $fiber->resume(2 * $value);
26var_dump($value); // int(4)
27$value = $fiber->resume(2 * $value);
28var_dump($value); // NULL
29var_dump($fiber->getReturn()); // int(-1)
30
31?>
32--EXPECT--
33int(1)
34int(2)
35int(3)
36int(6)
37int(4)
38int(8)
39int(5)
40NULL
41int(-1)
42