xref: /php-src/Zend/tests/gh9916-011.phpt (revision 1173c2e6)
1--TEST--
2Bug GH-9916 011 (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    print "Before yield\n";
8    $from = (function () {
9        $x = new stdClass;
10        print "Before yield 2\n";
11        yield;
12        print "Before suspend\n";
13        Fiber::suspend();
14        print "Not executed\n";
15        yield;
16    })();
17    try {
18        yield from $from;
19    } finally {
20        $from->next();
21    }
22})();
23
24$fiber = new Fiber(function () use ($gen, &$fiber) {
25    print "Before current\n";
26    $gen->current();
27    print "Before next\n";
28    $gen->next();
29    print "Not executed\n";
30});
31
32$fiber->start();
33?>
34==DONE==
35--EXPECT--
36Before current
37Before yield
38Before yield 2
39Before next
40Before suspend
41==DONE==
42