expect(NotFoundException::class, 'should throw on attempt to configure undefined component', function () use($c) { $c->configure('nope', function () { }); }); $c = new Container(); $c->register(Foo::class); $c->register('zap', Bar::class); $ok = false; $c->configure(Foo::class, function (Foo $foo, Bar $bar) use(&$ok) { $ok = true; }, ['bar' => $c->ref('zap')]); $got_foo = false; $c->configure(function (Foo $few) use(&$got_foo) { $got_foo = true; }); $c->get(Foo::class); ok($ok, 'can use parameter list/map in calls to configure()'); ok($got_foo, 'can infer component name from argument type-hint'); }); test('named components take precedence over type-hints', function () { $container = new Container(); $container->register(FileCache::class, ["/tmp/foo"]); $container->register("cache", FileCache::class, ["/tmp/bar"]); $by_type = null; $container->call(function (FileCache $cache) use(&$by_type) { $by_type = $cache; }); $by_name = null; $container->call(function ($cache) use(&$by_name) { $by_name = $cache; });