Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CachingIterator: do not ask when not in valid state #230

Merged
merged 21 commits into from Sep 30, 2020

Conversation

hrach
Copy link
Contributor

@hrach hrach commented Sep 6, 2020

  • bug fix: yes
  • BC break: no, but...
  • doc PR: no

The inner iterator is one iteration ahead and therefore when CachingIterator asks for the next value (key), it uses a current() method on the inner iterator. But the iteration may have finished and calling iterator's current() and key() in invalid state may produce an exception or invalid data.

PHP'S internal ArrayIterator returns a null, but generally speaking the iterators should rather throw. When doing types properly, we can't even type such interface.

This PR asks first if the inner iterator is in a valid state.

@hrach
Copy link
Contributor Author

hrach commented Sep 6, 2020

Test failures seems unrelated.

@dg dg force-pushed the master branch 4 times, most recently from 63d6779 to 31553c2 Compare Sep 29, 2020
@hrach
Copy link
Contributor Author

hrach commented Sep 29, 2020

@dg what do you think?

@dg dg force-pushed the master branch 4 times, most recently from f6d1b05 to 2a1d768 Compare Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants