Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive PrivateService issue for doctrine ID #317

Open
ostrolucky opened this issue Jun 30, 2023 · 0 comments
Open

False positive PrivateService issue for doctrine ID #317

ostrolucky opened this issue Jun 30, 2023 · 0 comments

Comments

@ostrolucky
Copy link
Contributor

ostrolucky commented Jun 30, 2023

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant