Skip to content

Defining service locators without a class #40861

@derrabus

Description

@derrabus

Symfony version(s) affected: 5.3.0-beta1

Description
See nelmio/NelmioApiDocBundle#1807

In Symfony 5.2, it was possible to define a service locator service without defining the actual class of the service:

https://github.com/nelmio/NelmioApiDocBundle/blob/bf77277f2fe7c52a5226493d6593659ddb8b9fb8/DependencyInjection/NelmioApiDocExtension.php#L132-L138

In Symfony 5.3, this code fails:

The definition for "nelmio_api_doc.generator_locator" has no class. If you intend to inject this service dynamically at runtime, please mark it as synthetic=true. If this is an abstract definition solely used by child definitions, please add abstract=true, otherwise specify a class to get rid of this error.

According to the documentation, the Symfony\Component\DependencyInjection\ServiceLocator should be used in the definition.

The fix for NelmioApiDocBundle is trivial and I've already opened nelmio/NelmioApiDocBundle#1808 to address the issue. However, since this bundle broke because of a Symfony upgrade, I wanted to clarify if we want to treat this issue as a regression.

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