Clarify that Iterator->rewind() must be called before a foreach
Nobody has claimed this yet.
- Dominant language
- XML
- Stars
- 596
- Forks
- 890
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 55
Description
From manual page: https://php.net/iterator.rewind
Many comments in the manual state that foreach calls the rewind method before iterating. But it always seems as if this is something that foreach just does, maybe for safety. But that's a misunderstanding. In a final comment in https://bugs.php.net/bug.php?id=63823, levim says very clearly that calling rewind before using an iterator is mandatory and trying to get values from an unrewound iterator is undefined behaviour. I can't find this clear statement in the manual. At least, it should be found in articles about the current() and next() methods (which could be many). This would have saved me some hours today...
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Iterator::rewind() manual page and review the related current() and next() documentation mentioned in the issue. Clarify that rewind() must be called before reading an iterator and document the consequence of using an unrewound iterator, then verify the wording and documentation links in the PHP manual build.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100