Closed
Description
Symfony version(s) affected: 4.4 and 5.0
Description
If a service that is an interface created through a factory is only implemented once and its implementation also has no constructor arguments then the factory method doesn't get called when the service is injected.
How to reproduce
- Minimal code example is available here https://github.com/alecwcp/symfony-di-bug
- As the README.md says, if you make a second class implenting the interface the problem goes away (even if the second class is unused). The problem also goes away if you add constructor arguments to the implementing class (you then need to exclude that file in the services.yaml - when testing this the arguments weren't autowired for the implementing class).
Additional context
- Seems related to Singly implemented interfaces are not being registered since v4.4 through DirectoryLoader #34524 and DependencyInjection not passing service via interface #34361 potentially (based on descriptions in those bugs).
- Confirmed to not be an issue in 4.3.8.