Skip to content

Version 0.17

Latest
Compare
Choose a tag to compare
@jm42 jm42 released this 21 Jun 17:44
· 3 commits to master since this release

On __invoke, make class when string is not found in the registry.

$di = new Registry;
$di(SomeClass::class);
// will make an instance of SomeClass and call __invoke method

before:

$di = new Registry;
$di[SomeClass::class] = function(callable $make) {
    return $make();
};
$di(SomeClass::class);

BC-BREAK

Now Registry::make throws UnexpectedValueException when is not instantiable.

BC-BREAK

Now InvalidArgumentException is thrown when trying to reflect an interface.

BC-BREAK

Remove shortcuts to create build a concrete and with arguments.

before:

$di = new Registry;
$di[AbstractClass::class] = ConcreteClass::class;

now:

$di = new Registry;
$di[AbstractClass::class] = function(callable $make) {
    return $make(ConcreteClass::class);
};

before:

$di = new Registry;
$di[ConcreteClass::class] = ['arg0'];

now:

$di = new Registry;
$di[ConcreteClass::class] = function(callable $make) {
    return $make(ConcreteClass::class, ['arg0']);
};

BC-BREAK

Remove argument resolve.

before:

$di = new Registry;
$di['param_from_registry'] = 'some value';
$di[DependencyClass::class] = function() {
    return new DependencyClass
};
$di[SomeClass::class] = function(callable $make) {
    return $make(SomeClass::class, [
        '$param_from_registry',
        DependencyClass::class,
    ]);
};

now:

$di = new Registry;
$di[DependencyClass::class] = function() {
    return new DependencyClass
};
$di[SomeClass::class] = function(callable $make, DependencyClass $dep) {
    return $make(SomeClass::class, [
        'some value',
        $dep,
    ]);
};