Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 61a67ec

Browse filesBrowse files
committed
bug #21072 [DI] Fix method autowiring in ResolveDefinitionTemplatesPass (dunglas)
This PR was merged into the 3.3-dev branch. Discussion ---------- [DI] Fix method autowiring in ResolveDefinitionTemplatesPass | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a cc @nicolas-grekas Commits ------- 57661e4 [DI] Fix method autowiring in ResolveDefinitionTemplatesPass
2 parents ba932ae + 57661e4 commit 61a67ec
Copy full SHA for 61a67ec

File tree

5 files changed

+21
-20
lines changed
Filter options

5 files changed

+21
-20
lines changed

‎src/Symfony/Component/DependencyInjection/ChildDefinition.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/ChildDefinition.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,11 @@ public function setDeprecated($boolean = true, $template = null)
137137
/**
138138
* {@inheritdoc}
139139
*/
140-
public function setAutowired($autowired)
140+
public function setAutowiredMethods(array $autowiredMethods)
141141
{
142-
$this->changes['autowire'] = true;
142+
$this->changes['autowired_methods'] = true;
143143

144-
return parent::setAutowired($autowired);
144+
return parent::setAutowiredMethods($autowiredMethods);
145145
}
146146

147147
/**

‎src/Symfony/Component/DependencyInjection/Compiler/ResolveDefinitionTemplatesPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/ResolveDefinitionTemplatesPass.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ private function doResolveDefinition(ContainerBuilder $container, ChildDefinitio
141141
$def->setFile($parentDef->getFile());
142142
$def->setPublic($parentDef->isPublic());
143143
$def->setLazy($parentDef->isLazy());
144-
$def->setAutowired($parentDef->isAutowired());
144+
$def->setAutowiredMethods($parentDef->getAutowiredMethods());
145145

146146
// overwrite with values specified in the decorator
147147
$changes = $definition->getChanges();
@@ -166,8 +166,8 @@ private function doResolveDefinition(ContainerBuilder $container, ChildDefinitio
166166
if (isset($changes['deprecated'])) {
167167
$def->setDeprecated($definition->isDeprecated(), $definition->getDeprecationMessage('%service_id%'));
168168
}
169-
if (isset($changes['autowire'])) {
170-
$def->setAutowired($definition->isAutowired());
169+
if (isset($changes['autowired_methods'])) {
170+
$def->setAutowiredMethods($definition->getAutowiredMethods());
171171
}
172172
if (isset($changes['decorated_service'])) {
173173
$decoratedService = $definition->getDecoratedService();
@@ -199,7 +199,7 @@ private function doResolveDefinition(ContainerBuilder $container, ChildDefinitio
199199
}
200200

201201
// append method calls
202-
if (count($calls = $definition->getMethodCalls()) > 0) {
202+
if ($calls = $definition->getMethodCalls()) {
203203
$def->setMethodCalls(array_merge($def->getMethodCalls(), $calls));
204204
}
205205

‎src/Symfony/Component/DependencyInjection/Tests/ChildDefinitionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/ChildDefinitionTest.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ public function testSetLazy()
7070
$this->assertSame(array('lazy' => true), $def->getChanges());
7171
}
7272

73-
public function testSetAutowired()
73+
public function testSetAutowiredMethods()
7474
{
7575
$def = new ChildDefinition('foo');
7676

7777
$this->assertFalse($def->isAutowired());
78-
$this->assertSame($def, $def->setAutowired(false));
79-
$this->assertFalse($def->isAutowired());
80-
$this->assertSame(array('autowire' => true), $def->getChanges());
78+
$this->assertSame($def, $def->setAutowiredMethods(array('foo', 'bar')));
79+
$this->assertEquals(array('foo', 'bar'), $def->getAutowiredMethods());
80+
$this->assertSame(array('autowired_methods' => true), $def->getChanges());
8181
}
8282

8383
public function testSetArgument()

‎src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveDefinitionTemplatesPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveDefinitionTemplatesPassTest.php
+6-5Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,30 +214,31 @@ public function testSetAutowiredOnServiceHasParent()
214214
{
215215
$container = new ContainerBuilder();
216216

217-
$container->register('parent', 'stdClass');
217+
$container->register('parent', 'stdClass')
218+
->setAutowiredMethods(array('foo', 'bar'));
218219

219220
$container->setDefinition('child1', new ChildDefinition('parent'))
220-
->setAutowired(true)
221+
->setAutowiredMethods(array('baz'))
221222
;
222223

223224
$this->process($container);
224225

225-
$this->assertTrue($container->getDefinition('child1')->isAutowired());
226+
$this->assertEquals(array('baz'), $container->getDefinition('child1')->getAutowiredMethods());
226227
}
227228

228229
public function testSetAutowiredOnServiceIsParent()
229230
{
230231
$container = new ContainerBuilder();
231232

232233
$container->register('parent', 'stdClass')
233-
->setAutowired(true)
234+
->setAutowiredMethods(array('__construct', 'set*'))
234235
;
235236

236237
$container->setDefinition('child1', new ChildDefinition('parent'));
237238

238239
$this->process($container);
239240

240-
$this->assertTrue($container->getDefinition('child1')->isAutowired());
241+
$this->assertEquals(array('__construct', 'set*'), $container->getDefinition('child1')->getAutowiredMethods());
241242
}
242243

243244
public function testDeepDefinitionsResolving()

‎src/Symfony/Component/DependencyInjection/Tests/DefinitionDecoratorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/DefinitionDecoratorTest.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ public function testSetLazy()
7272
$this->assertEquals(array('lazy' => true), $def->getChanges());
7373
}
7474

75-
public function testSetAutowired()
75+
public function testSetAutowiredMethods()
7676
{
7777
$def = new DefinitionDecorator('foo');
7878

7979
$this->assertFalse($def->isAutowired());
80-
$this->assertSame($def, $def->setAutowired(false));
81-
$this->assertFalse($def->isAutowired());
82-
$this->assertEquals(array('autowire' => true), $def->getChanges());
80+
$this->assertSame($def, $def->setAutowiredMethods(array('foo', 'bar')));
81+
$this->assertEquals(array('foo', 'bar'), $def->getAutowiredMethods());
82+
$this->assertEquals(array('autowired_methods' => true), $def->getChanges());
8383
}
8484

8585
public function testSetArgument()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.