mirror of
https://github.com/php/php-src.git
synced 2024-12-19 15:00:15 +08:00
c0c73f7083
This should cover all the basic cycles. Anything further would require scanning the call stack and live temporaries.
45 lines
594 B
PHP
45 lines
594 B
PHP
--TEST--
|
|
Generator cycle collection edge cases
|
|
--FILE--
|
|
<?php
|
|
|
|
// Extra args
|
|
function gen1() {
|
|
yield;
|
|
}
|
|
$obj = new stdClass;
|
|
$obj->gen = gen1($obj);
|
|
|
|
// Symtable
|
|
function gen2() {
|
|
$varName = 'a';
|
|
$$varName = yield;
|
|
yield;
|
|
}
|
|
$gen = gen2();
|
|
$gen->send($gen);
|
|
|
|
// Symtable indirect
|
|
function gen3() {
|
|
$varName = 'a';
|
|
$$varName = 42;
|
|
$var = yield;
|
|
yield;
|
|
}
|
|
$gen = gen3();
|
|
$gen->send($gen);
|
|
|
|
// Yield from root
|
|
function gen4() {
|
|
yield from yield;
|
|
}
|
|
$gen = gen4();
|
|
$gen2 = gen4($gen);
|
|
$gen2->send([1, 2, 3]);
|
|
$gen->send($gen2);
|
|
|
|
?>
|
|
===DONE===
|
|
--EXPECT--
|
|
===DONE===
|