Skip to content
This repository has been archived by the owner on Jan 16, 2019. It is now read-only.

Docs IOC DefaultImplementations

Frank Kleine edited this page Apr 7, 2012 · 1 revision

Inversion of Control: Default implementations

Very often, you only use one concrete implementation of an interface in your application and only added the interface or abstract class to make it testable. To avoid having to bind all of your interfaces to the concrete implementations, you may specify a default implementation, which will be used, if no explicit binding has been set. To achieve this, add the @ImplementedBy annotation to your interface.

#php
<?php
/**
*All Persons should be bound to the class Schst
*unless Person is bound
 *
*@ImplementedBy(Schst.class)
*/
interface Person {
    public function sayHello();
}
?>

You may also specify the fully qualified class name, Stubbles will then load the class, if it's not already loaded.

Clone this wiki locally