Uh oh!
There was an error while loading. Please reload this page.
Iterator::rewind: link to reset() function vs rewind() function - #5764
Conversation
lacatoire
left a comment
There was a problem hiding this comment.
The change replaces rewind with reset, but these are different things: reset() is a built-in function that rewinds plain arrays, while Iterator::rewind() is the method foreach actually calls on objects implementing Iterator.
You can follow the call chain in the engine: foreach triggers zend_fe_reset_iterator(), which calls iter->funcs->rewind(iter), wired to zend_user_it_rewind() — which dispatches to the PHP-level rewind method (resolved by name here, called here).
So the original wording was correct. Happy to be wrong if I'm missing something!
Well then maybe For that matter, maybe it could even say But, as is, it's hyperlinking to a function that affects file pointers. |
| </para> | ||
| <simpara> | ||
| As &foreach; always calls <methodname>rewind</methodname> before starting | ||
| As &foreach; always calls <methodname>reset</methodname> before starting |
There was a problem hiding this comment.
| As &foreach; always calls <methodname>reset</methodname> before starting | |
| As &foreach; always calls <methodname>Iterator::rewind</methodname> before starting |
There was a problem hiding this comment.
You're proposing the page link to itself? Is there precedent for that on php.net? In general I think that that's kinda silly. Like making every instance of "World War "2 on the "World War 2" wikipedia article link to itself... I'm not sure that's a very useful change.
I feel like As &foreach; always calls this method before starting would be better.
There was a problem hiding this comment.
@terrafrost I agree with your suggestion. Using this method makes more sense.
jordikroon
commented
Aug 19, 2026
Thank you @terrafrost! |
Uh oh!
There was an error while loading. Please reload this page.
No description provided.