auraphp / Aura.Di

Dependency Injection System
MIT License
349 stars 63 forks source link

Fixes #116 closes #117 PR. #119

Closed harikt closed 8 years ago

harikt commented 8 years ago

If autowiring is enabled try to register the service when it is not available in current container or in delegate container.

glen-84 commented 8 years ago

I don't know if this is the right solution. It looks like it will swallow all exceptions during auto-resolution, which is not ideal.

I think that it should only handle cases where the class is not instantiable. After that, any dependency resolution should throw exceptions as usual.

I believe that this is how PHP-DI handles it (see here).

My current thinking is:

  1. has should return true if the service is defined OR (auto-resolution is enabled AND the class is instantiable).
  2. get should look for a defined service first, otherwise it should use newInstance to create the service if auto-resolution is enabled.

This would solve #112 as well.

Edit: See also https://github.com/container-interop/container-interop/pull/65#issuecomment-185217599

pmjones commented 8 years ago

@harikt Given other conversations on this subject, I'm closing this PR as "not needed just yet". We can reopen it if Glen decides it's really necessary after all.

harikt commented 8 years ago

sure :) .​