Closed
Description
Symfony version(s) affected: 4.0.14 and above
Description
Imagine there are two services A and B in the container. The A service depends on non-existent service X, the B service depends on A. If the A is declared as public=false, then container compilation reports, that service B has requested non-existent service X. If the A service is public=true, the report message will be correct.
How to reproduce
Try to compile container with such definition:
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="AppBundle\Service\Child" public="false">
<argument type="service" id="serializer" /> <!-- Missed service -->
</service>
<service id="AppBundle\Service\ParentA" public="true">
<argument type="service" id="AppBundle\Service\Child" />
</service>
</services>
</container>
Reproducing application: https://github.com/edefimov/symfony-reproduce/tree/eea1edabc1ab944603cf773d570e51ed0357f37d/
Additional context
The output when service AppBundle\Service\Child is public=false
In CheckExceptionOnInvalidReferenceBehaviorPass.php line 31:
The service "AppBundle\Service\ParentA" has a dependency on a non-existent service "serializer".
Correct output when service AppBundle\Service\Child is public=true
In CheckExceptionOnInvalidReferenceBehaviorPass.php line 31:
The service "AppBundle\Service\Child" has a dependency on a non-existent service "serializer".