Skip to content

[DI Debug] Private Aliases not shown with debug:container #16388

Closed
@linaori

Description

@linaori

When running debug:container --show-private, it doesn't show private aliases. A scenario where this happens is when a private alias is used for a private service to optimize them away and prevent Container->get() usage.

My company has code that automates generating services for repositories, this follows a specific setup: order.repository.clients_order_line where clients is the entity manager (connection) name. This would result in a private alias: order.repository.order_line pointing at order.repository.clients_order_line. This code works perfect with one downside, private alias cannot be found back.

The naming follows a convention so we can always find it back one way or another, but we cannot find it using the debug:container command nor can an IDE such as PHPStorm find it as it's optimized away. I've been digging in the code and in TextDescriptor::describeContainerServices() this is not available.

My guess is that private aliases are optimized away if they are not used before hitting this code and is therefore a bug. If I wanted to find all un-used private services/alias, I would be unable to do so with the current setup.

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