diff --git a/Compiler/ResolveParameterPlaceHoldersPass.php b/Compiler/ResolveParameterPlaceHoldersPass.php index aa932e944..9733e5d09 100644 --- a/Compiler/ResolveParameterPlaceHoldersPass.php +++ b/Compiler/ResolveParameterPlaceHoldersPass.php @@ -66,6 +66,7 @@ protected function processValue($value, $isRoot = false) return $this->resolveArrays || !$v || !is_array($v) ? $v : $value; } if ($value instanceof Definition) { + $value->setBindings($this->processValue($value->getBindings())); $changes = $value->getChanges(); if (isset($changes['class'])) { $value->setClass($this->bag->resolveValue($value->getClass())); diff --git a/Tests/Compiler/ResolveParameterPlaceHoldersPassTest.php b/Tests/Compiler/ResolveParameterPlaceHoldersPassTest.php index b9459729e..a34e007de 100644 --- a/Tests/Compiler/ResolveParameterPlaceHoldersPassTest.php +++ b/Tests/Compiler/ResolveParameterPlaceHoldersPassTest.php @@ -64,6 +64,13 @@ public function testAliasParametersShouldBeResolved() $this->assertSame('foo', $this->container->getAlias('bar')->__toString()); } + public function testBindingsShouldBeResolved() + { + list($boundValue) = $this->container->getDefinition('foo')->getBindings()['$baz']->getValues(); + + $this->assertSame($this->container->getParameterBag()->resolveValue('%env(BAZ)%'), $boundValue); + } + private function createContainerBuilder() { $containerBuilder = new ContainerBuilder(); @@ -84,6 +91,7 @@ private function createContainerBuilder() $fooDefinition->addMethodCall('%foo.method%', array('%foo.arg1%', '%foo.arg2%')); $fooDefinition->setProperty('%foo.property.name%', '%foo.property.value%'); $fooDefinition->setFile('%foo.file%'); + $fooDefinition->setBindings(array('$baz' => '%env(BAZ)%')); $containerBuilder->setAlias('%alias.id%', 'foo'); diff --git a/Tests/Fixtures/php/services26.php b/Tests/Fixtures/php/services26.php index 6519a9dff..257a145c6 100644 --- a/Tests/Fixtures/php/services26.php +++ b/Tests/Fixtures/php/services26.php @@ -29,6 +29,7 @@ public function __construct() $this->services = array(); $this->methodMap = array( + 'bar' => 'getBarService', 'test' => 'getTestService', ); @@ -60,6 +61,16 @@ public function isFrozen() return true; } + /** + * Gets the public 'bar' shared service. + * + * @return \Symfony\Component\DependencyInjection\Tests\Fixtures\Bar + */ + protected function getBarService() + { + return $this->services['bar'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\Bar($this->getEnv('QUZ')); + } + /** * Gets the public 'test' shared service. * diff --git a/Tests/Fixtures/yaml/services26.yml b/Tests/Fixtures/yaml/services26.yml index aa44b4d77..a1f235a7c 100644 --- a/Tests/Fixtures/yaml/services26.yml +++ b/Tests/Fixtures/yaml/services26.yml @@ -15,3 +15,8 @@ services: - '%env(Bar)%' - 'foo%bar%baz' - '%baz%' + bar: + class: Symfony\Component\DependencyInjection\Tests\Fixtures\Bar + public: true + bind: + $quz: '%env(QUZ)%'