1--TEST--
2Observer: Nested fibers
3--EXTENSIONS--
4zend_test
5--INI--
6zend_test.observer.enabled=1
7zend_test.observer.show_output=1
8zend_test.observer.fiber_switch=1
9--FILE--
10<?php
11
12$fiber = new Fiber(function (): void {
13    Fiber::suspend();
14    var_dump(1);
15
16    $fiber = new Fiber(function (): void {
17        Fiber::suspend();
18        var_dump(3);
19        Fiber::suspend();
20        var_dump(5);
21    });
22
23    $fiber->start();
24
25    Fiber::suspend();
26    var_dump(2);
27
28    $fiber->resume();
29
30    Fiber::suspend();
31    var_dump(4);
32
33    $fiber->resume();
34});
35
36$fiber->start();
37$fiber->resume();
38$fiber->resume();
39$fiber->resume();
40
41?>
42--EXPECTF--
43<!-- init '%s' -->
44<!-- init Fiber::__construct() -->
45<!-- init Fiber::start() -->
46<!-- switching from fiber %s to %s -->
47<init '%s'>
48<!-- init {closure}() -->
49<!-- init Fiber::suspend() -->
50<!-- switching from fiber %s to %s -->
51<suspend '%s'>
52<!-- init Fiber::resume() -->
53<!-- switching from fiber %s to %s -->
54<resume '%s'>
55<!-- init var_dump() -->
56int(1)
57<!-- switching from fiber %s to %s -->
58<init '%s'>
59<!-- init {closure}() -->
60<!-- switching from fiber %s to %s -->
61<suspend '%s'>
62<!-- switching from fiber %s to %s -->
63<suspend '%s'>
64<!-- switching from fiber %s to %s -->
65<resume '%s'>
66int(2)
67<!-- switching from fiber %s to %s -->
68<resume '%s'>
69int(3)
70<!-- switching from fiber %s to %s -->
71<suspend '%s'>
72<!-- switching from fiber %s to %s -->
73<suspend '%s'>
74<!-- switching from fiber %s to %s -->
75<resume '%s'>
76int(4)
77<!-- switching from fiber %s to %s -->
78<resume '%s'>
79int(5)
80<!-- switching from fiber %s to %s -->
81<returned '%s'>
82<!-- switching from fiber %s to %s -->
83<returned '%s'>
84