I'm implementing PHPStan into my application and also testing Psalm for automatic fixes, however I'm unable to make them read entity class strings (with colon) fe:
$repository = $this->em->getRepository('MyApp:EntityClass');
turns into Psalm error:
ERROR: UndefinedClass - src/Controller/MyController.php:229:48 - Class, interface or enum named MyApp:EntityClass does not exist (see https://psalm.dev/019)
and in PHP Stan
Line src/Controller/MyController.php
------ ---------------------------------------------------------------------------------------------------------------------------------------------------
229 Parameter #1 $className of method Doctrine\ORM\EntityManagerInterface::getRepository() expects class-string<MyApp:EntityClass>, string given.
------ ---------------------------------------------------------------------------------------------------------------------------------------------------
Easiest way to fix this is to use \EntityClass::class instead of a string 'MyApp:EntityClass' however I would like to avoid that. Probable I need to use some annotation to make both tools interprete string correctly, but I have problems figuring out which one. It would also be nice to have it avaialble globaly via entire app, and don't use annotation each time I call a class via string. Currently I've just added this error to ignored ones but would like to know how to fix that.