Skip to content

[DI] error for unused binding on controller action #28041

@dmaicher

Description

@dmaicher

Symfony version(s) affected: 3.4.13 (and other new patch releases for 4.0 & 4.1)

Description
I just updated my app from 3.4.12 to 3.4.13 and have an error with a service configuration.

How to reproduce
Add a binding by variable name for an argument of a controller action.

I have a controller like this:

class LegacyAdminController extends Controller
{
    /**
     * @Route("/{path}", requirements={"path"=".+"})
     */
    public function proxyAction(
        ServerRequestInterface $request,
        LegacyUserMapper $legacyUserMapper,
        Client $legacyProxyClient
    ) {

And the config:

    App\Controller\LegacyAdminController:
        tags: ['controller.service_arguments']
        bind:
            $legacyProxyClient: '@ca_admin.legacy_proxy_client'

Now I get this error:

In ResolveBindingsPass.php line 48:
                                                                                                     
  Unused binding "$legacyProxyClient" in service "CA\AdminBundle\Controller\LegacyAdminController".

Possible Solution
As just discussed with @nicolas-grekas the problem was introduced in https://github.com/symfony/symfony/pull/27834/files.

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