Skip to content

Instantly share code, notes, and snippets.

@GRMule
Created May 14, 2015 18:36
Show Gist options
  • Save GRMule/addd42fe35263b3f518a to your computer and use it in GitHub Desktop.
Save GRMule/addd42fe35263b3f518a to your computer and use it in GitHub Desktop.
<?php
require_once('../vendor/autoload.php'); // composer autoload
class Foo {
public $someProperty = 'val1';
}
class Bar {
public function __construct($valueFromFoo){
}
}
$auryn = new Auryn\Injector();
$auryn->delegate('Bar', function (Foo $foo) {
return new Bar($foo->someProperty);
});
$bar = $auryn->make('Bar');
// expected: delegate function is provisioed with a Foo object
// actual: Catchable fatal error: Argument 1 passed to {closure}() must be an instance of Foo, string given
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment