From 5963c823ed27909e5ca8e576f5d3e72f1f0af53f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Sun, 10 Dec 2023 19:24:19 +0100 Subject: [PATCH] Remove container injection in fixture classes with ContainerAwareInterface --- Loader/SymfonyFixturesLoader.php | 11 ----------- Resources/config/mongodb.xml | 4 +--- UPGRADE-5.0.md | 2 ++ psalm-baseline.xml | 5 ----- 4 files changed, 3 insertions(+), 19 deletions(-) diff --git a/Loader/SymfonyFixturesLoader.php b/Loader/SymfonyFixturesLoader.php index 9c5e802e..61f8876e 100644 --- a/Loader/SymfonyFixturesLoader.php +++ b/Loader/SymfonyFixturesLoader.php @@ -12,8 +12,6 @@ use LogicException; use ReflectionClass; use RuntimeException; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; use function array_key_exists; use function array_values; @@ -28,11 +26,6 @@ final class SymfonyFixturesLoader extends Loader implements SymfonyFixturesLoade /** @var array> */ private array $groupsFixtureMapping = []; - public function __construct( - private ContainerInterface $container, - ) { - } - /** * @internal * @@ -67,10 +60,6 @@ public function addFixture(FixtureInterface $fixture): void $this->addGroupsFixtureMapping($class, $fixture::getGroups()); } - if ($fixture instanceof ContainerAwareInterface) { - $fixture->setContainer($this->container); - } - parent::addFixture($fixture); } diff --git a/Resources/config/mongodb.xml b/Resources/config/mongodb.xml index 9317d7b0..0cf838b6 100644 --- a/Resources/config/mongodb.xml +++ b/Resources/config/mongodb.xml @@ -183,8 +183,6 @@ - - - + diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index a9c0584d..8657add2 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -13,3 +13,5 @@ UPGRADE FROM 4.x to 5.0 used directly or extended. * Remove support of Annotation mapping, you should use Attributes or XML instead. * Remove `--service` option from `doctrine:mongodb:fixtures:load` command +* Remove automatic injection of the container in fixtures classes implementing + `ContainerAwareInterface`. You should use dependency injection instead. diff --git a/psalm-baseline.xml b/psalm-baseline.xml index bc24f184..d33c7f8b 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -16,11 +16,6 @@ children - - - private ContainerInterface $container - - GuesserTestType