Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 ;)
- Loading branch information
Showing
2 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters