ID: 49104
Updated by: [email protected]
Reported By: seva dot lapsha at gmail dot com
-Status: Open
+Status: Assigned
Bug Type: SPL related
Operating System: *
PHP Version: 5.3.0
-Assigned To:
+Assigned To: colder
Previous Comments:
------------------------------------------------------------------------
[2009-07-29 22:57:40] seva dot lapsha at gmail dot com
Line 6:
x This causes append to happen twice:
should be read as
* This causes rewind to happen twice:)
------------------------------------------------------------------------
[2009-07-29 22:54:19] seva dot lapsha at gmail dot com
Description:
------------
AppendIterator::append($iterator) calls $iterator->rewind() with no
reason.
This causes append to happen twice:
1) when $iterator appended;
2) when $iterator starts iterating.
Reproduce code:
---------------
<?php
class ArrayIterator1 extends ArrayIterator {
function rewind() {
echo ".";
parent::rewind();
}
}
$i1 = new ArrayIterator1(array(1, 2, 3));
$i2 = new ArrayIterator1(array(4, 5, 6));
$i = new AppendIterator();
$i->append($i1);
$i->append($i2);
foreach ($i as $n) {
echo $n;
}
?>
Expected result:
----------------
.123.456
rewind() of each append()ed iterator should be called on demand when
iterating and not when append()ing.
Actual result:
--------------
..123.456
On each append() each append()ed iterator's rewind is called with no
need.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49104&edit=1