Composite pattern and Dependency Injection
问题 I see that Composite pattern and dependency injection means public function __construct(ClassToUseInterface $class) { $this->class = $class } So, what's the difference ? 回答1: The code as presented in your question neither represents dependency-injection, nor does it represent the composite pattern. Your code represents what is known as Dependency inversion. Let's answer your question : One way for your code to truly represent Dependency injection is to call the construct function from code