diff --git a/UPGRADE-5.1.md b/UPGRADE-5.1.md index eb670c66fcf62..5a232c0af5ad5 100644 --- a/UPGRADE-5.1.md +++ b/UPGRADE-5.1.md @@ -12,6 +12,8 @@ DependencyInjection * The signature of method `Definition::setDeprecated()` has been updated to `Definition::setDeprecation(string $package, string $version, string $message)`. * The signature of method `Alias::setDeprecated()` has been updated to `Alias::setDeprecation(string $package, string $version, string $message)`. * The signature of method `DeprecateTrait::deprecate()` has been updated to `DeprecateTrait::deprecation(string $package, string $version, string $message)`. + * Deprecated the `Psr\Container\ContainerInterface` and `Symfony\Component\DependencyInjection\ContainerInterface` aliases of the `service_container` service, + configure them explicitly instead. Dotenv ------ diff --git a/UPGRADE-6.0.md b/UPGRADE-6.0.md index 570d4d10a5b30..0cd85ac25bfc5 100644 --- a/UPGRADE-6.0.md +++ b/UPGRADE-6.0.md @@ -12,6 +12,8 @@ DependencyInjection * The signature of method `Definition::setDeprecated()` has been updated to `Definition::setDeprecation(string $package, string $version, string $message)`. * The signature of method `Alias::setDeprecated()` has been updated to `Alias::setDeprecation(string $package, string $version, string $message)`. * The signature of method `DeprecateTrait::deprecate()` has been updated to `DeprecateTrait::deprecation(string $package, string $version, string $message)`. + * Removed the `Psr\Container\ContainerInterface` and `Symfony\Component\DependencyInjection\ContainerInterface` aliases of the `service_container` service, + configure them explicitly instead. Dotenv ------ diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSessionDomainConstraintPassTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSessionDomainConstraintPassTest.php index 438a2072ef181..66f942273204f 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSessionDomainConstraintPassTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSessionDomainConstraintPassTest.php @@ -12,10 +12,14 @@ namespace Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Compiler; use PHPUnit\Framework\TestCase; +use Psr\Container\ContainerInterface; use Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension; use Symfony\Bundle\SecurityBundle\DependencyInjection\Compiler\AddSessionDomainConstraintPass; use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension; +use Symfony\Component\DependencyInjection\Alias; +use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\HttpFoundation\Request; class AddSessionDomainConstraintPassTest extends TestCase @@ -148,6 +152,9 @@ private function createContainer($sessionStorageOptions) $pass = new AddSessionDomainConstraintPass(); $pass->process($container); + $container->setDefinition('.service_subscriber.fallback_container', new Definition(Container::class)); + $container->setAlias(ContainerInterface::class, new Alias('.service_subscriber.fallback_container', false)); + return $container; } } diff --git a/src/Symfony/Component/DependencyInjection/CHANGELOG.md b/src/Symfony/Component/DependencyInjection/CHANGELOG.md index f08356ae91837..b245814edb757 100644 --- a/src/Symfony/Component/DependencyInjection/CHANGELOG.md +++ b/src/Symfony/Component/DependencyInjection/CHANGELOG.md @@ -10,6 +10,8 @@ CHANGELOG * updated the signature of method `Definition::setDeprecated()` to `Definition::setDeprecation(string $package, string $version, string $message)` * updated the signature of method `Alias::setDeprecated()` to `Alias::setDeprecation(string $package, string $version, string $message)` * updated the signature of method `DeprecateTrait::deprecate()` to `DeprecateTrait::deprecation(string $package, string $version, string $message)` + * deprecated the `Psr\Container\ContainerInterface` and `Symfony\Component\DependencyInjection\ContainerInterface` aliases of the `service_container` service, + configure them explicitly instead 5.0.0 ----- diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index f5b3cb96e6923..e08e4a141d6ca 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -147,8 +147,8 @@ public function __construct(ParameterBagInterface $parameterBag = null) $this->trackResources = interface_exists('Symfony\Component\Config\Resource\ResourceInterface'); $this->setDefinition('service_container', (new Definition(ContainerInterface::class))->setSynthetic(true)->setPublic(true)); - $this->setAlias(PsrContainerInterface::class, new Alias('service_container', false)); - $this->setAlias(ContainerInterface::class, new Alias('service_container', false)); + $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.'); + $this->setAlias(ContainerInterface::class, new Alias('service_container', false))->setDeprecated('symfony/dependency-injection', '5.1', $deprecationMessage); } /** diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php index ced09157617c3..f0bcd6d7de334 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php @@ -88,8 +88,12 @@ public function testDumpAnonymousServices() - - + + The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + + + The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + ', $dumper->dump()); @@ -107,8 +111,12 @@ public function testDumpEntities() foo<>&bar - - + + The \"%alias_id%\" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + + + The \"%alias_id%\" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + ", $dumper->dump()); @@ -133,8 +141,12 @@ public function provideDecoratedServicesData() - - + + The \"%alias_id%\" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + + + The \"%alias_id%\" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + ", include $fixturesPath.'/containers/container15.php'], @@ -143,8 +155,12 @@ public function provideDecoratedServicesData() - - + + The \"%alias_id%\" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + + + The \"%alias_id%\" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + ", include $fixturesPath.'/containers/container16.php'], @@ -153,8 +169,12 @@ public function provideDecoratedServicesData() - - + + The \"%alias_id%\" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + + + The \"%alias_id%\" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + ", include $fixturesPath.'/containers/container34.php'], diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services1.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services1.xml index 7d8674a30f3fe..2767ea9ea670b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services1.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services1.xml @@ -2,7 +2,11 @@ - - + + The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + + + The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services21.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services21.xml index 20dd4cf47614e..1753449da445c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services21.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services21.xml @@ -18,7 +18,11 @@ - - + + The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + + + The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services24.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services24.xml index 23c91cdc2e99d..95145f3ca4855 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services24.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services24.xml @@ -3,7 +3,11 @@ - - + + The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + + + The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services8.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services8.xml index d817a079a08ed..e8809a7e5605c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services8.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services8.xml @@ -34,7 +34,11 @@ - - + + The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + + + The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml index e3b981c910611..3281f24d70aaa 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml @@ -148,8 +148,12 @@ - - + + The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + + + The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_abstract.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_abstract.xml index 47fd3a53bd767..f72bc14cb857f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_abstract.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_abstract.xml @@ -3,7 +3,11 @@ - - + + The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + + + The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_dump_load.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_dump_load.xml index 7a91166c1fc77..482beae6e1707 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_dump_load.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_dump_load.xml @@ -5,7 +5,11 @@ - - + + The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + + + The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_with_abstract_argument.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_with_abstract_argument.xml index 8a05525f555aa..b881135424928 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_with_abstract_argument.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_with_abstract_argument.xml @@ -6,7 +6,11 @@ should be defined by Pass test - - + + The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + + + The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_with_tagged_arguments.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_with_tagged_arguments.xml index 6992f8432430f..eb66bf33fa939 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_with_tagged_arguments.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_with_tagged_arguments.xml @@ -11,7 +11,11 @@ - - + + The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + + + The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services1.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services1.yml index 071742f2e0519..272d395e02e3d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services1.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services1.yml @@ -6,6 +6,14 @@ services: Psr\Container\ContainerInterface: alias: service_container public: false + deprecated: + package: symfony/dependency-injection + version: 5.1 + message: The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. Symfony\Component\DependencyInjection\ContainerInterface: alias: service_container public: false + deprecated: + package: symfony/dependency-injection + version: 5.1 + message: The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services24.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services24.yml index f59354e3e2509..babe475552d44 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services24.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services24.yml @@ -11,6 +11,14 @@ services: Psr\Container\ContainerInterface: alias: service_container public: false + deprecated: + package: symfony/dependency-injection + version: 5.1 + message: The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. Symfony\Component\DependencyInjection\ContainerInterface: alias: service_container public: false + deprecated: + package: symfony/dependency-injection + version: 5.1 + message: The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services34.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services34.yml index d95e320ac3b5a..6485278356756 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services34.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services34.yml @@ -12,6 +12,14 @@ services: Psr\Container\ContainerInterface: alias: service_container public: false + deprecated: + package: symfony/dependency-injection + version: 5.1 + message: The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. Symfony\Component\DependencyInjection\ContainerInterface: alias: service_container public: false + deprecated: + package: symfony/dependency-injection + version: 5.1 + message: The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services8.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services8.yml index 8c9f7a2902fc2..a3e17cc750a70 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services8.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services8.yml @@ -26,6 +26,14 @@ services: Psr\Container\ContainerInterface: alias: service_container public: false + deprecated: + package: symfony/dependency-injection + version: 5.1 + message: The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. Symfony\Component\DependencyInjection\ContainerInterface: alias: service_container public: false + deprecated: + package: symfony/dependency-injection + version: 5.1 + message: The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml index 960b5b740a7fb..88d271132a749 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml @@ -168,9 +168,17 @@ services: Psr\Container\ContainerInterface: alias: service_container public: false + deprecated: + package: symfony/dependency-injection + version: 5.1 + message: The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. Symfony\Component\DependencyInjection\ContainerInterface: alias: service_container public: false + deprecated: + package: symfony/dependency-injection + version: 5.1 + message: The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. alias_for_foo: alias: 'foo' public: true diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_dump_load.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_dump_load.yml index 9c25cbcbc5835..6b999e90e24cb 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_dump_load.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_dump_load.yml @@ -11,6 +11,14 @@ services: Psr\Container\ContainerInterface: alias: service_container public: false + deprecated: + package: symfony/dependency-injection + version: 5.1 + message: The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. Symfony\Component\DependencyInjection\ContainerInterface: alias: service_container public: false + deprecated: + package: symfony/dependency-injection + version: 5.1 + message: The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_inline.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_inline.yml index b985cabd9649e..6b2bcc5b8af4d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_inline.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_inline.yml @@ -11,6 +11,14 @@ services: Psr\Container\ContainerInterface: alias: service_container public: false + deprecated: + package: symfony/dependency-injection + version: 5.1 + message: The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. Symfony\Component\DependencyInjection\ContainerInterface: alias: service_container public: false + deprecated: + package: symfony/dependency-injection + version: 5.1 + message: The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_with_abstract_argument.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_with_abstract_argument.yml index 02889228c03cf..bd02da57123a1 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_with_abstract_argument.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_with_abstract_argument.yml @@ -10,6 +10,14 @@ services: Psr\Container\ContainerInterface: alias: service_container public: false + deprecated: + package: symfony/dependency-injection + version: 5.1 + message: The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. Symfony\Component\DependencyInjection\ContainerInterface: alias: service_container public: false + deprecated: + package: symfony/dependency-injection + version: 5.1 + message: The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_with_tagged_argument.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_with_tagged_argument.yml index 2b76522827de5..ad36141dae118 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_with_tagged_argument.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_with_tagged_argument.yml @@ -20,6 +20,14 @@ services: Psr\Container\ContainerInterface: alias: service_container public: false + deprecated: + package: symfony/dependency-injection + version: 5.1 + message: The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. Symfony\Component\DependencyInjection\ContainerInterface: alias: service_container public: false + deprecated: + package: symfony/dependency-injection + version: 5.1 + message: The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.