Skip to content

[DI] Trim tag name before injecting tagged services #25855

@z38

Description

@z38
Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? no
Symfony version 4.0.3, master

When injecting tagged services the whitespace around the tag name is significant (at least with YAML). Because unquoted, tagged values are not evaluated in the YAML parser, the whitespace will be passed to the DI component. It would be nice if the !tagged would behave more like !!str which seems to trim whitespace around unquoted strings. Alternatively, a warning message which indicates an invalid tag name would be fine too.

Example:

services:
    app.foo:
        class: App\Foo
        arguments: [ !tagged bar ]

The container compiler will try to inject services with the tag "bar " (note the trailing space).

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