xref: /PHP-8.3/Zend/tests/gh15330-004.phpt (revision cd255007)
1--TEST--
2GH-15330 004: Do not scan generator frames more than once
3--FILE--
4<?php
5
6class Canary {
7    public function __construct(public mixed $value) {}
8    public function __destruct() {
9        var_dump(__METHOD__);
10    }
11}
12
13function g() {
14    yield 'foo';
15    Fiber::suspend();
16}
17
18function f($canary) {
19    var_dump(yield from g());
20}
21
22$canary = new Canary(null);
23
24$iterable = f($canary);
25
26$fiber = new Fiber(function () use ($iterable, $canary) {
27    var_dump($canary, $iterable->current());
28    $iterable->next();
29    var_dump("not executed");
30});
31
32$canary->value = $fiber;
33
34$fiber->start();
35
36$iterable->current();
37
38$fiber = $iterable = $canary = null;
39
40gc_collect_cycles();
41
42?>
43==DONE==
44--EXPECTF--
45object(Canary)#%d (1) {
46  ["value"]=>
47  object(Fiber)#%d (0) {
48  }
49}
50string(3) "foo"
51string(18) "Canary::__destruct"
52==DONE==
53