php-src/Zend/tests/generators/generator_send.phpt
Nikita Popov c9709bfbd7 Remove asterix modifier (*) for generators
Generators are now automatically detected by the presence of a `yield`
expression in their body.

This removes the ZEND_SUSPEND_AND_RETURN_GENERATOR opcode. Instead
additional checks for ZEND_ACC_GENERATOR are added to the fcall_common
helper and zend_call_function.

This also adds a new function zend_generator_create_zval, which handles
the actual creation of the generator zval from an op array.

I feel like I should deglobalize the zend_create_execute_data_from_op_array
code a bit. It currently changes EG(current_execute_data) and
EG(opline_ptr) which is somewhat confusing (given the name).
2012-07-20 16:09:06 +02:00

23 lines
369 B
PHP

--TEST--
Values can be sent back to the generator
--FILE--
<?php
function gen() {
var_dump(yield "yield foo");
var_dump(yield "yield bar");
}
$gen = gen();
var_dump($gen->current());
$gen->send("send bar");
var_dump($gen->current());
$gen->send("send foo");
?>
--EXPECT--
string(9) "yield foo"
string(8) "send bar"
string(9) "yield bar"
string(8) "send foo"