Closed Furgas closed 1 year ago
What if you have two shared objects implementing that interface?
@kelunik Look at the end of the post:)
What do you think about adding automatic "last resort" resolving of interfaces and abstracts to shared instances?
Honestly, it makes me very sad.
Boostrapping applications shouldn't be magic. Having classes be resolved implicitly just to skip defining the alias function adds a significant amount of implicit behaviour for the small benefit of having to write a line of config.
I'm on both sides. I'd love it as an option and there's plenty of 'magic' here anyway.
I can see how being explicit with your aliases is better, like @Danack says. Would this add overhead?
This relates to #133.
I added some words in 6c06f163800693b712ae9c9bdd601d1c912356eb to explain why it was excluded.
Code in question:
Currently this code will fail with exception:
Auryn\InjectionException: Injection definition required for interface A
You must explicitly call following to get it working:
or
What do you think about adding automatic "last resort" resolving of interfaces and abstracts to shared instances? The simplest addition would be at
instantiateWithoutCtorParams
method:Probably it should throw exception when multiple shared objects can be used.