BlueSpice MediaWiki REL1_27
 All Classes Namespaces Files Functions Variables Groups Pages
Callback container

![Build Status]( ![Code Coverage]( ![Scrutinizer Code Quality]( ![Latest Stable Version]( ![Packagist download count]( ![Dependency Status](

A simple object instantiator to lazy load registered callback handlers. Part of the code base has been extracted from Semantic MediaWiki and is now being deployed as independent library.


PHP 5.3 / HHVM 3.5 or later


The recommended installation method for this library is to add the dependency to your composer.json.

```json { "require": { "onoi/callback-container": "~1.1" } } ```


```php class FooCallbackContainer implements CallbackContainer {

public function register( CallbackInstantiator $callbackInstantiator ) {
    $this->addCallbackHandlers( $callbackInstantiator);

private function addCallbackHandlers( $callbackInstantiator ) {

    $callbackInstantiator->registerCallback( 'Foo', function( array $input ) {
        $stdClass = new \stdClass;
        $stdClass->input = $input;

        return $stdClass;
    } );

    $callbackInstantiator->registerExpectedReturnType( 'Foo', '\stdClass' );

} php $callbackInstantiator = new DeferredCallbackLoader();

$callbackInstantiator->registerCallbackContainer( new FooCallbackContainer() ); $instance = $callbackInstantiator->create( 'Foo', array( 'a', 'b' ) );

$instance = $callbackInstantiator->singleton( 'Foo', array( 'aa', 'bb' ) ); ```

If a callback handler is registered with an expected return type then any mismatch of a returning instance will throw a RuntimeException.

Contribution and support

If you want to contribute work to the project please subscribe to the developers mailing list and have a look at the / "contribution guidelinee". A list of people who have made contributions in the past can be found here.


The library provides unit tests that covers the core-functionality normally run by the continues integration platform. Tests can also be executed manually using the composer phpunit command from the root directory.

Release notes

  • 1.1.0 (2016-04-30)
    • Fixed issue in registeredObject for when a singleton override contained a null argument
    • Deprecated the CallbackLoader interface in favour of the CallbackInstantiator interface
    • Deprecated the NullCallbackLoader class in favour of the NullCallbackInstantiator class
  • 1.0.0 Initial release (2015-09-08)
    • Added the CallbackContainer and CallbackLoader interface
    • Added the DeferredCallbackLoader and NullCallbackLoader implementation


GNU General Public License 2.0 or later.