note 116690 added to class.iteratoriterator

From: Date: Thu, 12 Feb 2015 12:07:09 +0000
Subject: note 116690 added to class.iteratoriterator
Groups: php.notes 
Request: Send a blank email to php-notes+get-201701@lists.php.net to get a copy of this message
Please note that if you are using IteratorIterator with a SplQueue then the valid() method of the iterator will retun false even if there are elements to be iterated in the queue. Example: <?php $q = new SplQueue(); $q->enqueue('something'); $it = new IteratorIterator($q); print (int) $it->valid(); //outputs 0 // but if you call rewind() first then check for valid() it works: $it->rewind(); print (int) $it->valid(); //outputs 1 ?> I don't know if this behavior is intended, but this is what I get on PHP 5.5.9-1ubuntu4.5 ---- Server IP: 72.52.91.14 Probable Submitter: 91.195.44.252 ---- Manual Page -- http://php.net/manual/en/class.iteratoriterator.php Edit -- https://master.php.net/note/edit/116690 Del: integrated -- https://master.php.net/note/delete/116690/integrated Del: useless -- https://master.php.net/note/delete/116690/useless Del: bad code -- https://master.php.net/note/delete/116690/bad+code Del: spam -- https://master.php.net/note/delete/116690/spam Del: non-english -- https://master.php.net/note/delete/116690/non-english Del: in docs -- https://master.php.net/note/delete/116690/in+docs Del: other reasons-- https://master.php.net/note/delete/116690 Reject -- https://master.php.net/note/reject/116690 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#201701) next »