Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ private function resolveServices($value, $file, $isParameter = false)
throw new InvalidArgumentException(sprintf('"!%s" tag contains unsupported key "%s"; supported ones are "tag", "index_by" and "default_index_method".', $value->getTag(), implode('"", "', $diff)));
}

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

if ($forLocator) {
$argument = new ServiceLocatorArgument($argument);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
services:
iterator_service:
class: FooClass
arguments: [!tagged {tag: test.tag}]
Original file line number Diff line number Diff line change
Expand Up @@ -852,4 +852,18 @@ public function testOverriddenDefaultsBindings()

$this->assertSame('overridden', $container->get('bar')->quz);
}

/**
* When creating a tagged iterator using the array syntax, all optional parameters should be properly handled.
*/
public function testDefaultValueOfTagged()
{
$container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
$loader->load('tagged_iterator_optional.yml');

$iteratorArgument = $container->getDefinition('iterator_service')->getArgument(0);
$this->assertInstanceOf(TaggedIteratorArgument::class, $iteratorArgument);
$this->assertNull($iteratorArgument->getIndexAttribute());
}
}