Skip to content

Commit 0fdf5eb

Browse files
feature #50578 [DependencyInjection] Remove deprecations across the component (alexandre-daubois)
This PR was merged into the 7.0 branch. Discussion ---------- [DependencyInjection] Remove deprecations across the component | Q | A | ------------- | --- | Branch? | 7.0 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - * Remove `#[MapDecorated]`, use `#[AutowireDecorated]` instead * Remove `ProxyHelper`, use `Symfony\Component\VarExporter\ProxyHelper` instead * Remove `ReferenceSetArgumentTrait` * Remove support of ``@required`` annotation, use the `Symfony\Contracts\Service\Attribute\Required` attribute instead * Passing `null` to `ContainerAwareTrait::setContainer()` must be done explicitly * Remove `PhpDumper` options `inline_factories_parameter` and `inline_class_loader_parameter`, use options `inline_factories` and `inline_class_loader` instead * Parameter names of `ParameterBag` cannot be numerics * Remove `ContainerAwareInterface` and `ContainerAwareTrait`, use dependency injection instead * Remove `ContainerAwareLoader`, use dependency injection in your fixtures instead Commits ------- cc4ef49 [DependencyInjection] Remove deprecations across the component
2 parents 21096e6 + cc4ef49 commit 0fdf5eb

Some content is hidden

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

45 files changed

+125
-1260
lines changed

.github/expected-missing-return-types.diff

Lines changed: 18 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,6 @@ index b275304d7d..48ba999884 100644
6060
+ public function getTime(): int
6161
{
6262
$time = 0;
63-
diff --git a/src/Symfony/Bridge/Doctrine/DataFixtures/ContainerAwareLoader.php b/src/Symfony/Bridge/Doctrine/DataFixtures/ContainerAwareLoader.php
64-
index 448da935d9..06c97eb70c 100644
65-
--- a/src/Symfony/Bridge/Doctrine/DataFixtures/ContainerAwareLoader.php
66-
+++ b/src/Symfony/Bridge/Doctrine/DataFixtures/ContainerAwareLoader.php
67-
@@ -40,5 +40,5 @@ class ContainerAwareLoader extends Loader
68-
* @return void
69-
*/
70-
- public function addFixture(FixtureInterface $fixture)
71-
+ public function addFixture(FixtureInterface $fixture): void
72-
{
73-
if ($fixture instanceof ContainerAwareInterface) {
7463
diff --git a/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php b/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php
7564
index 1ce0ffd40c..585265fb38 100644
7665
--- a/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php
@@ -566,17 +555,17 @@ index 94b95e5029..c8a563163e 100644
566555
{
567556
if (!$configuration) {
568557
diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Application.php b/src/Symfony/Bundle/FrameworkBundle/Console/Application.php
569-
index 02709ba649..5a3e972793 100644
558+
index 0451b31fe1..14806da8ee 100644
570559
--- a/src/Symfony/Bundle/FrameworkBundle/Console/Application.php
571560
+++ b/src/Symfony/Bundle/FrameworkBundle/Console/Application.php
572-
@@ -56,5 +56,5 @@ class Application extends BaseApplication
561+
@@ -55,5 +55,5 @@ class Application extends BaseApplication
573562
* @return void
574563
*/
575564
- public function reset()
576565
+ public function reset(): void
577566
{
578567
if ($this->kernel->getContainer()->has('services_resetter')) {
579-
@@ -145,5 +145,5 @@ class Application extends BaseApplication
568+
@@ -137,5 +137,5 @@ class Application extends BaseApplication
580569
* @return void
581570
*/
582571
- protected function registerCommands()
@@ -3733,10 +3722,10 @@ index 3f070dcc0c..aa0e5186bf 100644
37333722
{
37343723
foreach ($container->findTaggedServiceIds('auto_alias') as $serviceId => $tags) {
37353724
diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php
3736-
index e28b60c6ea..a5b3d3d00b 100644
3725+
index 3e94ed1b2c..1fd3fa27ea 100644
37373726
--- a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php
37383727
+++ b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php
3739-
@@ -73,5 +73,5 @@ class AutowirePass extends AbstractRecursivePass
3728+
@@ -72,5 +72,5 @@ class AutowirePass extends AbstractRecursivePass
37403729
* @return void
37413730
*/
37423731
- public function process(ContainerBuilder $container)
@@ -4190,27 +4179,6 @@ index 3ea2228b94..f1d7078383 100644
41904179
+ protected function load(string $file): mixed
41914180
{
41924181
return require $file;
4193-
diff --git a/src/Symfony/Component/DependencyInjection/ContainerAwareInterface.php b/src/Symfony/Component/DependencyInjection/ContainerAwareInterface.php
4194-
index 9b3709c965..97b54712c9 100644
4195-
--- a/src/Symfony/Component/DependencyInjection/ContainerAwareInterface.php
4196-
+++ b/src/Symfony/Component/DependencyInjection/ContainerAwareInterface.php
4197-
@@ -26,4 +26,4 @@ interface ContainerAwareInterface
4198-
* @return void
4199-
*/
4200-
- public function setContainer(?ContainerInterface $container);
4201-
+ public function setContainer(?ContainerInterface $container): void;
4202-
}
4203-
diff --git a/src/Symfony/Component/DependencyInjection/ContainerAwareTrait.php b/src/Symfony/Component/DependencyInjection/ContainerAwareTrait.php
4204-
index 4174fec8d0..f6a7b2da12 100644
4205-
--- a/src/Symfony/Component/DependencyInjection/ContainerAwareTrait.php
4206-
+++ b/src/Symfony/Component/DependencyInjection/ContainerAwareTrait.php
4207-
@@ -31,5 +31,5 @@ trait ContainerAwareTrait
4208-
* @return void
4209-
*/
4210-
- public function setContainer(ContainerInterface $container = null)
4211-
+ public function setContainer(ContainerInterface $container = null): void
4212-
{
4213-
if (1 > \func_num_args()) {
42144182
diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php
42154183
index a7a9c145aa..bd16e937ca 100644
42164184
--- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php
@@ -4631,52 +4599,52 @@ index 1ede090384..7b6b63c599 100644
46314599
{
46324600
throw new LogicException('Impossible to call remove() on a frozen ParameterBag.');
46334601
diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php
4634-
index c1cd9087f0..a9efa77a6d 100644
4602+
index 40447dbbcb..9d0cd64d85 100644
46354603
--- a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php
46364604
+++ b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php
4637-
@@ -35,5 +35,5 @@ class ParameterBag implements ParameterBagInterface
4605+
@@ -36,5 +36,5 @@ class ParameterBag implements ParameterBagInterface
46384606
* @return void
46394607
*/
46404608
- public function clear()
46414609
+ public function clear(): void
46424610
{
46434611
$this->parameters = [];
4644-
@@ -43,5 +43,5 @@ class ParameterBag implements ParameterBagInterface
4612+
@@ -44,5 +44,5 @@ class ParameterBag implements ParameterBagInterface
46454613
* @return void
46464614
*/
46474615
- public function add(array $parameters)
46484616
+ public function add(array $parameters): void
46494617
{
46504618
foreach ($parameters as $key => $value) {
4651-
@@ -104,5 +104,5 @@ class ParameterBag implements ParameterBagInterface
4619+
@@ -105,5 +105,5 @@ class ParameterBag implements ParameterBagInterface
46524620
* @return void
46534621
*/
46544622
- public function set(string $name, array|bool|string|int|float|\UnitEnum|null $value)
46554623
+ public function set(string $name, array|bool|string|int|float|\UnitEnum|null $value): void
46564624
{
46574625
if (is_numeric($name)) {
4658-
@@ -122,5 +122,5 @@ class ParameterBag implements ParameterBagInterface
4626+
@@ -121,5 +121,5 @@ class ParameterBag implements ParameterBagInterface
46594627
* @throws ParameterNotFoundException if the parameter is not defined
46604628
*/
46614629
- public function deprecate(string $name, string $package, string $version, string $message = 'The parameter "%s" is deprecated.')
46624630
+ public function deprecate(string $name, string $package, string $version, string $message = 'The parameter "%s" is deprecated.'): void
46634631
{
46644632
if (!\array_key_exists($name, $this->parameters)) {
4665-
@@ -139,5 +139,5 @@ class ParameterBag implements ParameterBagInterface
4633+
@@ -138,5 +138,5 @@ class ParameterBag implements ParameterBagInterface
46664634
* @return void
46674635
*/
46684636
- public function remove(string $name)
46694637
+ public function remove(string $name): void
46704638
{
46714639
unset($this->parameters[$name], $this->deprecatedParameters[$name]);
4672-
@@ -147,5 +147,5 @@ class ParameterBag implements ParameterBagInterface
4640+
@@ -146,5 +146,5 @@ class ParameterBag implements ParameterBagInterface
46734641
* @return void
46744642
*/
46754643
- public function resolve()
46764644
+ public function resolve(): void
46774645
{
46784646
if ($this->resolved) {
4679-
@@ -259,5 +259,5 @@ class ParameterBag implements ParameterBagInterface
4647+
@@ -258,5 +258,5 @@ class ParameterBag implements ParameterBagInterface
46804648
* @return bool
46814649
*/
46824650
- public function isResolved()
@@ -8297,31 +8265,31 @@ index af21469b1c..7b024368c5 100644
82978265
{
82988266
}
82998267
diff --git a/src/Symfony/Component/HttpKernel/Bundle/BundleInterface.php b/src/Symfony/Component/HttpKernel/Bundle/BundleInterface.php
8300-
index fe200629f4..692c41ec53 100644
8268+
index 400a9e0c92..870cbe80e5 100644
83018269
--- a/src/Symfony/Component/HttpKernel/Bundle/BundleInterface.php
83028270
+++ b/src/Symfony/Component/HttpKernel/Bundle/BundleInterface.php
8303-
@@ -29,5 +29,5 @@ interface BundleInterface extends ContainerAwareInterface
8271+
@@ -28,5 +28,5 @@ interface BundleInterface
83048272
* @return void
83058273
*/
83068274
- public function boot();
83078275
+ public function boot(): void;
83088276

83098277
/**
8310-
@@ -36,5 +36,5 @@ interface BundleInterface extends ContainerAwareInterface
8278+
@@ -35,5 +35,5 @@ interface BundleInterface
83118279
* @return void
83128280
*/
83138281
- public function shutdown();
83148282
+ public function shutdown(): void;
83158283

83168284
/**
8317-
@@ -45,5 +45,5 @@ interface BundleInterface extends ContainerAwareInterface
8285+
@@ -44,5 +44,5 @@ interface BundleInterface
83188286
* @return void
83198287
*/
83208288
- public function build(ContainerBuilder $container);
83218289
+ public function build(ContainerBuilder $container): void;
83228290

83238291
/**
8324-
@@ -72,4 +72,4 @@ interface BundleInterface extends ContainerAwareInterface
8292+
@@ -71,4 +71,4 @@ interface BundleInterface
83258293
* @return void
83268294
*/
83278295
- public function setContainer(?ContainerInterface $container);

UPGRADE-7.0.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ Console
1717
* Passing null to `*Command::setApplication()`, `*FormatterStyle::setForeground/setBackground()`, `Helper::setHelpSet()`, `Input*::setDefault()` and `Question::setAutocompleterCallback/setValidator()` must be done explicitly
1818
* Remove `StringInput::REGEX_STRING`
1919

20+
DependencyInjection
21+
-------------------
22+
23+
* Remove `#[MapDecorated]`, use `#[AutowireDecorated]` instead
24+
* Remove `ProxyHelper`, use `Symfony\Component\VarExporter\ProxyHelper` instead
25+
* Remove `ReferenceSetArgumentTrait`
26+
* Remove support of `@required` annotation, use the `Symfony\Contracts\Service\Attribute\Required` attribute instead
27+
* Passing `null` to `ContainerAwareTrait::setContainer()` must be done explicitly
28+
* Remove `PhpDumper` options `inline_factories_parameter` and `inline_class_loader_parameter`, use options `inline_factories` and `inline_class_loader` instead
29+
* Parameter names of `ParameterBag` cannot be numerics
30+
* Remove `ContainerAwareInterface` and `ContainerAwareTrait`, use dependency injection instead
31+
2032
DoctrineBridge
2133
--------------
2234

@@ -25,6 +37,7 @@ DoctrineBridge
2537
* Remove `RememberMeTokenProviderDoctrineSchemaSubscriber`, use `RememberMeTokenProviderDoctrineSchemaListener` instead
2638
* Remove `DbalLogger`, use a middleware instead
2739
* Remove `DoctrineDataCollector::addLogger()`, use a `DebugDataHolder` instead
40+
* Remove `ContainerAwareLoader`, use dependency injection in your fixtures instead
2841
* `ContainerAwareEventManager::getListeners()` must be called with an event name
2942
* DoctrineBridge now requires `doctrine/event-manager:^2`
3043
* Add parameter `$isSameDatabase` to `DoctrineTokenProvider::configureSchema()`

src/Symfony/Bridge/Doctrine/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ CHANGELOG
99
* Remove `RememberMeTokenProviderDoctrineSchemaSubscriber`, use `RememberMeTokenProviderDoctrineSchemaListener` instead
1010
* Remove `DbalLogger`, use a middleware instead
1111
* Remove `DoctrineDataCollector::addLogger()`, use a `DebugDataHolder` instead
12+
* Remove `ContainerAwareLoader`, use dependency injection in your fixtures instead
1213
* `ContainerAwareEventManager::getListeners()` must be called with an event name
1314
* DoctrineBridge now requires `doctrine/event-manager:^2`
1415
* Add parameter `$isSameDatabase` to `DoctrineTokenProvider::configureSchema()`

src/Symfony/Bridge/Doctrine/DataFixtures/ContainerAwareLoader.php

Lines changed: 0 additions & 50 deletions
This file was deleted.

src/Symfony/Bridge/Doctrine/Tests/DataFixtures/ContainerAwareLoaderTest.php

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/Symfony/Bridge/Doctrine/Tests/Fixtures/ContainerAwareFixture.php

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/Symfony/Bundle/FrameworkBundle/Console/Application.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use Symfony\Component\Console\Output\ConsoleOutputInterface;
2020
use Symfony\Component\Console\Output\OutputInterface;
2121
use Symfony\Component\Console\Style\SymfonyStyle;
22-
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
2322
use Symfony\Component\HttpKernel\Bundle\Bundle;
2423
use Symfony\Component\HttpKernel\Kernel;
2524
use Symfony\Component\HttpKernel\KernelInterface;
@@ -112,14 +111,7 @@ public function get(string $name): Command
112111
{
113112
$this->registerCommands();
114113

115-
$command = parent::get($name);
116-
117-
if ($command instanceof ContainerAwareInterface) {
118-
trigger_deprecation('symfony/dependency-injection', '6.4', 'Relying on "%s" to get the container in "%s" is deprecated, register the command as a service and use dependency injection instead.', ContainerAwareInterface::class, get_debug_type($command));
119-
$command->setContainer($this->kernel->getContainer());
120-
}
121-
122-
return $command;
114+
return parent::get($name);
123115
}
124116

125117
public function all(string $namespace = null): array

src/Symfony/Bundle/FrameworkBundle/Controller/ControllerResolver.php

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

1212
namespace Symfony\Bundle\FrameworkBundle\Controller;
1313

14-
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
1514
use Symfony\Component\HttpKernel\Controller\ContainerControllerResolver;
1615

1716
/**
@@ -25,10 +24,6 @@ protected function instantiateController(string $class): object
2524
{
2625
$controller = parent::instantiateController($class);
2726

28-
if ($controller instanceof ContainerAwareInterface) {
29-
trigger_deprecation('symfony/dependency-injection', '6.4', 'Relying on "%s" to get the container in "%s" is deprecated, register the controller as a service and use dependency injection instead.', ContainerAwareInterface::class, get_debug_type($controller));
30-
$controller->setContainer($this->container);
31-
}
3227
if ($controller instanceof AbstractController) {
3328
if (null === $previousContainer = $controller->setContainer($this->container)) {
3429
throw new \LogicException(sprintf('"%s" has no container set, did you forget to define it as a service subscriber?', $class));

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy