-
Notifications
You must be signed in to change notification settings - Fork 11.4k
[Proposal] Make dependency injection work with default values #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
$container = new Container; | ||
$container->bind('IContainerContractStub', 'ContainerImplementationStub'); | ||
$class = $container->make('ContainerNestedDependentWithDefaultValueStub'); | ||
$this->assertTrue($class->inner instanceof ContainerDependentStub); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about assertInstanceOf()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just copying Taylors tests
Nice one. Looks good. |
$this->inner = $inner; | ||
$this->innerArray = $innerArray; | ||
$this->innerString = 'string'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is supposed to copy over the parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, oops. Half asleep here haha
Seems logical to me. 👍 |
Are these being checked? |
Worked for me 👍 |
Done. Implemented slightly differently. |
Feature/create users
I thought this would work by default, was using a component via dependency injection that has
$configuration = null
in the constructor and it threw the binding resolution exception. So I had a look and it was easy to make default values work, is there any reason to not do this?