mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
* Make `ReflectionGenerator::getFunction()` legal after generator termination * Expose the generator function name via `Generator::__debugInfo()` * Allow creating `ReflectionGenerator` after termination * Reorder `struct _zend_generator` to avoid a hole * Adjust `ext/reflection/tests/028.phpt` This is legal now. * Fix Generator Closure collection * Add test to verify the Closure dies with the generator * NEWS / UPGRADING
83 lines
1.2 KiB
PHP
83 lines
1.2 KiB
PHP
--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"
|
|
}
|