1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/ext/reflection/tests/ReflectionGenerator_after_termination.phpt
Tim Düsterhus 8094bd1b58 Make ReflectionGenerator::getFunction() legal after generator termination (#14167)
* 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
2024-05-21 08:54:51 +02:00

34 lines
465 B
PHP

--TEST--
Creating ReflectionGenerator is legal after termination.
--FILE--
<?php
function foo() {
yield;
}
$gens = [
(new class() {
function a() {
yield from foo();
}
})->a(),
(function() {
yield;
})(),
foo(),
];
foreach ($gens as $gen) {
foreach ($gen as $dummy);
$ref = new ReflectionGenerator($gen);
echo $ref->getFunction()->getName(), PHP_EOL;
}
?>
--EXPECTF--
a
{closure:%s:%d}
foo