在将教义/持久性从 1.0 升级到 1.3 时,我遇到了静态代码分析问题。
Repository (Doctrine\ORM\EntityRepository) does not accept
Doctrine\Persistence\ObjectRepository.
问题在于这个
<?php
declare(strict_types=1);
namespace Appbundle\Repository\Company;
class CompanyRepository
{
/**
* @var EntityManagerInterface
*/
private $entityManager;
/**
* @var EntityRepository
*/
private $entityRepository;
/**
* @var ProfileRepository
*/
private $profileRepository;
public function __construct(
EntityManagerInterface $entityManager,
) {
$this->entityManager = $entityManager;
$this->entityRepository = $entityManager->getRepository(Company::class);
}
该代码作为 getRepository reuturns EntityRepository 但 getReposiry 的返回类型是 ObjectRepository 并且不兼容。使用 1.0 版。有人知道它可能是什么吗?