You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 16, 2019. It is now read-only.
Frank Kleine edited this page Apr 7, 2012
·
1 revision
Inversion of Control: Implicit bindings
Stubbles does not force you to use interfaces in your type hints. If you are already using concrete classes, there is no need to bind them, as Stubbles will implicitly bind the concrete class to itself:
#php
<?php
class Window {}
class BMW implements Car {
protected $driver;
protected $engine;
protected $tire;
protected $window;
// same constructor and methods as in previous examples
/**
***@Inject
***/
public function setWindow(Window $win) {
$this->window = $win;
}
}
?>
When creating an instance of BMW, it will automatically have a reference to an instance of Window although no special binding has been added.
Please note that implicit bindings turn into explicit bindings once the net::stubbles::ioc::stubInjector::hasBinding() or net::stubbles::ioc::stubInjector::getInstance() methods are called.