mirror of
https://github.com/php/php-src.git
synced 2026-03-26 01:02:25 +01:00
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
40 lines
464 B
PHP
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
|