Closed
Description
Symfony version(s) affected
6.2.0
Description
After upgrading to 6.2.0 I noticed that some of my service locators broke.
How to reproduce
I was adding some typed arguments of a method (in a compiler pass) to an array like this:
foreach {
// some logic
$services[$class] = new Reference(
$class
ContainerInterface::IGNORE_ON_INVALID_REFERENCE,
);
}
// Create service locator
ServiceLocatorTagPass::register($container, $services);
I was using ContainerInterface::IGNORE_ON_INVALID_REFERENCE
to automatically filter out invalid services. This used to work fine in 6.1.
But in 6.2.0 I get this error:
In CheckReferenceValidityPass.php line 37:
The definition ".service_locator.ZCXM_ST" has a reference to an abstract definition "App\Entity\SomeEntity". Abstract definitions cannot be the target of references.
Possible Solution
I think CheckReferenceValidityPass
should not report an error when the Reference
has ContainerInterface::IGNORE_ON_INVALID_REFERENCE
.
Additional Context
It's related to: