Last active
May 30, 2018 08:06
-
-
Save koriym/88647b1029dd5275422d71ecf062c4e3 to your computer and use it in GitHub Desktop.
Should dependency injector only do injections ?
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
<?php | |
// Should injections only do injections ? | |
// current - "get"Instance() | |
$injector = new Injector(new Bindings); | |
// get instance by interface name | |
$foo = $injector->getInstance(FooInterface::class); | |
// "injection" only - better ??? | |
$injector = new Injector(new Bindings); | |
// create instance without dependent instance | |
$foo = (new \ReflectionClass(Foo::class))->newInstanceWithoutConstructor(); | |
// dependency injection !! | |
$injector->inject($foo); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment