thephpleague / container

Small but powerful dependency injection container

Home Page:http://container.thephpleague.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

If definition has only one tag return the definition not an array

JeanPaiva opened this issue · comments

The method League\Container\Container::get always return an array of definitions if has a tag set.
If only one definition was found with that tag, it could be returned directly instead?

Simple use case:

$container->add(Slim\Http\Environment::class)->addArgument($_SERVER)->addTag('environment');

$container->add('request', function () use ($container) {
    return Request::createFromEnvironment($container->get('environment')[0]);
}, true);

I think this makes the feature more complex, it was always supposed to replicate ArrayOf functionality so it's unlikely that I would change that behaviour.