yiisoft/di

Check tag services array in `Container::setTags()` on empty

Closed this issue · 4 comments

vjik commented

Now we can add tag with empty array and $container->has() returns true. It's wrong.

I think it's totally okay to have an empty tags.
First of all, we shouldn't put sticks in the wheels. Making a developer remove a line or start a debugging research do it.
An empty tag may be computed during some operations from config (removing keys or values).
There are nothing bad if sometime tag can be empty. It's ok to have it. You may provide a point of the expansion of your library.
Also tagged definitions are iterable. Empty tag is also iterable.

vjik commented

I think it's totally okay to have an empty tags. First of all, we shouldn't put sticks in the wheels. Making a developer remove a line or start a debugging research do it. An empty tag may be computed during some operations from config (removing keys or values). There are nothing bad if sometime tag can be empty. It's ok to have it. You may provide a point of the expansion of your library. Also tagged definitions are iterable. Empty tag is also iterable.

Should $container->has() returns true on empty tag?

For sure

vjik commented

Ok, agree