diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index d04f558980..d5acdd729d 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -415,16 +415,14 @@ class PhpDumper extends Dumper } $processed->offsetSet($iDefinition); - if (!$this->hasReference($id, $iDefinition->getMethodCalls())) { + if (!$this->hasReference($id, $iDefinition->getMethodCalls()) && !$this->hasReference($id, $iDefinition->getProperties())) { continue; } - if ($iDefinition->getMethodCalls()) { - $code .= $this->addServiceMethodCalls(null, $iDefinition, (string) $this->definitionVariables->offsetGet($iDefinition)); - } - if ($iDefinition->getConfigurator()) { - $code .= $this->addServiceConfigurator(null, $iDefinition, (string) $this->definitionVariables->offsetGet($iDefinition)); - } + $name = (string) $this->definitionVariables->offsetGet($iDefinition); + $code .= $this->addServiceMethodCalls(null, $iDefinition, $name); + $code .= $this->addServiceProperties(null, $iDefinition, $name); + $code .= $this->addServiceConfigurator(null, $iDefinition, $name); } if ('' !== $code) { diff --git a/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/containers/container9.php b/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/containers/container9.php index da0a7bbb45..72c355f70c 100644 --- a/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/containers/container9.php +++ b/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/containers/container9.php @@ -57,4 +57,15 @@ $container-> setFactoryMethod('getInstance') ; +$container + ->register('foo_with_inline', 'Foo') + ->addMethodCall('setBar', array(new Reference('inlined'))) +; +$container + ->register('inlined', 'Bar') + ->setProperty('pub', 'pub') + ->addMethodCall('setFoo', array(new Reference('foo_with_inline'))) + ->setPublic(false) +; + return $container; diff --git a/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/graphviz/services9.dot b/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/graphviz/services9.dot index 3bed9669c7..b9618bb051 100644 --- a/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/graphviz/services9.dot +++ b/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/graphviz/services9.dot @@ -9,6 +9,8 @@ digraph sc { node_foo_bar [label="foo_bar\nFooClass\n", shape=record, fillcolor="#eeeeee", style="dotted"]; node_method_call1 [label="method_call1\nFooClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; node_factory_service [label="factory_service\nBar\n", shape=record, fillcolor="#eeeeee", style="filled"]; + node_foo_with_inline [label="foo_with_inline\nFoo\n", shape=record, fillcolor="#eeeeee", style="filled"]; + node_inlined [label="inlined\nBar\n", shape=record, fillcolor="#eeeeee", style="filled"]; node_service_container [label="service_container\nSymfony\\Component\\DependencyInjection\\ContainerBuilder\n", shape=record, fillcolor="#9999ff", style="filled"]; node_foo2 [label="foo2\n\n", shape=record, fillcolor="#ff9999", style="filled"]; node_foo3 [label="foo3\n\n", shape=record, fillcolor="#ff9999", style="filled"]; @@ -22,4 +24,6 @@ digraph sc { node_method_call1 -> node_foo2 [label="setBar()" style="dashed"]; node_method_call1 -> node_foo3 [label="setBar()" style="dashed"]; node_method_call1 -> node_foobaz [label="setBar()" style="dashed"]; + node_foo_with_inline -> node_inlined [label="setBar()" style="dashed"]; + node_inlined -> node_foo_with_inline [label="setFoo()" style="dashed"]; } diff --git a/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/php/services9.php b/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/php/services9.php index 19764998f5..92969123e7 100644 --- a/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/php/services9.php +++ b/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/php/services9.php @@ -104,6 +104,23 @@ class ProjectServiceContainer extends Container return new $class(); } + /** + * Gets the 'foo_with_inline' service. + * + * This service is shared. + * This method always returns the same instance of the service. + * + * @return Foo A Foo instance. + */ + protected function getFooWithInlineService() + { + $this->services['foo_with_inline'] = $instance = new \Foo(); + + $instance->setBar($this->get('inlined')); + + return $instance; + } + /** * Gets the 'method_call1' service. * @@ -140,6 +157,28 @@ class ProjectServiceContainer extends Container return $this->get('foo'); } + /** + * Gets the 'inlined' service. + * + * This service is shared. + * This method always returns the same instance of the service. + * + * This service is private. + * If you want to be able to request this service from the container directly, + * make it public, otherwise you might end up with broken code. + * + * @return Bar A Bar instance. + */ + protected function getInlinedService() + { + $this->services['inlined'] = $instance = new \Bar(); + + $instance->setFoo($this->get('foo_with_inline')); + $instance->pub = 'pub'; + + return $instance; + } + /** * Gets the default parameters. * diff --git a/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/php/services9_compiled.php b/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/php/services9_compiled.php index f380070555..0ef72e1c71 100644 --- a/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/php/services9_compiled.php +++ b/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/php/services9_compiled.php @@ -112,6 +112,28 @@ class ProjectServiceContainer extends Container return new \FooClass(); } + /** + * Gets the 'foo_with_inline' service. + * + * This service is shared. + * This method always returns the same instance of the service. + * + * @return Foo A Foo instance. + */ + protected function getFooWithInlineService() + { + $a = new \Bar(); + + $this->services['foo_with_inline'] = $instance = new \Foo(); + + $a->setFoo($instance); + $a->pub = 'pub'; + + $instance->setBar($a); + + return $instance; + } + /** * Gets the 'method_call1' service. * diff --git a/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/xml/services9.xml b/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/xml/services9.xml index 9b935d5845..4c22e6b51f 100644 --- a/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/xml/services9.xml +++ b/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/xml/services9.xml @@ -51,6 +51,17 @@ + + + + + + + pub + + + + diff --git a/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/yaml/services9.yml b/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/yaml/services9.yml index ebd3ed3d1a..ab26425a7d 100644 --- a/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/yaml/services9.yml +++ b/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/yaml/services9.yml @@ -41,4 +41,15 @@ services: class: Bar factory_method: getInstance factory_service: foo.baz + foo_with_inline: + class: Foo + calls: + - [setBar, ['@inlined']] + + inlined: + class: Bar + properties: { pub: pub } + calls: + - [setFoo, ['@foo_with_inline']] + alias_for_foo: @foo