Skip to content

Rename Collection to Scope, remove dead code, simplify API#32

Merged
alganet merged 1 commit intoRespect:masterfrom
alganet:scope
Apr 4, 2026
Merged

Rename Collection to Scope, remove dead code, simplify API#32
alganet merged 1 commit intoRespect:masterfrom
alganet:scope

Conversation

@alganet
Copy link
Copy Markdown
Member

@alganet 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-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 4, 2026

Codecov Report

❌ Patch coverage is 98.59155% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 98.51%. Comparing base (0b1c694) to head (59f826a).

Files with missing lines Patch % Lines
src/Hydrators/Base.php 87.50% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

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/CollectionIterator to Scope/ScopeIterator and move them out of the Collections sub-namespace.
  • Simplify AbstractMapper by removing registered-collection plumbing and making __call() a direct Scope factory; make Scope::$name non-null and drop null-name guards.
  • Remove unused Stylable methods and refactor Plural to 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 a Scope. Constructing an empty iterator (new ScopeIterator()) and calling key() (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) so ScopeIterator remains 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
@alganet alganet marked this pull request as ready for review April 4, 2026 03:04
@alganet alganet merged commit 6512ccc into Respect:master Apr 4, 2026
3 checks passed
@alganet alganet deleted the scope branch April 4, 2026 03:05
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.

3 participants