mirror of
https://github.com/php/php-src.git
synced 2024-10-02 23:36:16 +00:00
268740d984
It looks like you have to implement the Iterator interface *before* assigning get_iterator. Otherwise the structure for user iterators isn't correctly zeroed out. Additionaly I'm setting class_entry->iterator_funcs.funcs now. Not sure if this is strictly necessary, but better safe than sorry ;)
38 lines
452 B
PHP
38 lines
452 B
PHP
--TEST--
|
|
Generators work properly in MultipleIterator
|
|
--FILE--
|
|
<?php
|
|
|
|
function gen1() {
|
|
yield 'a';
|
|
yield 'aa';
|
|
}
|
|
|
|
function gen2() {
|
|
yield 'b';
|
|
yield 'bb';
|
|
}
|
|
|
|
$it = new MultipleIterator;
|
|
$it->attachIterator(gen1());
|
|
$it->attachIterator(gen2());
|
|
|
|
foreach ($it as $values) {
|
|
var_dump($values);
|
|
}
|
|
|
|
?>
|
|
--EXPECT--
|
|
array(2) {
|
|
[0]=>
|
|
string(1) "a"
|
|
[1]=>
|
|
string(1) "b"
|
|
}
|
|
array(2) {
|
|
[0]=>
|
|
string(2) "aa"
|
|
[1]=>
|
|
string(2) "bb"
|
|
}
|