From f230478b4c40814afe06fbdd75747451ed6147d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Fr=C3=A9mont?= Date: Fri, 26 Apr 2024 10:32:57 +0200 Subject: [PATCH] Fix Container aware migration --- phpstan.neon | 4 +--- src/Factory/ContainerAwareVersionFactory.php | 5 ++++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 5b8bccd..327324c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -6,7 +6,5 @@ parameters: excludePaths: - tests/Fixture/ContainerAwareMigration + - tests/Factory/ContainerAwareVersionFactoryTest.php - ignoreErrors: - - '/Call to method setContainer\(\) on an unknown class Symfony\\Component\\DependencyInjection\\ContainerAwareInterface./' - - '/Class Symfony\\Component\\DependencyInjection\\ContainerAwareInterface not found./' diff --git a/src/Factory/ContainerAwareVersionFactory.php b/src/Factory/ContainerAwareVersionFactory.php index 311c393..d0b0a17 100644 --- a/src/Factory/ContainerAwareVersionFactory.php +++ b/src/Factory/ContainerAwareVersionFactory.php @@ -27,7 +27,10 @@ public function createVersion(string $migrationClassName): AbstractMigration { $instance = $this->migrationFactory->createVersion($migrationClassName); - if ($instance instanceof ContainerAwareInterface) { + if ( + interface_exists(ContainerAwareInterface::class) + && $instance instanceof ContainerAwareInterface + ) { $instance->setContainer($this->container); }