From a17bf9d90139f77e7e82ae82566a0be4762336b2 Mon Sep 17 00:00:00 2001 From: Alexandre Vingtier Date: Tue, 11 Aug 2026 09:33:34 +0200 Subject: [PATCH] Add support of Doctrine DBAL 4 and Symfony 8 The package could not be installed alongside doctrine/doctrine-bundle 3.x, which requires DBAL 4, nor on a Symfony 8 application. No source change was needed for DBAL 4: AbstractDriverMiddleware, AbstractConnectionMiddleware, Driver::connect(), Connection::query(), getNativeConnection() and DriverException::getSQLState() all kept their signatures. Only the constraints were in the way. doctrine/migrations moves to ^3.6, the first release that accepts DBAL 4, while still allowing DBAL 3. PHPStan goes to 2.x, which drops the checkMissingIterableValueType option; the two array parameters it was hiding are now documented instead. The CI matrix gains PHP 8.3, 8.4 and 8.5. Symfony 8 needs PHP 8.4, so without those rows the new support would never be exercised. The existing --prefer-lowest row keeps DBAL 3 covered. Co-Authored-By: Claude Opus 5 (1M context) --- .github/workflows/ci.yml | 7 ++++++- README.md | 2 +- composer.json | 14 +++++++------- phpstan.neon.dist | 1 - .../Driver/Middleware/RetryLockTimeoutDriver.php | 2 +- src/Doctrine/Migration.php | 4 ++++ .../Database/Doctrine/Migrations/MigrationTest.php | 4 ++++ 7 files changed, 23 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aee15f5..8e9081e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,10 +17,15 @@ jobs: fail-fast: false matrix: include: + # --prefer-lowest keeps DBAL 3 covered; every other row resolves to DBAL 4. - php: 8.1 composer_update_flags: --prefer-lowest - php: 8.1 - php: 8.2 + - php: 8.3 + # Symfony 8 needs PHP 8.4, so this is where that support is actually exercised. + - php: 8.4 + - php: 8.5 steps: - uses: actions/checkout@v2 @@ -49,7 +54,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: "8.2" + php-version: "8.4" - name: Composer dependencies run: make vendor diff --git a/README.md b/README.md index a5860b6..90a81ae 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Because SQL migrations can execute heavy queries on database which can slow down ## ⚙️ Config -_*For a Symfony > 6.x_ +_*For Symfony 6.4, 7.x or 8.x, with Doctrine DBAL 3 or 4_ Install in your project diff --git a/composer.json b/composer.json index f199de5..2d7687f 100644 --- a/composer.json +++ b/composer.json @@ -33,15 +33,15 @@ }, "require": { "php": "^8.1", - "doctrine/dbal": "^3.7", - "doctrine/migrations": "^3.3", - "symfony/string": "^6.4|^7.0" + "doctrine/dbal": "^3.7|^4.0", + "doctrine/migrations": "^3.6", + "symfony/string": "^6.4|^7.0|^8.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.9", - "phpstan/phpstan": "1.10.50", - "phpstan/phpstan-phpunit": "1.3.15", - "phpunit/phpunit": "^10.4.2", - "symfony/var-dumper": ">=6.3.8|^7.0" + "phpstan/phpstan": "^2.1", + "phpstan/phpstan-phpunit": "^2.0", + "phpunit/phpunit": "^10.4.2|^11.0", + "symfony/var-dumper": ">=6.3.8|^7.0|^8.0" } } diff --git a/phpstan.neon.dist b/phpstan.neon.dist index aa3b358..fa62ea7 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -4,7 +4,6 @@ includes: parameters: inferPrivatePropertyTypeFromConstructor: true tipsOfTheDay: false - checkMissingIterableValueType: false tmpDir: var/.phpstan.cache level: 9 paths: [ src, tests ] diff --git a/src/Doctrine/DBAL/Driver/Middleware/RetryLockTimeoutDriver.php b/src/Doctrine/DBAL/Driver/Middleware/RetryLockTimeoutDriver.php index 34a8420..abf9b72 100644 --- a/src/Doctrine/DBAL/Driver/Middleware/RetryLockTimeoutDriver.php +++ b/src/Doctrine/DBAL/Driver/Middleware/RetryLockTimeoutDriver.php @@ -18,7 +18,7 @@ public function __construct( } public function connect( - #[\SensitiveParameter] array $params + #[\SensitiveParameter] array $params, ): RetryLockTimeoutConnection { return new RetryLockTimeoutConnection(parent::connect($params), $this->logger); } diff --git a/src/Doctrine/Migration.php b/src/Doctrine/Migration.php index b86480f..d04b32e 100644 --- a/src/Doctrine/Migration.php +++ b/src/Doctrine/Migration.php @@ -37,6 +37,10 @@ public function down(Schema $schema): void $this->throwIrreversibleMigrationException(); } + /** + * @param mixed[] $params + * @param mixed[] $types + */ protected function addUnsafeSql(string $sql, array $params = [], array $types = [], ?int $statementTimeout = null): void { if (null !== $statementTimeout) { diff --git a/tests/Database/Doctrine/Migrations/MigrationTest.php b/tests/Database/Doctrine/Migrations/MigrationTest.php index 8e8f730..6428057 100644 --- a/tests/Database/Doctrine/Migrations/MigrationTest.php +++ b/tests/Database/Doctrine/Migrations/MigrationTest.php @@ -336,6 +336,10 @@ public function up(Schema $schema): void throw new \Exception('Unused for this test'); } + /** + * @param mixed[] $params + * @param mixed[] $types + */ public function addUnsafeSql(string $sql, array $params = [], array $types = [], ?int $statementTimeout = null): void { parent::addUnsafeSql($sql, $params, $types, $statementTimeout);