1
0
mirror of https://github.com/php/php-src.git synced 2026-04-27 18:23:26 +02:00
Files
archived-php-src/ext/reflection/tests/ReflectionGenerator_isClosed.phpt
T
Tim Düsterhus 8a87206211 reflection: Add ReflectionGenerator::isClosed() (#14358)
* reflection: Add `ReflectionGenerator::isClosed()`

see https://github.com/php/php-src/pull/14167#issuecomment-2133641998

* Fix test expectation

* Drop `{{{` / `}}}` comments around `ReflectionGenerator::isClosed()`
2024-05-29 19:07:09 +02:00

47 lines
774 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;
}
?>
--EXPECTF--
int(10)
bool(false)
int(10)
bool(true)
Cannot fetch information from a closed Generator
int(4)
bool(false)
int(4)
bool(true)
Cannot fetch information from a closed Generator