Implement getIterator() method in GetIterator trait / Issue #105#109
Open
atournayre wants to merge 2 commits intomainfrom
Open
Implement getIterator() method in GetIterator trait / Issue #105#109atournayre wants to merge 2 commits intomainfrom
atournayre wants to merge 2 commits intomainfrom
Conversation
Issue #105: GetIterator trait was not implemented and threw RuntimeException. Implementation: - Implement getIterator(): \Traversable delegating to $this->collection - Return type \Traversable<array-key, mixed> - Remove RuntimeException placeholder - Clean unused imports Tests added: - testGetIteratorReturnsTraversable - testGetIteratorAllowsForeach - testGetIteratorWithEmptyCollection - testGetIteratorPreservesKeys - testGetIteratorWithNestedArrays Fixes #105
Owner
Author
🔍 Automated Code Review✅ Positive pointsImplementation:
Tests:
Code quality:
📝 Suggestions (non-blocking)Testing:
Documentation:
✅ ValidationCode ready to merge. Solves RuntimeException issue. Collections now properly iterable in foreach loops. |
CI tests were failing because manual foreach loops weren't correctly capturing iterator values. Use iterator_to_array() for reliable iteration testing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the
getIterator()method in GetIterator trait to enable collections to be iterable in foreach loops, fixing issue #105.Changes
Implementation:
getIterator(): \Traversabledelegating to$this->collection->getIterator()\Traversable<array-key, mixed>Tests added:
testGetIteratorReturnsTraversable- Verifies return typetestGetIteratorAllowsForeach- Tests foreach iterationtestGetIteratorWithEmptyCollection- Empty collection handlingtestGetIteratorPreservesKeys- Key preservation validationtestGetIteratorWithNestedArrays- Nested arrays supportFiles:
src/Primitives/Traits/Collection/GetIterator.php(modified)tests/Unit/Primitives/Traits/Collection/GetIteratorTest.php(new)Testing
Checklist
Fixes #105