4 ms·
If by "kinds" you mean abstract classes, yeah. I just checked, there's no special handling for those since requesting them from the container makes no sense. I
by pdenton 5y ago
If by "kinds" you mean abstract classes, yeah. I just checked, there's no special handling for those since requesting them from the container makes no sense. I suppose a constructor could depend on an abstract type and expect an actual implementation, though. I haven't thought about that use case actually, but it's possible to configure a substitute for this case. Other IoC containers may handle this one better, since you may want to have different implementations depending on the current scope.
If you mean classes with private constructors, those are technically illegal. According to the PHP manual, constructors must be declared public. The fact that private constructors work at all should be considered an implementation detail.
Breakage occurs when something is said to be a class, yet isn't a class but still appears in the parameter list of a constructor. The container would instantiate a ReflectionClass of whatever is being requested and pass that around. At some point it'll call newInstanceArgs either with configuration-provided arguments or with auto-wired dependencies. The first case could still work, but foregoes auto-wiring.
- francislavoie 5y agoI can't think of any situation you'd put an enum in the container though. Maybe I'm just too tired to think of a situation where that would be helpful. Can you think of one?
- pdenton 5y ago* A database abstraction layer that's instantiated with a certain access level * A hydrator/extractor that changes the type of the value it handles * A task or job that has a certain priority to it
- deleted 5y ago[deleted]