Skip to content

Commit 7cc7c85

Browse files
committed
Fixing bug where indexed args were set wrong in pass in some situations
1 parent 3646d08 commit 7cc7c85

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/Symfony/Component/DependencyInjection/Compiler/ResolveNamedArgumentsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protected function processValue($value, $isRoot = false)
4040

4141
foreach ($arguments as $key => $argument) {
4242
if (is_int($key)) {
43-
$resolvedArguments[] = $argument;
43+
$resolvedArguments[$key] = $argument;
4444
continue;
4545
}
4646
if ('' === $key || '$' !== $key[0]) {

src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveNamedArgumentsPassTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,17 @@ public function testProcess()
2727
$container = new ContainerBuilder();
2828

2929
$definition = $container->register(NamedArgumentsDummy::class, NamedArgumentsDummy::class);
30-
$definition->setArguments(array(0 => new Reference('foo'), '$apiKey' => '123'));
30+
$definition->setArguments(array(
31+
2 => 'http://api.example.com',
32+
'$apiKey' => '123',
33+
0 => new Reference('foo'),
34+
));
3135
$definition->addMethodCall('setApiKey', array('$apiKey' => '123'));
3236

3337
$pass = new ResolveNamedArgumentsPass();
3438
$pass->process($container);
3539

36-
$this->assertEquals(array(0 => new Reference('foo'), 1 => '123'), $definition->getArguments());
40+
$this->assertEquals(array(0 => new Reference('foo'), 1 => '123', 2 => 'http://api.example.com'), $definition->getArguments());
3741
$this->assertEquals(array(array('setApiKey', array('123'))), $definition->getMethodCalls());
3842
}
3943

src/Symfony/Component/DependencyInjection/Tests/Fixtures/NamedArgumentsDummy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
class NamedArgumentsDummy
99
{
10-
public function __construct(CaseSensitiveClass $c, $apiKey)
10+
public function __construct(CaseSensitiveClass $c, $apiKey, $hostName)
1111
{
1212
}
1313

0 commit comments

Comments
 (0)