Created
February 22, 2013 18:55
-
-
Save giorgiosironi/5015697 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyClass | |
{ | |
function __construct(Collaborator %collaborator) | |
{ | |
} | |
} | |
// vs. | |
class MyClass | |
{ | |
function doSomething(Collaborator $collaborator) | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
MyClass is composed by SomeHttpAction, which creates an implementation of Collaborator depending on some input parameter. SomeHttpAction and MyClass are created at the startup, while Collaborator is created after analyzing the request: that's why I find it handy to inject it as a parameter; from the point of view of MyClass nothing really changes.