Closed mnapoli closed 8 years ago
FYI:
Definition
instance (so we can get the requested name): https://github.com/PHP-DI/PHP-DI/pull/334For me the second option is far more flexible. First option would force you to write factories for every service you write a definition for, while second option would technically allow you to to write factory definitions for classes that weren't made with definition-interop
in mind.
Completely agree with Maxime. 2nd option is the way to go.
This also highlights the interest of having a set of abstract unit tests that can be used by any container to test if it is definition-interop compliant. I might take a look at this topic next week if I find some time.
That means though that we cannot use abstract factories, i.e. use one factory to create several services. But I agree with you that the second option is much more important than the first one, especially if the goal is to provide a simple implementation (not covering all use cases).
Then I guess we can close this one and only mnapoli/assembly#7 needs fixing.
At some point, we said that factories should take the requested ID as the only argument.
Then later we forgot about that (it wasn't enforced or documented in the interfaces) and we allowed factories to take arguments (just like any method call).
Which one should we support? We need to fix that, see also https://github.com/mnapoli/assembly/issues/7