xref: /PHP-8.2/Zend/tests/gh15330-001.phpt (revision cd255007)
1--TEST--
2GH-15330 001: Do not scan generator frames more than once
3--FILE--
4<?php
5
6class It implements \IteratorAggregate
7{
8    public function getIterator(): \Generator
9    {
10        yield 'foo';
11        Fiber::suspend();
12        var_dump("not executed");
13    }
14}
15
16function f() {
17    var_dump(yield from new It());
18}
19
20$iterable = f();
21
22$fiber = new Fiber(function () use ($iterable) {
23    var_dump($iterable->current());
24    $iterable->next();
25    var_dump("not executed");
26});
27
28$ref = $fiber;
29
30$fiber->start();
31
32gc_collect_cycles();
33
34?>
35==DONE==
36--EXPECT--
37string(3) "foo"
38==DONE==
39