Skip to content

Optional attributes in !tagged_iterator not properly handled #32603

@apfelbox

Description

@apfelbox

Symfony version(s) affected: 4.3.2+

Description
Using the !tagged handler in YAML service definitions throws

Notice: Undefined index: index_by

How to reproduce
Define any service with:

App\MyService:
    $tagged: !tagged_iterator {tag: test.tag}

Please note that the string version works:

App\MyService:
    $tagged: !tagged_iterator test.tag

Possible Solution
Although the key seems to be optional (at least all the docs tell me it should be) there is no fallback in the array access.

https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php#L744

This line:

$argument = new TaggedIteratorArgument($argument['tag'], $argument['index_by'], $argument['default_index_method'] ?? null, $forLocator);

should probably be

$argument = new TaggedIteratorArgument($argument['tag'], $argument['index_by'] ?? null, $argument['default_index_method'] ?? null, $forLocator);
//                                                                            ^^^^^^^^

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy