When upgrading doctrine/persistence from 1.0 to 1.3 I encountered a problem with static code analysis.
Repository (Doctrine\ORM\EntityRepository) does not accept
Doctrine\Persistence\ObjectRepository.
The problem is with this
<?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);
}
The code works as getRepository reuturns EntityRepository but return type of getReposiry is ObjectRepository and is not compatible. Worked with version 1.0. Anyone got idea what it might be?
Ok so i found out it is due to Doctrine changing namespaces. It is a reported bug.
https://github.com/doctrine/orm/pull/7997 https://github.com/doctrine/orm/pull/7953