Open ostrolucky opened 1 year ago
In my case, plugin incorrectly claims doctrine service is private. After inspection, what I found is that plugin in my case analyzes these calls first
doctrine
self::getContainer()->get(\Doctrine\Persistence\ManagerRegistry::class);
But because \Doctrine\Persistence\ManagerRegistry is not a service but there is an alias pointing to it, it finds that doctrine is aliased to it, retrieves doctrine definition and mutates its public flag to whatever is set on alias. This is because of https://github.com/psalm/psalm-plugin-symfony/blob/2aa596491c1ade315cb9ac14a29788e7466c8444/src/Symfony/ContainerMeta.php#L154-L167
\Doctrine\Persistence\ManagerRegistry
public
In another words, in example such as
<service id="doctrine" class="Doctrine\Bundle\DoctrineBundle\Registry" public="true" /> <service id="Doctrine\Persistence\ManagerRegistry" alias="doctrine"/>
plugin will flip public of doctrine into false whenever Doctrine\Persistence\ManagerRegistry is fetched
Doctrine\Persistence\ManagerRegistry
In my case, plugin incorrectly claims
doctrine
service is private. After inspection, what I found is that plugin in my case analyzes these calls firstBut because
\Doctrine\Persistence\ManagerRegistry
is not a service but there is an alias pointing to it, it finds thatdoctrine
is aliased to it, retrievesdoctrine
definition and mutates itspublic
flag to whatever is set on alias. This is because of https://github.com/psalm/psalm-plugin-symfony/blob/2aa596491c1ade315cb9ac14a29788e7466c8444/src/Symfony/ContainerMeta.php#L154-L167In another words, in example such as
plugin will flip
public
ofdoctrine
into false wheneverDoctrine\Persistence\ManagerRegistry
is fetched