Skip to content

[DI] Improve container logs when service inlined/removed #27386

@Tobion

Description

@Tobion

Description
Currently when a service is inlined in anoter service you get a log message like

Inlined service "abc" to "xyz".

And at the same time you also get a log message that the service got removed

Removed service "abc"; reason: unused.

IMO when it a service is inlined, it should not also log that it got removed.
This way you can actually find services that are unused. Currently you get alot of duplicate messages for inlined services. And the reason "unused" is even more irritating as it is not really unused, it was just inlined because it's only used once.

Another improvement can be made for the autowire pass. When an object argument has a default value that cannot be wired, it does not error but logs a message like

Symfony\Component\DependencyInjection\Compiler\AutowirePass
Cannot autowire service "Ekino\NewRelicBundle\Listener\ResponseListener": argument "$newRelicTwigExtension" of method "__construct()" references class "Ekino\NewRelicBundle\Twig\NewRelicExtension" but no such service exists.

This is good. But for consistency and debugging purposes, it would be good if a scalar argument that has a default value that wasn't wired explicitly, also triggers a log. You might have just forgotten to wire it with a parameter for example and that is hard to spot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DXDX = Developer eXperience (anything that improves the experience of using Symfony)DependencyInjection

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions