Files
php-src/ext/reflection/tests/ReflectionGenerator_isClosed.phpt
Arnaud Le Blanc c02c1d4474 Change YIELD/YIELD_FROM to do not increment opline (#15328)
YIELD and YIELD_FROM increment opline before returning, but in most places
we need the opline to point to the YIELD and YIELD_FROM.

Here I change YIELD / YIELD_FROM to not increment opline. This simplifies the
code and fixes GH-15275 in a better way.

Closes GH-15328
2024-08-10 16:09:47 +02:00

47 lines
771 B
PHP

--TEST--
ReflectionGenerator::isClosed
--FILE--
<?php
function empty_generator() {
return;
yield;
}
$gens = [
(function() {
yield;
})(),
empty_generator(),
];
foreach ($gens as $gen) {
$ref = new ReflectionGenerator($gen);
var_dump($ref->getExecutingLine());
var_dump($ref->isClosed());
var_dump($ref->getExecutingLine());
foreach ($gen as $dummy);
var_dump($ref->isClosed());
try {
var_dump($ref->getExecutingLine());
} catch (\Exception $e) {
echo $e->getMessage(), PHP_EOL;
}
echo PHP_EOL;
}
?>
--EXPECT--
int(9)
bool(false)
int(9)
bool(true)
Cannot fetch information from a closed Generator
int(3)
bool(false)
int(3)
bool(true)
Cannot fetch information from a closed Generator