10000 [DI] Deprecate autowiring-types in favor of aliases · symfony/symfony@4366566 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4366566

Browse files
[DI] Deprecate autowiring-types in favor of aliases
1 parent b4ff1c8 commit 4366566

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+199
-175
lines changed

UPGRADE-3.3.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Debug
1414
DependencyInjection
1515
-------------------
1616

17+
* Autoriwing-types have been deprecated, use aliases instead.
18+
1719
* The `Reference` and `Alias` classes do not make service identifiers lowercase anymore.
1820

1921
* Case insensitivity of service identifiers is deprecated and will be removed in 4.0.

UPGRADE-4.0.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ Debug
2424
DependencyInjection
2525
-------------------
2626

27+
* Autoriwing-types have been removed, use aliases instead.
28+
2729
* Service identifiers are now case sensitive.
2830

2931
* The `Reference` and `Alias` classes do not make service identifiers lowercase anymore.

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,9 @@ private function getContainerDefinitionData(Definition $definition, $omitTags =
220220
'shared' => $definition->isShared(),
221221
'abstract' => $definition->isAbstract(),
222222
'autowire' => $definition->isAutowired(),
223-
'autowiring_types' => array(),
224223
);
225224

226-
foreach ($definition->getAutowiringTypes() as $autowiringType) {
225+
foreach ($definition->getAutowiringTypes(false) as $autowiringType) {
227226
$data['autowiring_types'][] = $autowiringType;
228227
}
229228

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ protected function describeContainerDefinition(Definition $definition, array $op
185185
."\n".'- Autowired: '.($definition->isAutowired() ? 'yes' : 'no')
186186
;
187187

188-
foreach ($definition->getAutowiringTypes() as $autowiringType) {
188+
foreach ($definition->getAutowiringTypes(false) as $autowiringType) {
189189
$output .= "\n" . '- Autowiring Type: `' . $autowiringType . '`';
190190
}
191191

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,9 @@ protected function describeContainerDefinition(Definition $definition, array $op
294294
$tableRows[] = array('Abstract', $definition->isAbstract() ? 'yes' : 'no');
295295
$tableRows[] = array('Autowired', $definition->isAutowired() ? 'yes' : 'no');
296296

297-
$autowiringTypes = $definition->getAutowiringTypes();
298-
$tableRows[] = array('Autowiring Types', $autowiringTypes ? implode(', ', $autowiringTypes) : '-');
297+
if ($autowiringTypes = $definition->getAutowiringTypes(false)) {
298+
$tableRows[] = array('Autowiring Types', implode(', ', $autowiringTypes));
299+
}
299300

300301
if ($definition->getFile()) {
301302
$tableRows[] = array('Required File', $definition->getFile() ? $definition->getFile() : '-');

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TemplatingPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ public function process(ContainerBuilder $container)
2525
}
2626

2727
if ($container->hasAlias('templating')) {
28-
$definition = $container->findDefinition('templating');
29-
$definition->setAutowiringTypes(array(ComponentEngineInterface::class, FrameworkBundleEngineInterface::class));
28+
$container->setAlias(ComponentEngineInterface::class, 'templating');
29+
$container->setAlias(FrameworkBundleEngineInterface::class, 'templating');
3030
}
3131

3232
if ($container->hasDefinition('templating.engine.php')) {

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1096,8 +1096,8 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
10961096
->getDefinition('annotations.cached_reader')
10971097
->replaceArgument(1, new Reference($cacheService))
10981098
->replaceArgument(2, $config['debug'])
1099-
->addAutowiringType(Reader::class)
11001099
;
1100+
$container->setAlias(Reader::class, new Alias('annotations.cached_reader', false));
11011101
} else {
11021102
$container->removeDefinition('annotations.cached_reader');
11031103
}

src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
66

77
<services>
8-
<service id="annotations.reader" class="Doctrine\Common\Annotations\AnnotationReader" public="false">
9-
<autowiring-type>Doctrine\Common\Annotations\Reader</autowiring-type>
10-
</service>
8+
<service id="annotations.reader" class="Doctrine\Common\Annotations\AnnotationReader" public="false" />
9+
<service id="Doctrine\Common\Annotations\Reader" alias="annotations.reader" public="false" />
1110

1211
<service id="annotations.cached_reader" class="Doctrine\Common\Annotations\CachedReader" public="false">
1312
<argument type="service" id="annotations.reader" />

src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<services>
88
<service id="event_dispatcher" class="Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher">
99
<argument type="service" id="service_container" />
10-
<autowiring-type>Symfony\Component\EventDispatcher\EventDispatcherInterface</autowiring-type>
11-
<autowiring-type>Symfony\Component\EventDispatcher\EventDispatcher</autowiring-type>
1210
</service>
11+
<service id="Symfony\Component\EventDispatcher\EventDispatcherInterface" alias="event_dispatcher" />
12+
<service id="Symfony\Component\EventDispatcher\EventDispatcher" alias="event_dispatcher" />
1313

1414
<service id="http_kernel" class="Symfony\Component\HttpKernel\HttpKernel">
1515
<argument type="service" id="event_dispatcher" />
@@ -40,10 +40,9 @@
4040
<argument type="collection" />
4141
</service>
4242

43-
<service id="service_container" synthetic="true">
44-
<autowiring-type>Symfony\Component\DependencyInjection\ContainerInterface</autowiring-type>
45-
<autowiring-type>Symfony\Component\DependencyInjection\Container</autowiring-type>
46-
</service>
43+
<service id="service_container" synthetic="true" />
44+
<service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" />
45+
<service id="Symfony\Component\DependencyInjection\Container" alias="service_container" />
4746

4847
<service id="kernel" synthetic="true" />
4948

src/Symfony/Bundle/FrameworkBundle/Resources/config/translation.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717
<call method="setConfigCacheFactory">
1818
<argument type="service" id="config_cache_factory" />
1919
</call>
20-
21-
<autowiring-type>Symfony\Component\Translation\TranslatorInterface</autowiring-type>
2220
</service>
21+
<service id="Symfony\Component\Translation\TranslatorInterface" alias="translator.default" />
2322

2423
<service id="translator.logging" class="Symfony\Component\Translation\LoggingTranslator" public="false">
2524
<argument type="service" id="translator.logging.inner" />

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_with_definition_1.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"shared": true,
1212
"abstract": true,
1313
"autowire": false,
14-
"autowiring_types": [],
1514
"file": null,
1615
"factory_class": "Full\\Qualified\\FactoryClass",
1716
"factory_method": "get",

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_with_definition_1.txt

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,18 @@
33
Information for Service "service_1"
44
===================================
55

6-
------------------ -----------------------------
7-
 Option   Value 
8-
------------------ -----------------------------
9-
Service ID service_1
10-
Class Full\Qualified\Class1
11-
Tags -
12-
Public yes
13-
Synthetic no
14-
Lazy yes
15-
Shared yes
16-
Abstract yes
17-
Autowired no
18-
Autowiring Types -
19-
Factory Class Full\Qualified\FactoryClass
20-
Factory Method get
21-
------------------ -----------------------------
6+
---------------- -----------------------------
7+
 Option   Value 
8+
---------------- -----------------------------
9 341A +
Service ID service_1
10+
Class Full\Qualified\Class1
11+
Tags -
12+
Public yes
13+
Synthetic no
14+
Lazy yes
15+
Shared yes
16+
Abstract yes
17+
Autowired no
18+
Factory Class Full\Qualified\FactoryClass
19+
Factory Method get
20+
---------------- -----------------------------

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_with_definition_2.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"shared": true,
1212
"abstract": false,
1313
"autowire": false,
14-
"autowiring_types": [],
1514
"file": "\/path\/to\/file",
1615
"factory_service": "factory.service",
1716
"factory_method": "get",

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_with_definition_2.txt

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,22 @@
33
Information for Service "service_2"
44
===================================
55

6-
------------------ ---------------------------------
7-
 Option   Value 
8-
------------------ ---------------------------------
9-
Service ID service_2
10-
Class Full\Qualified\Class2
11-
Tags tag1 (attr1: val1, attr2: val2)
12-
tag1 (attr3: val3)
13-
tag2
14-
Calls setMailer
15-
Public no
16-
Synthetic yes
17-
Lazy no
18-
Shared yes
19-
Abstract no
20-
Autowired no
21-
Autowiring Types -
22-
Required File /path/to/file
23-
Factory Service factory.service
24-
Factory Method get
25-
------------------ ---------------------------------
6+
----------------- ---------------------------------
7+
 Option   Value 
8+
----------------- ---------------------------------
9+
Service ID service_2
10+
Class Full\Qualified\Class2
11+
Tags tag1 (attr1: val1, attr2: val2)
12+
tag1 (attr3: val3)
13+
tag2
14+
Calls setMailer
15+
Public no
16+
Synthetic yes
17+
Lazy no
18+
Shared yes
19+
Abstract no
20+
Autowired no
21+
Required File /path/to/file
22+
Factory Service factory.service
23+
Factory Method get
24+
----------------- ---------------------------------

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
],
1616
"autowire": false,
17-
"autowiring_types": [],
1817
"arguments": [
1918
{
2019
"type": "service",
@@ -29,7 +28,6 @@
2928
"shared": true,
3029
"abstract": false,
3130
"autowire": false,
32-
"autowiring_types": [],
3331
"arguments": [
3432
"arg1",
3533
"arg2"

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
"tags": [
1414

1515
],
16-
"autowire": false,
17-
"autowiring_types": []
16+
"autowire": false
1817
}
1918
},
2019
"aliases": {

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
"tags": [
1414

1515
],
16-
"autowire": false,
17-
"autowiring_types": []
16+
"autowire": false
1817
},
1918
"definition_2": {
2019
"class": "Full\\Qualified\\Class2",
@@ -50,8 +49,7 @@
5049
"calls": [
5150
"setMailer"
5251
],
53-
"autowire": false,
54-
"autowiring_types": []
52+
"autowire": false
5553
}
5654
},
5755
"aliases": {

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434
"calls": [
3535
"setMailer"
3636
],
37-
"autowire": false,
38-
"autowiring_types": []
37+
"autowire": false
3938
}
4039
},
4140
"aliases": [

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tags.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
],
1414
"factory_service": "factory.service",
1515
"factory_method": "get",
16-
"autowire": false,
17-
"autowiring_types": []
16+
"autowire": false
1817
}
1918
],
2019
"tag2": [
@@ -31,8 +30,7 @@
3130
],
3231
"factory_service": "factory.service",
3332
"factory_method": "get",
34-
"autowire": false,
35-
"autowiring_types": []
33+
"autowire": false
3634
}
3735
]
3836
}

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@
1111
"tags": [
1212

1313
],
14-
"autowire": false,
15-
"autowiring_types": []
14+
"autowire": false
1615
}
Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
------------------ -----------------------------
2-
 Option   Value 
3-
------------------ -----------------------------
4-
Service ID -
5-
Class Full\Qualified\Class1
6-
Tags -
7-
Public yes
8-
Synthetic no
9-
Lazy yes
10-
Shared yes
11-
Abstract yes
12-
Autowired no
13-
Autowiring Types -
14-
Factory Class Full\Qualified\FactoryClass
15-
Factory Method get
16-
------------------ -----------------------------
< 10000 div aria-hidden="true" style="left:-2px" class="position-absolute top-0 d-flex user-select-none DiffLineTableCellParts-module__in-progress-comment-indicator--hx3m3">
1+
---------------- -----------------------------
2+
 Option   Value 
3+
---------------- -----------------------------
4+
Service ID -
5+
Class Full\Qualified\Class1
6+
Tags -
7+
Public yes
8+
Synthetic no
9+
Lazy yes
10+
Shared yes
11+
Abstract yes
12+
Autowired no
13+
Factory Class Full\Qualified\FactoryClass
14+
Factory Method get
15+
---------------- -----------------------------
1716

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,5 @@
3232
"calls": [
3333
"setMailer"
3434
],
35-
"autowire": false,
36-
"autowiring_types": []
35+
"autowire": false
3736
}
Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
------------------ ---------------------------------
2-
 Option   Value 
3-
------------------ ---------------------------------
4-
Service ID -
5-
Class Full\Qualified\Class2
6-
Tags tag1 (attr1: val1, attr2: val2)
7-
tag1 (attr3: val3)
8-
tag2
9-
Calls setMailer
10-
Public no
11-
Synthetic yes
12-
Lazy no
13-
Shared yes
14-
Abstract no
15-
Autowired no
16-
Autowiring Types -
17-
Required File /path/to/file
18-
Factory Service factory.service
19-
Factory Method get
20-
------------------ ---------------------------------
1+
----------------- ---------------------------------
2+
 Option   Value 
3+
----------------- ---------------------------------
4+
Service ID -
5+
Class Full\Qualified\Class2
6+
Tags tag1 (attr1: val1, attr2: val2)
7+
tag1 (attr3: val3)
8+
tag2
9+
Calls setMailer
10+
Public no
11+
Synthetic yes
12+
Lazy no
13+
Shared yes
14+
Abstract no
15+
Autowired no
16+
Required File /path/to/file
17+
Factory Service factory.service
18+
Factory Method get
19+
----------------- ---------------------------------
2120

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"shared": true,
77
"abstract": true,
88
"autowire": false,
9-
"autowiring_types": [],
109
"arguments": [
1110
{
1211
"type": "service",
@@ -21,7 +20,6 @@
2120
"shared": true,
2221
"abstract": false,
2322
"autowire": false,
24-
"autowiring_types": [],
2523
"arguments": [
2624
"arg1",
2725
"arg2"

0 commit comments

Comments
 (0)
0