Skip to content

Commit

Permalink
Revert "bug #21436 [DependencyInjection] check for circular refs caus…
Browse files Browse the repository at this point in the history
…ed by method calls (xabbuh)"

This reverts commit 3441b15, reversing
changes made to d1f4cb2.
  • Loading branch information
fabpot committed Feb 16, 2017
1 parent a5c099c commit 68d6415
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 32 deletions.
Expand Up @@ -63,7 +63,6 @@ public function __construct()
new RemoveUnusedDefinitionsPass(),
)),
new CheckExceptionOnInvalidReferenceBehaviorPass(),
new CheckCircularReferencesPass(),
);
}

Expand Down
Expand Up @@ -113,30 +113,4 @@ public function testProcessInlinesWhenThereAreMultipleReferencesButFromTheSameDe
$this->assertFalse($container->hasDefinition('b'));
$this->assertFalse($container->hasDefinition('c'), 'Service C was not inlined.');
}

/**
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
*/
public function testCircularReferencesCausedByMethodCallsAreDetectedDuringCompilation()
{
$container = new ContainerBuilder();
$container->setResourceTracking(false);

$container
->register('foobar', '\stdClass')
->addArgument(new Reference('foo'))
;

$container
->register('foo', '\stdClass')
->addArgument(new Reference('bar'))
;

$container
->register('foo', '\stdClass')
->addMethodCall('addFoobar', array(new Reference('foobar')))
;

$container->compile();
}
}
Expand Up @@ -64,6 +64,7 @@
;
$container
->register('baz', 'Baz')
->addMethodCall('setFoo', array(new Reference('foo_with_inline')))
;
$container
->register('request', 'Request')
Expand Down
Expand Up @@ -36,5 +36,6 @@ digraph sc {
node_method_call1 -> node_foobaz [label="setBar()" style="dashed"];
node_foo_with_inline -> node_inlined [label="setBar()" style="dashed"];
node_inlined -> node_baz [label="setBaz()" style="dashed"];
node_baz -> node_foo_with_inline [label="setFoo()" style="dashed"];
node_configurator_service -> node_baz [label="setFoo()" style="dashed"];
}
Expand Up @@ -80,7 +80,11 @@ protected function getBarService()
*/
protected function getBazService()
{
return $this->services['baz'] = new \Baz();
$this->services['baz'] = $instance = new \Baz();

$instance->setFoo($this->get('foo_with_inline'));

return $instance;
}

/**
Expand Down
Expand Up @@ -99,7 +99,11 @@ protected function getBarService()
*/
protected function getBazService()
{
return $this->services['baz'] = new \Baz();
$this->services['baz'] = $instance = new \Baz();

$instance->setFoo($this->get('foo_with_inline'));

return $instance;
}

/**
Expand Down Expand Up @@ -223,11 +227,12 @@ protected function getFooBarService()
protected function getFooWithInlineService()
{
$a = new \Bar();
$a->pub = 'pub';
$a->setBaz($this->get('baz'));

$this->services['foo_with_inline'] = $instance = new \Foo();

$a->pub = 'pub';
$a->setBaz($this->get('baz'));

$instance->setBar($a);

return $instance;
Expand Down
Expand Up @@ -70,7 +70,11 @@
<argument type="service" id="baz"/>
</call>
</service>
<service id="baz" class="Baz"/>
<service id="baz" class="Baz">
<call method="setFoo">
<argument type="service" id="foo_with_inline"/>
</call>
</service>
<service id="request" class="Request" synthetic="true"/>
<service id="configurator_service" class="ConfClass" public="false">
<call method="setFoo">
Expand Down
Expand Up @@ -52,6 +52,8 @@ services:

baz:
class: Baz
calls:
- [setFoo, ['@foo_with_inline']]

request:
class: Request
Expand Down

0 comments on commit 68d6415

Please sign in to comment.