-
Notifications
You must be signed in to change notification settings - Fork 64
False positive PrivateService issue for doctrine ID #317
Copy link
Copy link
Open
Description
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
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
psalm-plugin-symfony/src/Symfony/ContainerMeta.php
Lines 154 to 167 in 2aa5964
| try { | |
| $definition = $this->container->getDefinition($id); | |
| } catch (ServiceNotFoundException $serviceNotFoundException) { | |
| try { | |
| $alias = $this->container->getAlias($id); | |
| } catch (InvalidArgumentException $e) { | |
| throw $serviceNotFoundException; | |
| } | |
| $definition = $this->container->getDefinition((string) $alias); | |
| $definition->setPublic($alias->isPublic()); | |
| } | |
| return $definition; |
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels