Skip to content

Commit fb8fd4d

Browse files
[2.6] cleanup deprecated uses
1 parent 3b64fed commit fb8fd4d

8 files changed

+30
-27
lines changed

Compiler/AnalyzeServiceReferencesPass.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,16 @@ public function process(ContainerBuilder $container)
7474
if ($definition->getFactoryService()) {
7575
$this->processArguments(array(new Reference($definition->getFactoryService())));
7676
}
77+
if (is_array($definition->getFactory())) {
78+
$this->processArguments($definition->getFactory());
79+
}
7780

7881
if (!$this->onlyConstructorArguments) {
7982
$this->processArguments($definition->getMethodCalls());
8083
$this->processArguments($definition->getProperties());
8184
if ($definition->getConfigurator()) {
8285
$this->processArguments(array($definition->getConfigurator()));
8386
}
84-
if ($definition->getFactory()) {
85-
$this->processArguments(array($definition->getFactory()));
86-
}
8787
}
8888
}
8989

@@ -115,6 +115,9 @@ private function processArguments(array $arguments)
115115
$this->processArguments($argument->getMethodCalls());
116116
$this->processArguments($argument->getProperties());
117117

118+
if (is_array($argument->getFactory())) {
119+
$this->processArguments($argument->getFactory());
120+
}
118121
if ($argument->getFactoryService()) {
119122
$this->processArguments(array(new Reference($argument->getFactoryService())));
120123
}

Compiler/InlineServiceDefinitionsPass.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ private function isInlineableDefinition(ContainerBuilder $container, $id, Defini
144144
return false;
145145
}
146146

147+
if (count($ids) > 1 && is_array($factory = $definition->getFactory()) && ($factory[0] instanceof Reference || $factory[0] instanceof Definition)) {
148+
return false;
149+
}
150+
147151
if (count($ids) > 1 && $definition->getFactoryService()) {
148152
return false;
149153
}

Compiler/ResolveDefinitionTemplatesPass.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,9 @@ private function resolveDefinition($id, DefinitionDecorator $definition)
8181
$def->setArguments($parentDef->getArguments());
8282
$def->setMethodCalls($parentDef->getMethodCalls());
8383
$def->setProperties($parentDef->getProperties());
84-
if (null !== $parentDef->getFactoryMethod()) {
85-
$def->setFactoryClass($parentDef->getFactoryClass());
86-
$def->setFactoryMethod($parentDef->getFactoryMethod());
87-
$def->setFactoryService($parentDef->getFactoryService());
88-
}
84+
$def->setFactoryClass($parentDef->getFactoryClass());
85+
$def->setFactoryMethod($parentDef->getFactoryMethod());
86+
$def->setFactoryService($parentDef->getFactoryService());
8987
$def->setFactory($parentDef->getFactory());
9088
$def->setConfigurator($parentDef->getConfigurator());
9189
$def->setFile($parentDef->getFile());

Tests/Compiler/AnalyzeServiceReferencesPassTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function testProcessDetectsReferencesFromInlinedFactoryDefinitions()
8787
;
8888

8989
$factory = new Definition();
90-
$factory->setFactoryService('a');
90+
$factory->setFactory(array(new Reference('a'), 'a'));
9191

9292
$container
9393
->register('b')
@@ -124,13 +124,11 @@ public function testProcessDetectsFactoryReferences()
124124

125125
$container
126126
->register('foo', 'stdClass')
127-
->setFactoryClass('stdClass')
128-
->setFactoryMethod('getInstance');
127+
->setFactory(array('stdClass', 'getInstance'));
129128

130129
$container
131130
->register('bar', 'stdClass')
132-
->setFactoryService('foo')
133-
->setFactoryMethod('getInstance');
131+
->setFactory(array(new Reference('foo'), 'getInstance'));
134132

135133
$graph = $this->process($container);
136134

Tests/Compiler/CheckCircularReferencesPassTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,11 @@ public function testProcessWithFactory()
5353

5454
$container
5555
->register('a', 'stdClass')
56-
->setFactoryService('b')
57-
->setFactoryMethod('getInstance');
56+
->setFactory(array(new Reference('b'), 'getInstance'));
5857

5958
$container
6059
->register('b', 'stdClass')
61-
->setFactoryService('a')
62-
->setFactoryMethod('getInstance');
60+
->setFactory(array(new Reference('a'), 'getInstance'));
6361

6462
$this->process($container);
6563
}
@@ -88,8 +86,7 @@ public function testProcessDetectsIndirectCircularReferenceWithFactory()
8886

8987
$container
9088
->register('b', 'stdClass')
91-
->setFactoryService('c')
92-
->setFactoryMethod('getInstance');
89+
->setFactory(array(new Reference('c'), 'getInstance'));
9390

9491
$container->register('c')->addArgument(new Reference('a'));
9592

Tests/Compiler/InlineServiceDefinitionsPassTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function testProcessInlinesPrivateFactoryReference()
118118
$b = $container
119119
->register('b')
120120
->setPublic(false)
121-
->setFactoryService('a')
121+
->setFactory(array(new Reference('a'), 'a'))
122122
;
123123

124124
$container
@@ -142,7 +142,7 @@ public function testProcessDoesNotInlinePrivateFactoryIfReferencedMultipleTimesW
142142
$container
143143
->register('b')
144144
->setPublic(false)
145-
->setFactoryService('a')
145+
->setFactory(array(new Reference('a'), 'a'))
146146
;
147147

148148
$container
@@ -168,12 +168,12 @@ public function testProcessDoesNotInlineReferenceWhenUsedByInlineFactory()
168168
$container
169169
->register('b')
170170
->setPublic(false)
171-
->setFactoryService('a')
171+
->setFactory(array(new Reference('a'), 'a'))
172172
;
173173

174174
$inlineFactory = new Definition();
175175
$inlineFactory->setPublic(false);
176-
$inlineFactory->setFactoryService('b');
176+
$inlineFactory->setFactory(array(new Reference('b'), 'b'));
177177

178178
$container
179179
->register('foo')

Tests/Compiler/RemoveUnusedDefinitionsPassTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,12 @@ public function testProcessWontRemovePrivateFactory()
8686

8787
$container
8888
->register('foo', 'stdClass')
89-
->setFactoryClass('stdClass')
90-
->setFactoryMethod('getInstance')
89+
->setFactory(array('stdClass', 'getInstance'))
9190
->setPublic(false);
9291

9392
$container
9493
->register('bar', 'stdClass')
95-
->setFactoryService('foo')
96-
->setFactoryMethod('getInstance')
94+
->setFactory(array(new Reference('foo'), 'getInstance'))
9795
->setPublic(false);
9896

9997
$container

Tests/LegacyContainerBuilderTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616

1717
class LegacyContainerBuilderTest extends \PHPUnit_Framework_TestCase
1818
{
19+
public function setUp()
20+
{
21+
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
22+
}
23+
1924
/**
2025
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::createService
2126
*/

0 commit comments

Comments
 (0)