Doc #76250 [Opn]: Better Documentation Description - ArrayIterator Class

From: Date: Mon, 23 Apr 2018 03:25:49 +0000
Subject: Doc #76250 [Opn]: Better Documentation Description - ArrayIterator Class
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-15621@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76250&edit=1 ID: 76250 Updated by: requinix@php.net Reported by: bonnevillessei67 at hotmail dot com Summary: Better Documentation Description - ArrayIterator Class Status: Open Type: Documentation Problem -Package: Documentation problem +Package: SPL related Operating System: Windows PHP Version: 7.0.29 Block user comment: N Private report: N New Comment: I don't understand what the original description is trying to say, but your version sounds downright incorrect. ArrayIterator can be iterated over because it is an iterator, meaning it has implemented the necessary logic (Iterator interface) to do so. ArrayObject can be iterated over because it passes the work off (IteratorAggregate interface) to an ArrayIterator instance, and the process is entirely transparent. Both will work fine in a foreach - even multiple times in a row. https://3v4l.org/KFStB If anything that part should be removed entirely. I can't be sure but I believe it's at least 10 years old so it could very well just not be true anymore. Previous Comments: ------------------------------------------------------------------------ [2018-04-23 03:04:33] bonnevillessei67 at hotmail dot com Description: ------------ A strong suggestion to change the wording on this page. http://php.net/manual/en/class.arrayiterator.php This statement caused me to pull my hair out for three days to understand what is being said. "When you want to iterate over the same array multiple times you need to instantiate ArrayObject and let it create ArrayIterator instances that refer to it either by using foreach or by calling its getIterator() method manually." This is a much better explanation of how ArrayObject and ArrayIterator work together. "ArrayObject cannot be iterated when you use it in foreach it creates an ArrayIterator object internally" Scroll down to "Comparing ArrayObject vs ArrayIterator" in this Stackoverflow link for context. https://stackoverflow.com/questions/10502719/difference-between-arrayiterator-arrayobject-and-array-in-php ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76250&edit=1

« previous php.doc.bugs (#15621) next »