Skip to content

Reference Tagged Services combined with Autoconfiguring Tags does not work #36682

@kniziol

Description

@kniziol

Symfony version(s) affected: 4.3.11

Description
Reference Tagged Services combined with Autoconfiguring Tags does not work

How to reproduce

  1. Create interface
  2. Tag the interface under _instanceof - as described in Autoconfiguring Tags
  3. Create a service and pass all !tagged services as its arguments - as described in Reference Tagged Services
  4. Run bin/console cache:clear (or any other command)
  5. You will see Cannot autowire service (…): argument "$handlers" of method "__construct()" is type-hinted "iterable", you should configure its value explicitly. exception

Is it a bug?

Workaround

  1. Create a Compiler Pass class that implements CompilerPassInterface
  2. Call findTaggedServiceIds() + addMethodCall() as described in How to Work with Compiler Passes

Is there another solution?

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