CoreShop
CoreShop copied to clipboard
Generics for repositories and repository interfaces
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.
Additional example: https://psalm.dev/r/11594ec601