|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2013-04-13 17:36 UTC] nikic@php.net
 
-Status:      Open
+Status:      Closed
-Assigned To:
+Assigned To: nikic
  [2013-04-13 17:36 UTC] nikic@php.net
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 11:00:01 2025 UTC | 
Description: ------------ The idea of MultipleIterator is great, however its key() method implementation is somehow invalid. Documentation of Iterator::key clearly stands, that key have to be a scalar or NULL, but MultipleIterator returns an array which leads to problems. First problem is inability to use $key => $val syntax in foreach Second problem is inability to use MultipleIterator with other iterators, e.g. with InfiniteIterator. MultipleIterator could just compute key by imploding keys from all attached iterators using user specified separator. I've tried this localy and worked perfectly. If that's the way to go, I'll be happy to help with patch. Test script: --------------- $multiIter = new MultipleIterator(); $multiIter->attachIterator(new ArrayIterator(array('a'))); $multiIter->attachIterator(new ArrayIterator(array('b'))); $infinityIter = new InfiniteIterator($multiIter); foreach(new LimitIterator($infinityIter, 0, 2) as $item) { echo $item[0] . $item[1]; } Expected result: ---------------- I expect "abab" to be printed Actual result: -------------- Warning: Illegal type returned from MultipleIterator::key() in /some/path/phptests/iterators/InfinityIterator.php on line 8 ab Warning: Illegal type returned from MultipleIterator::key() in /some/path/phptests/iterators/InfinityIterator.php on line 8 ab Warning: Illegal type returned from MultipleIterator::key() in /some/path/phptests/iterators/InfinityIterator.php on line 8