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

default_index_method mishandles "numeric" strings #35349

Copy link
Copy link
Closed
@Bilge

Description

@Bilge
Issue body actions

Symfony version(s) affected: 4.4.0

Description
Creating a tagged locator with default_index_method set to a method name returning numbers encoded as strings (e.g. "123"), does not work. It reindexes each entry as a numerical list starting from 0 instead of using the values supplied by the index method.

How to reproduce

services:
    _instanceof:
        My\Service:
            tags: [foo]

    My\ServiceAggregator:
        arguments:
            $foos: !tagged_locator { tag: foo, default_index_method: getId }

Additional context
Debugging shows My\Service::getId is actually called at container creation time, and it receives the correct value, but ends up discarding it at some point. That point is exactly here, where it does an array_merge, which according to the docs:

Values in the input arrays with numeric keys will be renumbered with incrementing keys starting from zero in the result array.

This is the beaviour I'm seeing.

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.