There is a method call expression:
$session->setUser($this->em->getReference(UserAccount::class, $ownerId));
where setUser
is declared as
public function setUser(UserAccount $user): self
$this->em->getReference
being a Doctrines's entity manager method returns object|null
.
So PhpStorm marks this call as mismatching argument-parameter types.
I surely can split it into 2 statements and type it:
/** @var UserAccount $userAccount */
$userAccount = $this->em->getReference(UserAccount::class, $ownerId);
$session->setUser($userAccount);
But may be there is a way to do that inline?
I'm pretty sure it's possible with what they call PHPStorm advanced metadata. As far as I understand you want something like this (you may need to experiment)
override(\Doctrine\ORM\EntityManagerInterface::getReference(0), map([
'' => '@'
]))