Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generics for repositories and repository interfaces #1971

Open
dkarlovi opened this issue Apr 22, 2022 · 1 comment
Open

Generics for repositories and repository interfaces #1971

dkarlovi opened this issue Apr 22, 2022 · 1 comment

Comments

@dkarlovi
Copy link
Contributor

dkarlovi commented Apr 22, 2022

Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? yes

Doctrine's \Doctrine\Persistence\ObjectRepository supports generics. Since CS interfaces extend it, it would make sense to denote they're generic too.

For example, it would mean adding

/**
 * @template T
 *
 * @extends ObjectRepository<T>
 */
interface CoreShop\Component\Resource\Repository\RepositoryInterface extends ObjectRepository

and then

/** 
 * @template T of PaymentProviderInterface
 *
 * @extends RepositoryInterface<T>
 */
interface PaymentProviderRepositoryInterface extends RepositoryInterface

This would also make many of the types inferred by default by Psalm / PHPStan and many PHPDoc blocks could be removed.

@dkarlovi
Copy link
Contributor Author

Additional example: https://psalm.dev/r/11594ec601

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants