I get the following error when i try to use this in my controller
Return value of App\Repository\AccountRepository::findOneByAccountCode() must be an instance of App\Repository\Bank or null, instance of App\Entity\Account returned
/**
* @param Request $request
* @param string $accountCode
* @return Response
* @throws EntityNotFoundException
*/
public function somefunction(Request $request, string $accountCode)
{
/** @var BankRepository $acRepository */
$acRepository = $this->getDoctrine()->getRepository(Account::class);
$bank = $acRepository->findOneByAccountCode($accountCode);
}
Repository Code
public function findOneByAccountCode(string $accountCode): ?Bank
{
try {
return $this->createQueryBuilder('a')
->innerJoin('a.bank', 'b')
->where('a.code = :code')
->setParameter('code', $accountCode)
->getQuery()
->getOneOrNullResult();
}catch (NonUniqueResultException $e) {
return null;
}
}
just changed the code to my AccountRepository and added array as a return type