1--TEST--
2Generators expose the underlying function name in __debugInfo().
3--FILE--
4<?php
5
6function foo() {
7    yield;
8}
9
10$gens = [
11    (new class() {
12        function a() {
13            yield from foo();
14        }
15    })->a(),
16    (function() {
17        yield;
18    })(),
19    foo(),
20];
21
22foreach ($gens as $gen) {
23    echo "Before:", PHP_EOL;
24    var_dump($gen);
25
26    foreach ($gen as $dummy) {
27        echo "Inside:", PHP_EOL;
28        var_dump($gen);
29    }
30
31    echo "After:", PHP_EOL;
32
33    var_dump($gen);
34}
35
36?>
37--EXPECTF--
38Before:
39object(Generator)#%d (1) {
40  ["function"]=>
41  string(%d) "class@anonymous%s::a"
42}
43Inside:
44object(Generator)#%d (1) {
45  ["function"]=>
46  string(%d) "class@anonymous%s::a"
47}
48After:
49object(Generator)#%d (1) {
50  ["function"]=>
51  string(%d) "class@anonymous%s::a"
52}
53Before:
54object(Generator)#%d (1) {
55  ["function"]=>
56  string(%d) "{closure:%s:%d}"
57}
58Inside:
59object(Generator)#%d (1) {
60  ["function"]=>
61  string(%d) "{closure:%s:%d}"
62}
63After:
64object(Generator)#%d (1) {
65  ["function"]=>
66  string(%d) "{closure:%s:%d}"
67}
68Before:
69object(Generator)#%d (1) {
70  ["function"]=>
71  string(3) "foo"
72}
73Inside:
74object(Generator)#%d (1) {
75  ["function"]=>
76  string(3) "foo"
77}
78After:
79object(Generator)#%d (1) {
80  ["function"]=>
81  string(3) "foo"
82}
83