Open jtojnar opened 1 year ago
You actually don't need to setShared
, by doing that, you're telling the container that Authentication::class
has a definition in the container, so no autowiring is attempted. However, you have the reflection container set to cache resolutions, so anything resolved through it will, in effect, be shared anyway.
I tried using
ReflectionDelegate
to achieve auto-wiring and it works mostly great. The issue occurs when I register some services as shared – then they won’t be autowired any more.See the following simplified example:
I could
addArguments
the dependencies explicitly but doing it for all of the shared services would be annoying.