xref: /PHP-8.2/Zend/tests/gh9916-003.phpt (revision 1173c2e6)
1--TEST--
2Bug GH-9916 003 (Entering shutdown sequence with a fiber suspended in a Generator emits an unavoidable fatal error or crashes)
3--FILE--
4<?php
5$gen = (function() {
6    $x = new stdClass;
7    try {
8        yield from (function () {
9            $x = new stdClass;
10            try {
11                print "Before suspend\n";
12                Fiber::suspend();
13                print "Not executed\n";
14                yield;
15            } finally {
16                print "Finally (inner)\n";
17            }
18        })();
19        print "Not executed\n";
20        yield;
21    } finally {
22        print "Finally\n";
23    }
24})();
25$fiber = new Fiber(function() use ($gen, &$fiber) {
26    $gen->current();
27    print "Not executed";
28});
29$fiber->start();
30?>
31==DONE==
32--EXPECT--
33Before suspend
34==DONE==
35Finally (inner)
36Finally
37