php-src/Zend/tests/generators/generator_in_multipleiterator.phpt
Nikita Popov 268740d984 Fix implementation of Iterator interface
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 ;)
2012-07-26 17:13:25 +02:00

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"
}