Skip to content

Add lazy collection creation from closure and enhance collection methods.#42

Merged
gustavofreze merged 15 commits intomainfrom
feature/develop
Apr 15, 2026
Merged

Add lazy collection creation from closure and enhance collection methods.#42
gustavofreze merged 15 commits intomainfrom
feature/develop

Conversation

@gustavofreze
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings April 15, 2026 18:14
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds support for creating lazy collections from a closure (enabling safe re-iteration) and adjusts pipeline/collection behavior accordingly, with expanded test coverage and repo metadata updates.

Changes:

  • Introduces Collection::createLazyFromClosure() backed by LazyPipeline::fromClosure() for re-iterable lazy sources.
  • Refactors EagerPipeline to memoize materialization and allow repeated iteration when created from single-use iterables (e.g., generators).
  • Updates each() to be a terminal operation returning void, and updates tests + adds new tests for closure/generator reiteration.

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
src/Collection.php Adds createLazyFromClosure() and changes each() to return void.
src/Collectible.php Extends public interface with createLazyFromClosure() and updates each() contract.
src/Internal/LazyPipeline.php Supports closure-based sources by invoking factory per iteration.
src/Internal/EagerPipeline.php Switches to staged processing with memoized materialization for reiteration.
src/Internal/Operations/Transforming/Rearrange.php Minor formatting adjustment in match arm.
tests/LazyCollectionTest.php Updates each() tests and adds closure-backed lazy collection tests.
tests/EagerCollectionTest.php Adds generator reiteration test and updates each() usage.
tests/CollectionTest.php Adds parity tests comparing closure/lazy/eager behavior and type preservation.
.gitattributes Adds LF normalization, diff drivers, and updates export-ignore rules.
.claude/* Adds documented rules for testing, code style, workflows, and documentation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Collection.php
Comment thread src/Internal/LazyPipeline.php
Comment thread src/Internal/LazyPipeline.php
Comment thread src/Internal/LazyPipeline.php
Comment thread src/Internal/EagerPipeline.php Outdated
Comment thread tests/CollectionTest.php
Comment thread tests/CollectionTest.php
Comment thread .gitattributes
Comment thread .gitattributes
Comment thread .claude/CLAUDE.md
@gustavofreze gustavofreze merged commit 12a3972 into main Apr 15, 2026
5 checks passed
@gustavofreze gustavofreze deleted the feature/develop branch April 15, 2026 19:46
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.

2 participants