rectorphp/rector-doctrine

Add @extends ServiceEntityRepository<TEntityClass>

Opened this issue · 2 comments

PHPStan doesn't support Repositories as a service: phpstan/phpstan-doctrine#178, phpstan/phpstan-doctrine#67 (comment)

Would be great if we can use Rector to add this annotation:

+ /** @extends ServiceEntityRepository<Document>  */
final class DocumentRepository extends ServiceEntityRepository
{
    public function __construct(ManagerRegistry $registry)
    {
        parent::__construct($registry, Document::class);
    }
}

Sounds good 👍

Could you add rule to a code quality set here?

With some help of ChatGPT I already have this: https://gist.github.com/stephanvierkant/a341c1c336b01022661e16a7e8a2a2fd

It worked for me, but I'll try to create a PR here.