Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Symfony 7 #15

Merged
merged 8 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -58,11 +61,16 @@ 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

- 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
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@
}
],
"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",
"matthiasnoback/symfony-config-test": "^4.2",
"matthiasnoback/symfony-dependency-injection-test": "^4.1",
"phpunit/phpunit": "^9.5",
"vimeo/psalm": "^4.23"
"infection/infection": "^0.28",
"matthiasnoback/symfony-config-test": "^5.1",
"matthiasnoback/symfony-dependency-injection-test": "^5.1",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^9.5"
},
"config": {
"allow-plugins": {
Expand Down
10 changes: 10 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
parameters:
level: 6
paths:
- src
- tests

excludePaths:
- tests/Fixture/ContainerAwareMigration
- tests/Factory/ContainerAwareVersionFactoryTest.php

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty line

15 changes: 0 additions & 15 deletions psalm.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@

final class SyliusLabsDoctrineMigrationsExtraExtension extends Extension
{
/**
* @param array<string, mixed> $configs
*
* @throws \Exception
*/
public function load(array $configs, ContainerBuilder $container): void
{
$config = $this->processConfiguration($this->getConfiguration([], $container), $configs);
Expand All @@ -23,6 +28,9 @@ public function load(array $configs, ContainerBuilder $container): void
$container->getDefinition(TopologicalVersionComparator::class)->setArgument(0, $config['migrations']);
}

/**
* @param array<string, mixed> $config
*/
public function getConfiguration(array $config, ContainerBuilder $container): ConfigurationInterface
{
return new Configuration();
Expand Down
5 changes: 4 additions & 1 deletion src/Factory/ContainerAwareVersionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
{
$instance = $this->migrationFactory->createVersion($migrationClassName);

if ($instance instanceof ContainerAwareInterface) {
if (
interface_exists(ContainerAwareInterface::class)

Check warning on line 31 in src/Factory/ContainerAwareVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHP 8.2, Symfony ^7.0

Escaped Mutant for Mutator "LogicalAnd": --- Original +++ New @@ @@ public function createVersion(string $migrationClassName): AbstractMigration { $instance = $this->migrationFactory->createVersion($migrationClassName); - if (interface_exists(ContainerAwareInterface::class) && $instance instanceof ContainerAwareInterface) { + if (interface_exists(ContainerAwareInterface::class) || $instance instanceof ContainerAwareInterface) { $instance->setContainer($this->container); } return $instance; } }

Check warning on line 31 in src/Factory/ContainerAwareVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHP 8.2, Symfony ^7.0

Escaped Mutant for Mutator "LogicalAndSingleSubExprNegation": --- Original +++ New @@ @@ public function createVersion(string $migrationClassName): AbstractMigration { $instance = $this->migrationFactory->createVersion($migrationClassName); - if (interface_exists(ContainerAwareInterface::class) && $instance instanceof ContainerAwareInterface) { + if (!interface_exists(ContainerAwareInterface::class) && $instance instanceof ContainerAwareInterface) { $instance->setContainer($this->container); } return $instance; } }

Check warning on line 31 in src/Factory/ContainerAwareVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHP 8.3, Symfony ^7.0

Escaped Mutant for Mutator "LogicalAnd": --- Original +++ New @@ @@ public function createVersion(string $migrationClassName): AbstractMigration { $instance = $this->migrationFactory->createVersion($migrationClassName); - if (interface_exists(ContainerAwareInterface::class) && $instance instanceof ContainerAwareInterface) { + if (interface_exists(ContainerAwareInterface::class) || $instance instanceof ContainerAwareInterface) { $instance->setContainer($this->container); } return $instance; } }

Check warning on line 31 in src/Factory/ContainerAwareVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHP 8.3, Symfony ^7.0

Escaped Mutant for Mutator "LogicalAndSingleSubExprNegation": --- Original +++ New @@ @@ public function createVersion(string $migrationClassName): AbstractMigration { $instance = $this->migrationFactory->createVersion($migrationClassName); - if (interface_exists(ContainerAwareInterface::class) && $instance instanceof ContainerAwareInterface) { + if (!interface_exists(ContainerAwareInterface::class) && $instance instanceof ContainerAwareInterface) { $instance->setContainer($this->container); } return $instance; } }
&& $instance instanceof ContainerAwareInterface

Check warning on line 32 in src/Factory/ContainerAwareVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHP 8.2, Symfony ^7.0

Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ public function createVersion(string $migrationClassName): AbstractMigration { $instance = $this->migrationFactory->createVersion($migrationClassName); - if (interface_exists(ContainerAwareInterface::class) && $instance instanceof ContainerAwareInterface) { + if (interface_exists(ContainerAwareInterface::class) && true) { $instance->setContainer($this->container); } return $instance; } }

Check warning on line 32 in src/Factory/ContainerAwareVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHP 8.2, Symfony ^7.0

Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ public function createVersion(string $migrationClassName): AbstractMigration { $instance = $this->migrationFactory->createVersion($migrationClassName); - if (interface_exists(ContainerAwareInterface::class) && $instance instanceof ContainerAwareInterface) { + if (interface_exists(ContainerAwareInterface::class) && false) { $instance->setContainer($this->container); } return $instance; } }

Check warning on line 32 in src/Factory/ContainerAwareVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHP 8.3, Symfony ^7.0

Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ public function createVersion(string $migrationClassName): AbstractMigration { $instance = $this->migrationFactory->createVersion($migrationClassName); - if (interface_exists(ContainerAwareInterface::class) && $instance instanceof ContainerAwareInterface) { + if (interface_exists(ContainerAwareInterface::class) && true) { $instance->setContainer($this->container); } return $instance; } }

Check warning on line 32 in src/Factory/ContainerAwareVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHP 8.3, Symfony ^7.0

Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ public function createVersion(string $migrationClassName): AbstractMigration { $instance = $this->migrationFactory->createVersion($migrationClassName); - if (interface_exists(ContainerAwareInterface::class) && $instance instanceof ContainerAwareInterface) { + if (interface_exists(ContainerAwareInterface::class) && false) { $instance->setContainer($this->container); } return $instance; } }
) {
$instance->setContainer($this->container);
}

Expand Down
5 changes: 5 additions & 0 deletions tests/Factory/ContainerAwareVersionFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down
Loading