Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[DI] Tagged locator no longer provides service class names as of 4.4.6 #36258

Copy link
Copy link
Closed
@allcode

Description

@allcode
Issue body actions

Symfony version(s) affected: 4.4.6

Description
This issue is regarding a change in functionality of the !tagged_locator (Symfony\Component\DependencyInjection\Argument\ServiceLocator) after updating from 4.4.5 to 4.4.6.

With SF 4.4.5 and earlier, the injected tagged locator provides an array with the alias as key and the FQCN as value when calling getProvidedServices().
As of SF 4.4.6, the FQCN value is replaced with a '?'.

The reason it only provides a '?' is because it now uses a generic Reference instead of a TypedReference for the tagged services. The PhpDumper only adds the service type to the $serviceTypes property of the ServiceLocator if the reference is a TypedReference.

The change is caused by #35957 in \Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait.

Possible Solution
This specific problem can be solved by adding a TypedReference if the resolved class service exists and is not stdClass:

        foreach ($services as [, , $index, $serviceId]) {
            $class = $container->getDefinition($serviceId)->getClass();
            $class = $container->getParameterBag()->resolveValue($class) ?: null;

            if (!$class || 'stdClass' === $class) {
                $reference = new Reference($serviceId);
            } elseif ($index === $serviceId) {
                $reference = new TypedReference($serviceId, $class);
            } else {
                $reference = new TypedReference($serviceId, $class, ContainerBuilder::EXCEPTION_ON_INVALID_REFERENCE, \is_string($index) ? $index : null);
            }

            if (null === $index) {
                $refs[] = $reference;
            } else {
                $refs[$index] = $reference;
            }
        }

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.