Skip to content

Commit 7fc2552

Browse files
committed
bug #23141 [DI] Fix keys resolution in ResolveParameterPlaceHoldersPass (nicolas-grekas)
This PR was merged into the 3.3 branch. Discussion ---------- [DI] Fix keys resolution in ResolveParameterPlaceHoldersPass | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Keys are resolved in 3.2, but we broke that when moving to AbstractRecursivePass. Commits ------- 9251a21 [DI] Fix keys resolution in ResolveParameterPlaceHoldersPass
2 parents 6852b10 + 9251a21 commit 7fc2552

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,14 @@ protected function processValue($value, $isRoot = false)
6565
if (isset($changes['file'])) {
6666
$value->setFile($this->bag->resolveValue($value->getFile()));
6767
}
68-
$value->setProperties($this->bag->resolveValue($value->getProperties()));
69-
$value->setMethodCalls($this->bag->resolveValue($value->getMethodCalls()));
7068
}
7169

72-
return parent::processValue($value, $isRoot);
70+
$value = parent::processValue($value, $isRoot);
71+
72+
if ($value && is_array($value)) {
73+
$value = array_combine($this->bag->resolveValue(array_keys($value)), $value);
74+
}
75+
76+
return $value;
7377
}
7478
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ public function testFactoryParametersShouldBeResolved()
4141

4242
public function testArgumentParametersShouldBeResolved()
4343
{
44-
$this->assertSame(array('bar', 'baz'), $this->fooDefinition->getArguments());
44+
$this->assertSame(array('bar', array('bar' => 'baz')), $this->fooDefinition->getArguments());
4545
}
4646

4747
public function testMethodCallParametersShouldBeResolved()
4848
{
49-
$this->assertSame(array(array('foobar', array('bar', 'baz'))), $this->fooDefinition->getMethodCalls());
49+
$this->assertSame(array(array('foobar', array('bar', array('bar' => 'baz')))), $this->fooDefinition->getMethodCalls());
5050
}
5151

5252
public function testPropertyParametersShouldBeResolved()
@@ -71,7 +71,7 @@ private function createContainerBuilder()
7171
$containerBuilder->setParameter('foo.class', 'Foo');
7272
$containerBuilder->setParameter('foo.factory.class', 'FooFactory');
7373
$containerBuilder->setParameter('foo.arg1', 'bar');
74-
$containerBuilder->setParameter('foo.arg2', 'baz');
74+
$containerBuilder->setParameter('foo.arg2', array('%foo.arg1%' => 'baz'));
7575
$containerBuilder->setParameter('foo.method', 'foobar');
7676
$containerBuilder->setParameter('foo.property.name', 'bar');
7777
$containerBuilder->setParameter('foo.property.value', 'baz');
@@ -80,7 +80,7 @@ private function createContainerBuilder()
8080

8181
$fooDefinition = $containerBuilder->register('foo', '%foo.class%');
8282
$fooDefinition->setFactory(array('%foo.factory.class%', 'getFoo'));
83-
$fooDefinition->setArguments(array('%foo.arg1%', '%foo.arg2%'));
83+
$fooDefinition->setArguments(array('%foo.arg1%', array('%foo.arg1%' => 'baz')));
8484
$fooDefinition->addMethodCall('%foo.method%', array('%foo.arg1%', '%foo.arg2%'));
8585
$fooDefinition->setProperty('%foo.property.name%', '%foo.property.value%');
8686
$fooDefinition->setFile('%foo.file%');

0 commit comments

Comments
 (0)
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