Repository navigation
Let applications extend Repository into typed repositories - #5
Merged
Merged
Conversation
Repository is no longer final. An application can extend it with a readonly class that fixes the mapping in its own constructor, so a container injects each table's repository by type and static analysis reads the model from @extends Repository<Model>. Every public method except the constructor is final: a subclass adds methods of its own and cannot change the inherited reads and writes.
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.
Makes
Repositoryextensible beforev1.0.0-RC4. The dilio backend moved all 140 of its tables to the package and wanted one injectable type per table instead of a container id per mapping.Changes
Repositoryis a non-finalreadonly class. An application can extend it with areadonlyclass that fixes the mapping in its own constructor, so a container injects each table's repository by type and PHPStan reads the model of every read from@extends Repository<Model>.final: a subclass adds methods of its own and cannot change the inherited reads and writes.docs/guide/api.md; the migration guide and the details page offer extending next to owning an instance; changelog section "Changes since 1.0.0-RC3".Behavior changes for RC3 users
None. Code that constructs
Repositorydirectly keeps working unchanged.Verification
composer validate --strict; the examples run.RepositorySubclassTest: a subclass fixes its mapping and adds a method; the class is readonly and non-final, and every public method but the constructor is final.tests/Types/PublicApiTypes.phpchecks that reads through a typed subclass keep its model.Repositoryin place of RC3: 140 typed table repositories over three abstract per-database bases, injected by type; Unit 919 and Feature 1704 pass, and its PHPStan and PHPCS findings are unchanged.🤖 Generated with Claude Code