8000 Autowire: Try with variable name in case of doubt · Issue #23346 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Autowire: Try with variable name in case of doubt #23346
Closed
@ScreamingDev

Description

@ScreamingDev
Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? yes
Symfony version 3.3.z

I am having this class and want to autowire it:



use SimpleBus\Message\Bus\MessageBus;

class AddressController
{
    /**
     * AddressController constructor.
     *
     * @param MessageBus        $commandBus Bla bla (e.g. simple_bus.command_bus)
     */
    public function __construct(MessageBus $commandBus)
    {
        // ...
    }
}

But it errors with:

argument "$commandBus" of method "__construct()" references interface "SimpleBus\Message\Bus\MessageBus" but no such service exists. You should maybe alias this interface to one of these existing services: "simple_bus.command_bus", "simple_bus.event_bus".

I understand this and like to add a feature request.

Put in some additional strategy to autowire services like:

  • Variable name can be found in the service name (e.g. $commandBus in "simple_bus.command_bus").
  • DocComment tells which service to use (e.g. Bla bla (e.g. simple_bus.command_bus) ).
  • or @see simple_bus.command_bus

I guess there is some more or better to look up.

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

      0