Skip to content

Fix registered collection base interface and class resolution - #579

Open
dajiaohuang wants to merge 1 commit into
cycle:2.xfrom
dajiaohuang:repostew/collection-base-types-20261015
Open

dajiaohuang wants to merge 1 commit into
cycle:2.xfrom
dajiaohuang:repostew/collection-base-types-20261015

Conversation

@dajiaohuang

Copy link
Copy Markdown
Contributor

🔍 What was changed

Match registered collection types with is_a(..., true) so both the registered base type itself and subclasses resolve to the collection factory. Preserve alias precedence, factory class customization and the fallback for explicit factory names.

🤔 Why?

Fixes #573. Using Doctrine\Common\Collections\Collection::class as the relation collection type currently attempts to autowire the interface, although DoctrineCollectionFactory::withCollectionClass() explicitly supports it. Using the registered Illuminate base class also falls through to the container and returns a collection instead of a collection factory.

📝 Checklist

  • Real relation-loading regressions for eager and lazy Doctrine interface / Illuminate base class selection.
  • All four new cases fail on the base (two interface autowiring exceptions, two return-type errors) and pass with this change.
  • Existing default, alias and custom subclass cases retained.
  • Unit suite: 383 tests / 1,211 assertions passed.
  • Combined independent collection/typecast fixes: SQLite suite 1,321 tests / 30,354 assertions, 10 upstream skips / 3 incomplete unchanged.
  • Composer validate --strict; changed-file style; git diff --check.

Local runtime: PHP 8.3.35, cycle/database 2.23.3, doctrine/collections 2.6.0, illuminate/collections 12.70.0. Other PHP versions and database drivers were not run. Psalm has 12 errors on the base, including the unrelated callable-typecast issue; no new collection-path diagnostic remains. No static-analysis suppressions were added.

📃 Documentation

This restores registered-base collection selection without changing the public API.

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.

Collection type set to the interface registered via withCollectionFactory() is autowired instead of resolved to the factory

1 participant