phpstan-symfony icon indicating copy to clipboard operation
phpstan-symfony copied to clipboard

False positive with Symfony\Component\DependencyInjection\ContainerBuilder::has

Open emodric opened this issue 5 years ago • 1 comments

I have around 10 compiler passes in my code base.

I have NOT configured the path to container XML as I am not interested in testing for existing/non-existing services.

However, somehow, one and only one of my compiler passes fails with the message:

Call to method Symfony\Component\DependencyInjection\ContainerBuilder::has()
with 'fos_http_cache.cache_manager' will always evaluate to false.

The code in question is fairly standard:

if (!$container->has('fos_http_cache.cache_manager')) {
    return;
}

Every other compiler pass uses the same pattern and does not fail.

Why?

Thanks!

emodric avatar Apr 24 '20 19:04 emodric

Same here:

Call to method Symfony\Component\DependencyInjection\ContainerBuilder::has() with 'sonata.doctrine…' will always evaluate to false.

MaxE17677 avatar Dec 04 '20 13:12 MaxE17677