mirror of
https://github.com/php/php-src.git
synced 2025-08-18 06:58:55 +02: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
44 lines
732 B
PHP
44 lines
732 B
PHP
--TEST--
|
|
ReflectionGenerator::getFunction() 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) {
|
|
$ref = new ReflectionGenerator($gen);
|
|
|
|
echo "Before: ", $ref->getFunction()->getName(), PHP_EOL;
|
|
|
|
foreach ($gen as $dummy) {
|
|
echo "Inside: ", $ref->getFunction()->getName(), PHP_EOL;
|
|
}
|
|
|
|
echo "After: ", $ref->getFunction()->getName(), PHP_EOL;
|
|
}
|
|
|
|
?>
|
|
--EXPECTF--
|
|
Before: a
|
|
Inside: a
|
|
After: a
|
|
Before: {closure:%s:%d}
|
|
Inside: {closure:%s:%d}
|
|
After: {closure:%s:%d}
|
|
Before: foo
|
|
Inside: foo
|
|
After: foo
|