Skip to content

[Feature Request] Tagged iterators without tags! #53090

@sylfabre

Description

@sylfabre

Description

I use tagged iterators mostly to autowire implementations of a given interface as an iterable.

#[AutoconfigureTag('app.some_tag')]
interface SomeInterface
{
    ...
}

class SomeService
{
    public function __construct(
        /** @var SomeInterface[] */
        #[TaggedIterator('app.some_tag')]
        protected iterable $somes
    ) {
    }
}

It works great 👍
And I understand I have to provide a tag because this is how the system works today ✅
And I understand that the tag may be useful for other use cases ✅
However, from a developer's POV, I don't care about what this tag is 99% of the time so I would like it to be optional.

Example

It would be amazing if this simpler code was working 🤩

class SomeService
{
    public function __construct(
        /** @var SomeInterface[] */
        #[InterfaceIterator(SomeInterface::class)]
        protected iterable $somes
    ) {
    }
}

Or if it makes it easier to implement

#[AutoconfigureForIterable]
interface SomeInterface
{
    ...
}
class SomeService
{
    public function __construct(
        /** @var SomeInterface[] */
        #[InterfaceIterator(SomeInterface::class)]
        protected iterable $somes
    ) {
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions