From 192577db693409ab9638ed01bdf345b76dcb9ac7 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Fri, 12 Jul 2024 08:46:34 +0300 Subject: [PATCH] Fix #268: Don't use Yii DB deprecated methods in `Migrator` --- .github/workflows/mutation.yml | 6 ++++-- .github/workflows/static.yml | 8 +++++++- CHANGELOG.md | 2 +- composer.json | 4 ++-- psalm-8.0.xml | 22 ++++++++++++++++++++++ psalm.xml | 1 + src/Migrator.php | 8 +++++++- 7 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 psalm-8.0.xml diff --git a/.github/workflows/mutation.yml b/.github/workflows/mutation.yml index 78cbc9b3..c4dc4f86 100644 --- a/.github/workflows/mutation.yml +++ b/.github/workflows/mutation.yml @@ -9,6 +9,8 @@ on: - 'psalm.xml' push: + branches: + - master paths-ignore: - 'docs/**' - 'README.md' @@ -38,7 +40,7 @@ jobs: - ubuntu-latest php: - - 8.0 + - 8.3 services: postgres: @@ -72,6 +74,6 @@ jobs: - name: Run infection. run: | - vendor/bin/roave-infection-static-analysis-plugin -j2 --ignore-msi-with-no-mutations --only-covered --test-framework-options="--testsuite=Pgsql" + vendor/bin/roave-infection-static-analysis-plugin --threads=2 --ignore-msi-with-no-mutations --only-covered --test-framework-options="--testsuite=Pgsql" env: STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 9c9b94f9..c737ea1e 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -34,6 +34,7 @@ jobs: - ubuntu-latest php: + - '8.0' - '8.1' - '8.2' - '8.3' @@ -66,5 +67,10 @@ jobs: - name: Install dependencies with composer run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - name: Static analysis + - name: Static analysis PHP 8.0 + if: matrix.php == '8.0' + run: vendor/bin/psalm --shepherd --config=psalm-8.0.xml --stats --output-format=checkstyle --php-version=${{ matrix.php }} | cs2pr --graceful-warnings --colorize + + - name: Static analysis PHP not 8.0 + if: matrix.php != '8.0' run: vendor/bin/psalm --shepherd --stats --output-format=checkstyle --php-version=${{ matrix.php }} | cs2pr --graceful-warnings --colorize diff --git a/CHANGELOG.md b/CHANGELOG.md index 100e31de..c26359f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 1.1.1 under development -- no changes in this release. +- Enh #268: Don't use Yii DB deprecated methods in `Migrator` (@BaBL86, @vjik) ## 1.1.0 December 24, 2023 diff --git a/composer.json b/composer.json index e314e81b..fc5545ba 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ "php": "^8.0", "ext-filter": "*", "symfony/console": "^6.0|^7.0", - "yiisoft/db": "^1.1", + "yiisoft/db": "^1.3", "yiisoft/injector": "^1.2" }, "require-dev": { @@ -43,7 +43,7 @@ "rector/rector": "^1.0", "roave/infection-static-analysis-plugin": "^1.25|^1.32", "spatie/phpunit-watcher": "^1.23", - "vimeo/psalm": "^4.30|^5.12", + "vimeo/psalm": "^4.30|^5.25", "yiisoft/db-sqlite": "^1.1", "yiisoft/di": "^1.2", "yiisoft/files": "^1.0|^2.0", diff --git a/psalm-8.0.xml b/psalm-8.0.xml new file mode 100644 index 00000000..99972ec4 --- /dev/null +++ b/psalm-8.0.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + diff --git a/psalm.xml b/psalm.xml index 14b155cb..fb64a3a4 100644 --- a/psalm.xml +++ b/psalm.xml @@ -17,5 +17,6 @@ + diff --git a/src/Migrator.php b/src/Migrator.php index dfa60afc..936960bc 100644 --- a/src/Migrator.php +++ b/src/Migrator.php @@ -138,7 +138,13 @@ private function checkMigrationHistoryTable(): void private function createMigrationHistoryTable(): void { - $tableName = $this->db->getSchema()->getRawTableName($this->historyTable); + /** + * Remove these annotations after raise Yii DB version to 2.0 + * + * @psalm-suppress UndefinedInterfaceMethod + * @var string $tableName + */ + $tableName = $this->db->getQuoter()->getRawTableName($this->historyTable); $this->informer->beginCreateHistoryTable('Creating migration history table "' . $tableName . '"...'); $b = $this->createBuilder(new NullMigrationInformer());