From 5366a50dd0aa70659c954bcaccf3644fac0473a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Fr=C3=A9mont?= Date: Thu, 25 Apr 2024 16:49:22 +0200 Subject: [PATCH 1/8] Add support for Symfony 7 --- .github/workflows/build.yml | 7 +++++-- composer.json | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0cc56f5..6f295db 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,8 +23,11 @@ jobs: strategy: fail-fast: false matrix: - php: ["8.0"] - symfony: ["^5.4", "^6.0"] + php: ["8.1", "8.2", "8.3"] + symfony: ["^5.4", "^6.4", "^7.0"] + exclude: + - php: "8.1" + symfony: "^7.0" steps: - uses: actions/checkout@v2 diff --git a/composer.json b/composer.json index bcf5a0e..8ae63ad 100644 --- a/composer.json +++ b/composer.json @@ -10,11 +10,11 @@ } ], "require": { - "php": "^8.0", + "php": "^8.1", "doctrine/doctrine-migrations-bundle": "^3.0", "doctrine/migrations": "^3.0", "marcj/topsort": "^1.1", - "symfony/framework-bundle": "^5.4 || ^6.0" + "symfony/framework-bundle": "^5.4 || ^6.4 || ^7.0" }, "require-dev": { "infection/infection": "^0.26", From 35af243210c2ad8ac70e014fb82fe1b6ec974129 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Fr=C3=A9mont?= Date: Fri, 26 Apr 2024 09:30:52 +0200 Subject: [PATCH 2/8] Upgrade Infection --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8ae63ad..c6c5fae 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "symfony/framework-bundle": "^5.4 || ^6.4 || ^7.0" }, "require-dev": { - "infection/infection": "^0.26", + "infection/infection": "^0.28", "matthiasnoback/symfony-config-test": "^4.2", "matthiasnoback/symfony-dependency-injection-test": "^4.1", "phpunit/phpunit": "^9.5", From 3f8d73a6b93b5b5c9f010b1ef76197e72fc097da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Fr=C3=A9mont?= Date: Fri, 26 Apr 2024 09:32:48 +0200 Subject: [PATCH 3/8] Upgrade matthiasnoback packages --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index c6c5fae..a952e5a 100644 --- a/composer.json +++ b/composer.json @@ -18,8 +18,8 @@ }, "require-dev": { "infection/infection": "^0.28", - "matthiasnoback/symfony-config-test": "^4.2", - "matthiasnoback/symfony-dependency-injection-test": "^4.1", + "matthiasnoback/symfony-config-test": "^5.1", + "matthiasnoback/symfony-dependency-injection-test": "^5.1", "phpunit/phpunit": "^9.5", "vimeo/psalm": "^4.23" }, From 955dda211a34cd276d36b06f2e724cb175199ca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Fr=C3=A9mont?= Date: Fri, 26 Apr 2024 09:42:11 +0200 Subject: [PATCH 4/8] Replace Psalm with PHPStan --- .github/workflows/build.yml | 4 ++-- composer.json | 4 ++-- phpstan.neon | 5 +++++ psalm.xml | 15 --------------- 4 files changed, 9 insertions(+), 19 deletions(-) create mode 100644 phpstan.neon delete mode 100644 psalm.xml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6f295db..f5ab3b5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -61,8 +61,8 @@ jobs: - name: Install dependencies run: composer install --ansi --no-interaction - - name: Run Psalm - run: vendor/bin/psalm + - name: Run PHPStan + run: vendor/bin/phpstan analyse - name: Run PHPUnit run: vendor/bin/phpunit diff --git a/composer.json b/composer.json index a952e5a..e22ef3e 100644 --- a/composer.json +++ b/composer.json @@ -20,8 +20,8 @@ "infection/infection": "^0.28", "matthiasnoback/symfony-config-test": "^5.1", "matthiasnoback/symfony-dependency-injection-test": "^5.1", - "phpunit/phpunit": "^9.5", - "vimeo/psalm": "^4.23" + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^9.5" }, "config": { "allow-plugins": { diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..54e6f5d --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,5 @@ +parameters: + level: 6 + paths: + - src + - tests diff --git a/psalm.xml b/psalm.xml deleted file mode 100644 index 3bb02f9..0000000 --- a/psalm.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - From cfe3f5164e26840ad1d81dfc0911de7a26927a4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Fr=C3=A9mont?= Date: Fri, 26 Apr 2024 09:47:15 +0200 Subject: [PATCH 5/8] Fix PHPStan errors --- .../SyliusLabsDoctrineMigrationsExtraExtension.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/DependencyInjection/SyliusLabsDoctrineMigrationsExtraExtension.php b/src/DependencyInjection/SyliusLabsDoctrineMigrationsExtraExtension.php index 3243c76..d140d4b 100644 --- a/src/DependencyInjection/SyliusLabsDoctrineMigrationsExtraExtension.php +++ b/src/DependencyInjection/SyliusLabsDoctrineMigrationsExtraExtension.php @@ -13,6 +13,11 @@ final class SyliusLabsDoctrineMigrationsExtraExtension extends Extension { + /** + * @param array $configs + * + * @throws \Exception + */ public function load(array $configs, ContainerBuilder $container): void { $config = $this->processConfiguration($this->getConfiguration([], $container), $configs); @@ -23,6 +28,9 @@ public function load(array $configs, ContainerBuilder $container): void $container->getDefinition(TopologicalVersionComparator::class)->setArgument(0, $config['migrations']); } + /** + * @param array $config + */ public function getConfiguration(array $config, ContainerBuilder $container): ConfigurationInterface { return new Configuration(); From 7addec25ef008ccd15a7b075d274d0a6d3ff3ea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Fr=C3=A9mont?= Date: Fri, 26 Apr 2024 09:58:52 +0200 Subject: [PATCH 6/8] Fix some issues --- phpstan.neon | 15 +++++++++++---- .../Factory/ContainerAwareVersionFactoryTest.php | 9 +++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 54e6f5d..5b8bccd 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,12 @@ parameters: - level: 6 - paths: - - src - - tests + level: 6 + paths: + - src + - tests + + excludePaths: + - tests/Fixture/ContainerAwareMigration + + ignoreErrors: + - '/Call to method setContainer\(\) on an unknown class Symfony\\Component\\DependencyInjection\\ContainerAwareInterface./' + - '/Class Symfony\\Component\\DependencyInjection\\ContainerAwareInterface not found./' diff --git a/tests/Factory/ContainerAwareVersionFactoryTest.php b/tests/Factory/ContainerAwareVersionFactoryTest.php index 287b6a9..cf018ed 100644 --- a/tests/Factory/ContainerAwareVersionFactoryTest.php +++ b/tests/Factory/ContainerAwareVersionFactoryTest.php @@ -11,6 +11,7 @@ use Psr\Log\LoggerInterface; use SyliusLabs\DoctrineMigrationsExtraBundle\Factory\ContainerAwareVersionFactory; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpKernel\Kernel; use Tests\SyliusLabs\DoctrineMigrationsExtraBundle\Fixture\ContainerAwareMigration; use Tests\SyliusLabs\DoctrineMigrationsExtraBundle\Fixture\NotContainerAwareMigration; @@ -19,6 +20,10 @@ final class ContainerAwareVersionFactoryTest extends TestCase /** @test */ public function migrations_implementing_container_aware_interface_are_injected_with_container(): void { + if (Kernel::MAJOR_VERSION >= 7) { + $this->markTestSkipped(); + } + // Arrange $decoratedFactory = $this->createMock(MigrationFactory::class); $container = $this->createMock(ContainerInterface::class); @@ -41,6 +46,10 @@ public function migrations_implementing_container_aware_interface_are_injected_w /** @test */ public function migrations_not_implementing_container_aware_interface_are_not_injected_with_container(): void { + if (Kernel::MAJOR_VERSION >= 7) { + $this->markTestSkipped(); + } + // Arrange $decoratedFactory = $this->createMock(MigrationFactory::class); $container = $this->createMock(ContainerInterface::class); 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 7/8] 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); } From 2b1350e2e57d8a1e076518513e4b6155b64d5035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Fr=C3=A9mont?= Date: Fri, 26 Apr 2024 10:42:45 +0200 Subject: [PATCH 8/8] Trying to fix infection with sf7 --- .github/workflows/build.yml | 5 +++++ tests/Factory/ContainerAwareVersionFactoryTest.php | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f5ab3b5..4ac55d6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -68,4 +68,9 @@ jobs: run: vendor/bin/phpunit - name: Run Infection + if: ${{matrix.symfony == '^7.0' }} + run: phpdbg -qrr vendor/bin/infection --min-msi=82 + + - name: Run Infection + if: ${{matrix.symfony != '^7.0' }} run: phpdbg -qrr vendor/bin/infection --min-msi=100 diff --git a/tests/Factory/ContainerAwareVersionFactoryTest.php b/tests/Factory/ContainerAwareVersionFactoryTest.php index cf018ed..1097369 100644 --- a/tests/Factory/ContainerAwareVersionFactoryTest.php +++ b/tests/Factory/ContainerAwareVersionFactoryTest.php @@ -46,10 +46,6 @@ public function migrations_implementing_container_aware_interface_are_injected_w /** @test */ public function migrations_not_implementing_container_aware_interface_are_not_injected_with_container(): void { - if (Kernel::MAJOR_VERSION >= 7) { - $this->markTestSkipped(); - } - // Arrange $decoratedFactory = $this->createMock(MigrationFactory::class); $container = $this->createMock(ContainerInterface::class);