Closed deleugpn closed 7 years ago
Hey @deleugpn ,
This is clearly an implementation detail.
If your container does auto-wiring (like Laravel or PHP-DI), then it makes sense to instantiate the class. If your container doesn't support auto-wiring, then it is fine to throw an exception. Different containers have different set of features and it's perfectly ok to have a different behavior based on the container you choose to use.
According to the PSR,
get
willGiven a call to the container
$container->get(Foo::class);
and the fact thatSome\Package\Foo
is instantiable (it's a concrete class), should the container resolve it or throw NotFoundException? Of course, the scenario to be discussed is only of interest in caseFoo::class
has not been registered in the container before (it's unknown to the container), otherwise the question would be stupid.