Skip to content

Commit

Permalink
bug #23141 [DI] Fix keys resolution in ResolveParameterPlaceHoldersPa…
Browse files Browse the repository at this point in the history
…ss (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
  • Loading branch information
fabpot committed Jun 12, 2017
2 parents 6852b10 + 9251a21 commit 7fc2552
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Expand Up @@ -65,10 +65,14 @@ protected function processValue($value, $isRoot = false)
if (isset($changes['file'])) {
$value->setFile($this->bag->resolveValue($value->getFile()));
}
$value->setProperties($this->bag->resolveValue($value->getProperties()));
$value->setMethodCalls($this->bag->resolveValue($value->getMethodCalls()));
}

return parent::processValue($value, $isRoot);
$value = parent::processValue($value, $isRoot);

if ($value && is_array($value)) {
$value = array_combine($this->bag->resolveValue(array_keys($value)), $value);
}

return $value;
}
}
Expand Up @@ -41,12 +41,12 @@ public function testFactoryParametersShouldBeResolved()

public function testArgumentParametersShouldBeResolved()
{
$this->assertSame(array('bar', 'baz'), $this->fooDefinition->getArguments());
$this->assertSame(array('bar', array('bar' => 'baz')), $this->fooDefinition->getArguments());
}

public function testMethodCallParametersShouldBeResolved()
{
$this->assertSame(array(array('foobar', array('bar', 'baz'))), $this->fooDefinition->getMethodCalls());
$this->assertSame(array(array('foobar', array('bar', array('bar' => 'baz')))), $this->fooDefinition->getMethodCalls());
}

public function testPropertyParametersShouldBeResolved()
Expand All @@ -71,7 +71,7 @@ private function createContainerBuilder()
$containerBuilder->setParameter('foo.class', 'Foo');
$containerBuilder->setParameter('foo.factory.class', 'FooFactory');
$containerBuilder->setParameter('foo.arg1', 'bar');
$containerBuilder->setParameter('foo.arg2', 'baz');
$containerBuilder->setParameter('foo.arg2', array('%foo.arg1%' => 'baz'));
$containerBuilder->setParameter('foo.method', 'foobar');
$containerBuilder->setParameter('foo.property.name', 'bar');
$containerBuilder->setParameter('foo.property.value', 'baz');
Expand All @@ -80,7 +80,7 @@ private function createContainerBuilder()

$fooDefinition = $containerBuilder->register('foo', '%foo.class%');
$fooDefinition->setFactory(array('%foo.factory.class%', 'getFoo'));
$fooDefinition->setArguments(array('%foo.arg1%', '%foo.arg2%'));
$fooDefinition->setArguments(array('%foo.arg1%', array('%foo.arg1%' => 'baz')));
$fooDefinition->addMethodCall('%foo.method%', array('%foo.arg1%', '%foo.arg2%'));
$fooDefinition->setProperty('%foo.property.name%', '%foo.property.value%');
$fooDefinition->setFile('%foo.file%');
Expand Down

0 comments on commit 7fc2552

Please sign in to comment.