1
0
mirror of https://github.com/php/php-src.git synced 2026-03-26 01:02:25 +01:00
Files
archived-php-src/Zend/tests/generators/nested_method_calls.phpt
Nikita Popov a31fa55b44 Fixed bug #63132
EG(arg_types_stack) is now also backed up when generators are used. This
allows the use of yield in nested method calls.

This commit adds two new functions to the zend_ptr_stack API:

    zend_ptr_stack_push_from_memory
    zend_ptr_stack_pop_into_memory

both taking the following arguments:

    zend_ptr_stack *stack, int count, void **pointers
2012-09-22 19:15:53 +02:00

40 lines
464 B
PHP

--TEST--
Yield can be used in nested method calls
--FILE--
<?php
class A {
function foo() {
echo "Called A::foo\n";
}
}
class B {
function foo() {
echo "Called B::foo\n";
}
}
function gen($obj) {
$obj->foo($obj->foo(yield));
}
$g1 = gen(new A);
$g1->current();
$g2 = gen(new B);
$g2->current();
$g1->next();
$g3 = clone $g2;
unset($g2);
$g3->next();
?>
--EXPECT--
Called A::foo
Called A::foo
Called B::foo
Called B::foo