Closed
Description
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.