Skip to content

Commit 9591cba

Browse files
committed
[DependencyInjection] Deprecate ContainerInterface aliases
1 parent ff5934d commit 9591cba

21 files changed

+160
-30
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ CHANGELOG
1010
* updated the signature of method `Definition::setDeprecated()` to `Definition::setDeprecation(string $package, string $version, string $message)`
1111
* updated the signature of method `Alias::setDeprecated()` to `Alias::setDeprecation(string $package, string $version, string $message)`
1212
* updated the signature of method `DeprecateTrait::deprecate()` to `DeprecateTrait::deprecation(string $package, string $version, string $message)`
13+
* deprecated the `Psr\Container\ContainerInterface` and `Symfony\Component\DependencyInjection\ContainerInterface` aliases of the `service_container` service,
14+
configure them explicitly instead
1315

1416
5.0.0
1517
-----

ContainerBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ public function __construct(ParameterBagInterface $parameterBag = null)
147147

148148
$this->trackResources = interface_exists('Symfony\Component\Config\Resource\ResourceInterface');
149149
$this->setDefinition('service_container', (new Definition(ContainerInterface::class))->setSynthetic(true)->setPublic(true));
150-
$this->setAlias(PsrContainerInterface::class, new Alias('service_container', false));
151-
$this->setAlias(ContainerInterface::class, new Alias('service_container', false));
150+
$this->setAlias(PsrContainerInterface::class, new Alias('service_container', false))->setDeprecated('symfony/dependency-injection', '5.1', $deprecationMessage = 'The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.');
151+
$this->setAlias(ContainerInterface::class, new Alias('service_container', false))->setDeprecated('symfony/dependency-injection', '5.1', $deprecationMessage);
152152
}
153153

154154
/**

Tests/Dumper/XmlDumperTest.php

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,12 @@ public function testDumpAnonymousServices()
8888
</service>
8989
</argument>
9090
</service>
91-
<service id="Psr\Container\ContainerInterface" alias="service_container" public="false"/>
92-
<service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false"/>
91+
<service id="Psr\Container\ContainerInterface" alias="service_container" public="false">
92+
<deprecated package="symfony/dependency-injection" version="5.1">The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.</deprecated>
93+
</service>
94+
<service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false">
95+
<deprecated package="symfony/dependency-injection" version="5.1">The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.</deprecated>
96+
</service>
9397
</services>
9498
</container>
9599
', $dumper->dump());
@@ -107,8 +111,12 @@ public function testDumpEntities()
107111
<tag name=\"foo&quot;bar\bar\" foo=\"foo&quot;barřž€\"/>
108112
<argument>foo&lt;&gt;&amp;bar</argument>
109113
</service>
110-
<service id=\"Psr\Container\ContainerInterface\" alias=\"service_container\" public=\"false\"/>
111-
<service id=\"Symfony\Component\DependencyInjection\ContainerInterface\" alias=\"service_container\" public=\"false\"/>
114+
<service id=\"Psr\Container\ContainerInterface\" alias=\"service_container\" public=\"false\">
115+
<deprecated package=\"symfony/dependency-injection\" version=\"5.1\">The \"%alias_id%\" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.</deprecated>
116+
</service>
117+
<service id=\"Symfony\Component\DependencyInjection\ContainerInterface\" alias=\"service_container\" public=\"false\">
118+
<deprecated package=\"symfony/dependency-injection\" version=\"5.1\">The \"%alias_id%\" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.</deprecated>
119+
</service>
112120
</services>
113121
</container>
114122
", $dumper->dump());
@@ -133,8 +141,12 @@ public function provideDecoratedServicesData()
133141
<services>
134142
<service id=\"service_container\" class=\"Symfony\Component\DependencyInjection\ContainerInterface\" public=\"true\" synthetic=\"true\"/>
135143
<service id=\"foo\" class=\"FooClass\Foo\" public=\"true\" decorates=\"bar\" decoration-inner-name=\"bar.woozy\"/>
136-
<service id=\"Psr\Container\ContainerInterface\" alias=\"service_container\" public=\"false\"/>
137-
<service id=\"Symfony\Component\DependencyInjection\ContainerInterface\" alias=\"service_container\" public=\"false\"/>
144+
<service id=\"Psr\Container\ContainerInterface\" alias=\"service_container\" public=\"false\">
145+
<deprecated package=\"symfony/dependency-injection\" version=\"5.1\">The \"%alias_id%\" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.</deprecated>
146+
</service>
147+
<service id=\"Symfony\Component\DependencyInjection\ContainerInterface\" alias=\"service_container\" public=\"false\">
148+
<deprecated package=\"symfony/dependency-injection\" version=\"5.1\">The \"%alias_id%\" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.</deprecated>
149+
</service>
138150
</services>
139151
</container>
140152
", include $fixturesPath.'/containers/container15.php'],
@@ -143,8 +155,12 @@ public function provideDecoratedServicesData()
143155
<services>
144156
<service id=\"service_container\" class=\"Symfony\Component\DependencyInjection\ContainerInterface\" public=\"true\" synthetic=\"true\"/>
145157
<service id=\"foo\" class=\"FooClass\Foo\" public=\"true\" decorates=\"bar\"/>
146-
<service id=\"Psr\Container\ContainerInterface\" alias=\"service_container\" public=\"false\"/>
147-
<service id=\"Symfony\Component\DependencyInjection\ContainerInterface\" alias=\"service_container\" public=\"false\"/>
158+
<service id=\"Psr\Container\ContainerInterface\" alias=\"service_container\" public=\"false\">
159+
<deprecated package=\"symfony/dependency-injection\" version=\"5.1\">The \"%alias_id%\" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.</deprecated>
160+
</service>
161+
<service id=\"Symfony\Component\DependencyInjection\ContainerInterface\" alias=\"service_container\" public=\"false\">
162+
<deprecated package=\"symfony/dependency-injection\" version=\"5.1\">The \"%alias_id%\" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.</deprecated>
163+
</service>
148164
</services>
149165
</container>
150166
", include $fixturesPath.'/containers/container16.php'],
@@ -153,8 +169,12 @@ public function provideDecoratedServicesData()
153169
<services>
154170
<service id=\"service_container\" class=\"Symfony\Component\DependencyInjection\ContainerInterface\" public=\"true\" synthetic=\"true\"/>
155171
<service id=\"decorator\" decorates=\"decorated\" decoration-on-invalid=\"null\" decoration-inner-name=\"decorated.inner\" decoration-priority=\"1\"/>
156-
<service id=\"Psr\Container\ContainerInterface\" alias=\"service_container\" public=\"false\"/>
157-
<service id=\"Symfony\Component\DependencyInjection\ContainerInterface\" alias=\"service_container\" public=\"false\"/>
172+
<service id=\"Psr\Container\ContainerInterface\" alias=\"service_container\" public=\"false\">
173+
<deprecated package=\"symfony/dependency-injection\" version=\"5.1\">The \"%alias_id%\" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.</deprecated>
174+
</service>
175+
<service id=\"Symfony\Component\DependencyInjection\ContainerInterface\" alias=\"service_container\" public=\"false\">
176+
<deprecated package=\"symfony/dependency-injection\" version=\"5.1\">The \"%alias_id%\" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.</deprecated>
177+
</service>
158178
</services>
159179
</container>
160180
", include $fixturesPath.'/containers/container34.php'],

Tests/Fixtures/xml/services1.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd">
33
<services>
44
<service class="Symfony\Component\DependencyInjection\ContainerInterface" id="service_container" public="true" synthetic="true"/>
5-
<service alias="service_container" id="Psr\Container\ContainerInterface" public="false"/>
6-
<service alias="service_container" id="Symfony\Component\DependencyInjection\ContainerInterface" public="false"/>
5+
<service alias="service_container" id="Psr\Container\ContainerInterface" public="false">
6+
<deprecated package="symfony/dependency-injection" version="5.1">The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.</deprecated>
7+
</service>
8+
<service alias="service_container" id="Symfony\Component\DependencyInjection\ContainerInterface" public="false">
9+
<deprecated package="symfony/dependency-injection" version="5.1">The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.</deprecated>
10+
</service>
711
</services>
812
</container>

Tests/Fixtures/xml/services21.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
</service>
1919
</configurator>
2020
</service>
21-
<service id="Psr\Container\ContainerInterface" alias="service_container" public="false"/>
22-
<service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false"/>
21+
<service id="Psr\Container\ContainerInterface" alias="service_container" public="false">
22+
<deprecated package="symfony/dependency-injection" version="5.1">The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.</deprecated>
23+
</service>
24+
<service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false">
25+
<deprecated package="symfony/dependency-injection" version="5.1">The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.</deprecated>
26+
</service>
2327
</services>
2428
</container>

Tests/Fixtures/xml/services24.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
<services>
44
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" public="true" synthetic="true"/>
55
<service id="foo" class="Foo" public="true" autowire="true"/>
6-
<service id="Psr\Container\ContainerInterface" alias="service_container" public="false"/>
7-
<service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false"/>
6+
<service id="Psr\Container\ContainerInterface" alias="service_container" public="false">
7+
<deprecated package="symfony/dependency-injection" version="5.1">The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.</deprecated>
8+
</service>
9+
<service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false">
10+
<deprecated package="symfony/dependency-injection" version="5.1">The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.</deprecated>
11+
</service>
812
</services>
913
</container>

Tests/Fixtures/xml/services8.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@
3434
</parameters>
3535
<services>
3636
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" public="true" synthetic="true"/>
37-
<service id="Psr\Container\ContainerInterface" alias="service_container" public="false"/>
38-
<service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false"/>
37+
<service id="Psr\Container\ContainerInterface" alias="service_container" public="false">
38+
<deprecated package="symfony/dependency-injection" version="5.1">The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.</deprecated>
39+
</service>
40+
<service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false">
41+
<deprecated package="symfony/dependency-injection" version="5.1">The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.</deprecated>
42+
</service>
3943
</services>
4044
</container>

Tests/Fixtures/xml/services9.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,12 @@
148148
<argument type="service" id="errored_definition"/>
149149
</service>
150150
<service id="errored_definition" class="stdClass"/>
151-
<service id="Psr\Container\ContainerInterface" alias="service_container" public="false"/>
152-
<service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false"/>
151+
<service id="Psr\Container\ContainerInterface" alias="service_container" public="false">
152+
<deprecated package="symfony/dependency-injection" version="5.1">The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.</deprecated>
153+
</service>
154+
<service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false">
155+
<deprecated package="symfony/dependency-injection" version="5.1">The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.</deprecated>
156+
</service>
153157
<service id="alias_for_foo" alias="foo" public="true"/>
154158
<service id="alias_for_alias" alias="foo" public="true"/>
155159
</services>

Tests/Fixtures/xml/services_abstract.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
<services>
44
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" public="true" synthetic="true"/>
55
<service id="foo" class="Foo" public="true" abstract="true"/>
6-
<service id="Psr\Container\ContainerInterface" alias="service_container" public="false"/>
7-
<service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false"/>
6+
<service id="Psr\Container\ContainerInterface" alias="service_container" public="false">
7+
<deprecated package="symfony/dependency-injection" version="5.1">The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.</deprecated>
8+
</service>
9+
<service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false">
10+
<deprecated package="symfony/dependency-injection" version="5.1">The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.</deprecated>
11+
</service>
812
</services>
913
</container>

Tests/Fixtures/xml/services_dump_load.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
<service id="foo" autoconfigure="true" abstract="true">
66
<argument type="service" id="bar" on-invalid="ignore_uninitialized"/>
77
</service>
8-
<service id="Psr\Container\ContainerInterface" alias="service_container" public="false"/>
9-
<service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false"/>
8+
<service id="Psr\Container\ContainerInterface" alias="service_container" public="false">
9+
<deprecated package="symfony/dependency-injection" version="5.1">The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.</deprecated>
10+
</service>
11+
<service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false">
12+
<deprecated package="symfony/dependency-injection" version="5.1">The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.</deprecated>
13+
</service>
1014
</services>
1115
</container>

0 commit comments

Comments
 (0)