Rename Collection to Scope, remove dead code, simplify API#32
Merged
alganet merged 1 commit intoRespect:masterfrom Apr 4, 2026
Merged
Rename Collection to Scope, remove dead code, simplify API#32alganet merged 1 commit intoRespect:masterfrom
alganet merged 1 commit intoRespect:masterfrom
Conversation
Member
alganet
commented
Apr 4, 2026
- Rename Collection to Scope, CollectionIterator to ScopeIterator, move out of Collections sub-namespace
- Make Scope::$name non-null, remove all null-name guards
- Remove registerScope, __isset, derive (unused after simplification)
- Remove unused Stylable methods: realName, remoteFromIdentifier, isRelationProperty
- Simplify __call to a one-liner Scope factory
- Extract applyFirstMatch helper in Plural to deduplicate loops
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #32 +/- ##
============================================
+ Coverage 98.41% 98.51% +0.10%
+ Complexity 216 196 -20
============================================
Files 10 10
Lines 441 404 -37
============================================
- Hits 434 398 -36
+ Misses 7 6 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR renames the query-spec concept from Collection to Scope across the library, removes now-dead/unused API surface (both mapper and style helpers), and refactors small internals (like pluralization matching) to reduce duplication.
Changes:
- Rename
Collection/CollectionIteratortoScope/ScopeIteratorand move them out of theCollectionssub-namespace. - Simplify
AbstractMapperby removing registered-collection plumbing and making__call()a directScopefactory; makeScope::$namenon-null and drop null-name guards. - Remove unused
Stylablemethods and refactorPluralto deduplicate regex-replacement loops.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Styles/StandardTest.php | Removes assertions for deleted style APIs (realName, remoteFromIdentifier, isRelationProperty). |
| tests/Styles/PluralTest.php | Same as above for the plural style implementation. |
| tests/Styles/AbstractStyleTest.php | Updates the anonymous style stub to match the trimmed Stylable interface. |
| tests/Scopes/ScopeTest.php | Renames the test suite for Scope and removes coverage for deleted derive behavior. |
| tests/ScopeIteratorTest.php | Renames iterator tests to ScopeIterator and updates expectations accordingly. |
| tests/InMemoryMapper.php | Updates mapper test-double to accept Scope instead of Collection. |
| tests/Hydrators/PrestyledAssocTest.php | Updates hydrator tests to build trees with Scope. |
| tests/Hydrators/NestedTest.php | Updates nested hydrator tests; removes null-name child scenario now that names are required. |
| tests/AbstractMapperTest.php | Updates tests to the simplified mapper API (Scope, no registration, remove() no longer returns bool). |
| src/Styles/Stylable.php | Removes unused methods from the style contract. |
| src/Styles/Standard.php | Removes implementations of deleted Stylable methods. |
| src/Styles/Plural.php | Removes unused methods and adds applyFirstMatch() helper to deduplicate matching logic. |
| src/ScopeIterator.php | Introduces ScopeIterator and removes null-name filtering logic. |
| src/Scope.php | Introduces Scope (non-null name) and removes derive. |
| src/Hydrators/PrestyledAssoc.php | Switches to Scope/ScopeIterator for spec traversal. |
| src/Hydrators/Nested.php | Switches to Scope and removes null-name guards. |
| src/Hydrators/Base.php | Switches to Scope and removes null-name guards; retains relationship wiring behavior. |
| src/Hydrator.php | Updates hydrator interface signatures to accept Scope. |
| src/AbstractMapper.php | Replaces Collection with Scope, removes registration API, and simplifies __call(). |
| phpstan.neon.dist | Updates ignore pattern to account for Scope magic static/method calls. |
Comments suppressed due to low confidence (1)
src/ScopeIterator.php:41
ScopeIterator::key()assumes$this->current()always returns aScope. Constructing an empty iterator (new ScopeIterator()) and callingkey()(or if the iterator is otherwise invalid) will now throw when accessing->name. Please guard against an empty/invalid current element (e.g., return an empty string or fall back to the parent key) soScopeIteratorremains safe to use when empty.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Rename Collection to Scope, CollectionIterator to ScopeIterator, move out of Collections sub-namespace - Make Scope::$name non-null, remove all null-name guards - Remove registerScope, __isset, derive (unused after simplification) - Remove unused Stylable methods: realName, remoteFromIdentifier, isRelationProperty - Simplify __call to a one-liner Scope factory - Extract applyFirstMatch helper in Plural to deduplicate loops
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.