note 124857 added to class.appenditerator
| From: | php at seanmorr dot is | Date: | Wed, 25 Mar 2020 22:18:40 +0000 |
| Subject: | note 124857 added to class.appenditerator | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-214379@lists.php.net to get a copy of this message | ||
joshdifabio is technically correct, but I don't see this as a bug. You can't rewind a
generator and thats what append iterator does.
If you want to use AppendIterator with Generators just wrap them with NoRewindIterator:
<?php
function foo() {
foreach ([] as $foo) {
yield $foo;
}
}
$append = new AppendIterator();
$append->append(new NoRewindIterator(foo()));
var_dump(iterator_to_array($append));
https://3v4l.org/pgiXB
----
Server IP: 45.112.84.4
Probable Submitter: 38.142.137.34 (proxied: 68.129.77.196)
----
Manual Page -- http://php.net/manual/en/class.appenditerator.php
Edit -- https://master.php.net/note/edit/124857
Del: integrated -- https://master.php.net/note/delete/124857/integrated
Del: useless -- https://master.php.net/note/delete/124857/useless
Del: bad code -- https://master.php.net/note/delete/124857/bad+code
Del: spam -- https://master.php.net/note/delete/124857/spam
Del: non-english -- https://master.php.net/note/delete/124857/non-english
Del: in docs -- https://master.php.net/note/delete/124857/in+docs
Del: other reasons-- https://master.php.net/note/delete/124857
Reject -- https://master.php.net/note/reject/124857
Search -- https://master.php.net/manage/user-notes.php