Skip to content

Commit 68d6415

Browse files
committed
Revert "bug #21436 [DependencyInjection] check for circular refs caused by method calls (xabbuh)"
This reverts commit 3441b15, reversing changes made to d1f4cb2.
1 parent a5c099c commit 68d6415

File tree

8 files changed

+22
-32
lines changed

8 files changed

+22
-32
lines changed

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

-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ public function __construct()
6363
new RemoveUnusedDefinitionsPass(),
6464
)),
6565
new CheckExceptionOnInvalidReferenceBehaviorPass(),
66-
new CheckCircularReferencesPass(),
6766
);
6867
}
6968

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

-26
Original file line numberDiff line numberDiff line change
@@ -113,30 +113,4 @@ public function testProcessInlinesWhenThereAreMultipleReferencesButFromTheSameDe
113113
$this->assertFalse($container->hasDefinition('b'));
114114
$this->assertFalse($container->hasDefinition('c'), 'Service C was not inlined.');
115115
}
116-
117-
/**
118-
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
119-
*/
120-
public function testCircularReferencesCausedByMethodCallsAreDetectedDuringCompilation()
121-
{
122-
$container = new ContainerBuilder();
123-
$container->setResourceTracking(false);
124-
125-
$container
126-
->register('foobar', '\stdClass')
127-
->addArgument(new Reference('foo'))
128-
;
129-
130-
$container
131-
->register('foo', '\stdClass')
132-
->addArgument(new Reference('bar'))
133-
;
134-
135-
$container
136-
->register('foo', '\stdClass')
137-
->addMethodCall('addFoobar', array(new Reference('foobar')))
138-
;
139-
140-
$container->compile();
141-
}
142116
}

src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
;
6565
$container
6666
->register('baz', 'Baz')
67+
->addMethodCall('setFoo', array(new Reference('foo_with_inline')))
6768
;
6869
$container
6970
->register('request', 'Request')

src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services9.dot

+1
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ digraph sc {
3636
node_method_call1 -> node_foobaz [label="setBar()" style="dashed"];
3737
node_foo_with_inline -> node_inlined [label="setBar()" style="dashed"];
3838
node_inlined -> node_baz [label="setBaz()" style="dashed"];
39+
node_baz -> node_foo_with_inline [label="setFoo()" style="dashed"];
3940
node_configurator_service -> node_baz [label="setFoo()" style="dashed"];
4041
}

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ protected function getBarService()
8080
*/
8181
protected function getBazService()
8282
{
83-
return $this->services['baz'] = new \Baz();
83+
$this->services['baz'] = $instance = new \Baz();
84+
85+
$instance->setFoo($this->get('foo_with_inline'));
86+
87+
return $instance;
8488
}
8589

8690
/**

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php

+8-3
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ protected function getBarService()
9999
*/
100100
protected function getBazService()
101101
{
102-
return $this->services['baz'] = new \Baz();
102+
$this->services['baz'] = $instance = new \Baz();
103+
104+
$instance->setFoo($this->get('foo_with_inline'));
105+
106+
return $instance;
103107
}
104108

105109
/**
@@ -223,11 +227,12 @@ protected function getFooBarService()
223227
protected function getFooWithInlineService()
224228
{
225229
$a = new \Bar();
226-
$a->pub = 'pub';
227-
$a->setBaz($this->get('baz'));
228230

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

233+
$a->pub = 'pub';
234+
$a->setBaz($this->get('baz'));
235+
231236
$instance->setBar($a);
232237

233238
return $instance;

src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml

+5-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@
7070
<argument type="service" id="baz"/>
7171
</call>
7272
</service>
73-
<service id="baz" class="Baz"/>
73+
<service id="baz" class="Baz">
74+
<call method="setFoo">
75+
<argument type="service" id="foo_with_inline"/>
76+
</call>
77+
</service>
7478
<service id="request" class="Request" synthetic="true"/>
7579
<service id="configurator_service" class="ConfClass" public="false">
7680
<call method="setFoo">

src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ services:
5252

5353
baz:
5454
class: Baz
55+
calls:
56+
- [setFoo, ['@foo_with_inline']]
5557

5658
request:
5759
class: Request

0 commit comments

Comments
 (0)