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