From 8bea6d0210b1847d2f46396849014a23095e63ba Mon Sep 17 00:00:00 2001 From: Tigrov Date: Sat, 17 Aug 2024 19:38:59 +0700 Subject: [PATCH 1/3] Raise PHP version to 8.1 --- .github/workflows/build.yml | 1 - .github/workflows/composer-require-checker.yml | 1 - .github/workflows/static.yml | 6 ------ README.md | 6 +++--- composer.json | 6 +++--- psalm4.xml | 17 ----------------- 6 files changed, 6 insertions(+), 31 deletions(-) delete mode 100644 psalm4.xml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e5f26f51e..b1de761f3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,7 +31,6 @@ jobs: strategy: matrix: php: - - 8.0 - 8.1 - 8.2 - 8.3 diff --git a/.github/workflows/composer-require-checker.yml b/.github/workflows/composer-require-checker.yml index 58107cb71..c2ca43f8b 100644 --- a/.github/workflows/composer-require-checker.yml +++ b/.github/workflows/composer-require-checker.yml @@ -29,7 +29,6 @@ jobs: - ubuntu-latest php: - - 8.0 - 8.1 - 8.2 - 8.3 diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 9ba848180..26f5cda2d 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -31,7 +31,6 @@ jobs: - ubuntu-latest php: - - '8.0' - '8.1' - '8.2' - '8.3' @@ -63,9 +62,4 @@ jobs: WORK_PACKAGE_URL: ${{ env.WORK_PACKAGE_URL }} - name: Static analysis. - if: ${{ matrix.php != '8.0' }} run: vendor/bin/psalm --config=${{ inputs.psalm-config }} --shepherd --stats --output-format=github --php-version=${{ matrix.php }} - - - name: Static analysis. - if: ${{ matrix.php == '8.0' }} - run: vendor/bin/psalm --config=psalm4.xml --shepherd --stats --output-format=github --php-version=${{ matrix.php }} diff --git a/README.md b/README.md index 39f49dea1..71097fc34 100644 --- a/README.md +++ b/README.md @@ -29,9 +29,9 @@ have access to a SQL Server database and the necessary credentials to connect to ## Support version -| PHP | MSSQL Version | CI-Actions | -|-----|---------------|------------| -|**8.0 - 8.2**| **2017 - 2022**|[![build](https://github.com/yiisoft/db-mssql/actions/workflows/build.yml/badge.svg?branch=dev)](https://github.com/yiisoft/db-mssql/actions/workflows/build.yml) [![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyiisoft%2Fdb-mssql%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/db-mssql/master) [![static analysis](https://github.com/yiisoft/db-mssql/actions/workflows/static.yml/badge.svg?branch=dev)](https://github.com/yiisoft/db-mssql/actions/workflows/static.yml) [![type-coverage](https://shepherd.dev/github/yiisoft/db-mssql/coverage.svg)](https://shepherd.dev/github/yiisoft/db-mssql) +| PHP | MSSQL Version | CI-Actions | +|---------------|---------------|------------| +| **8.1 - 8.3** | **2017 - 2022**|[![build](https://github.com/yiisoft/db-mssql/actions/workflows/build.yml/badge.svg?branch=dev)](https://github.com/yiisoft/db-mssql/actions/workflows/build.yml) [![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyiisoft%2Fdb-mssql%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/db-mssql/master) [![static analysis](https://github.com/yiisoft/db-mssql/actions/workflows/static.yml/badge.svg?branch=dev)](https://github.com/yiisoft/db-mssql/actions/workflows/static.yml) [![type-coverage](https://shepherd.dev/github/yiisoft/db-mssql/coverage.svg)](https://shepherd.dev/github/yiisoft/db-mssql) ## Installation diff --git a/composer.json b/composer.json index 2d9c69eed..fe47d418a 100644 --- a/composer.json +++ b/composer.json @@ -31,17 +31,17 @@ } ], "require": { - "php": "^8.0", + "php": "^8.1", "ext-pdo": "*", "yiisoft/db": "dev-master" }, "require-dev": { "maglnet/composer-require-checker": "^4.2", - "phpunit/phpunit": "^9.6|^10.0", + "phpunit/phpunit": "^10.0", "rector/rector": "^1.0", "roave/infection-static-analysis-plugin": "^1.16", "spatie/phpunit-watcher": "^1.23", - "vimeo/psalm": "^4.30|^5.20", + "vimeo/psalm": "^5.25", "yiisoft/aliases": "^2.0", "yiisoft/cache-file": "^3.1", "yiisoft/var-dumper": "^1.5" diff --git a/psalm4.xml b/psalm4.xml deleted file mode 100644 index 23bfcce17..000000000 --- a/psalm4.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - From d00577ab5e5a06ce48e754a712a1106fae447977 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Sun, 18 Aug 2024 14:17:36 +0700 Subject: [PATCH 2/3] Add line to CHANGELOG.md [skip ci] --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aae45259d..3fddc9743 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Chg #308: Replace call of `SchemaInterface::getRawTableName()` to `QuoterInterface::getRawTableName()` (@Tigrov) - Enh #312: Refactor `bit` type (@Tigrov) - Enh #315: Refactor PHP type of `ColumnSchemaInterface` instances (@Tigrov) +- Chg #317: Raise minimum PHP version to `^8.1` (@Tigrov) ## 1.2.0 March 21, 2024 From 9738f2417c64f8400ce6fb1dd04ff1b3ab199317 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Fri, 23 Aug 2024 10:41:04 +0700 Subject: [PATCH 3/3] Apply rector on PHP 8.1 + minor refactoring --- CHANGELOG.md | 2 +- rector.php | 10 +++++----- src/DQLQueryBuilder.php | 6 +++--- src/Quoter.php | 2 +- src/Schema.php | 11 +++++------ tests/SchemaTest.php | 5 +++-- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fddc9743..acae62be7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ - Chg #308: Replace call of `SchemaInterface::getRawTableName()` to `QuoterInterface::getRawTableName()` (@Tigrov) - Enh #312: Refactor `bit` type (@Tigrov) - Enh #315: Refactor PHP type of `ColumnSchemaInterface` instances (@Tigrov) -- Chg #317: Raise minimum PHP version to `^8.1` (@Tigrov) +- Enh #317: Raise minimum PHP version to `^8.1` with minor refactoring (@Tigrov) ## 1.2.0 March 21, 2024 diff --git a/rector.php b/rector.php index 7e1860eec..1474cb204 100644 --- a/rector.php +++ b/rector.php @@ -4,8 +4,8 @@ use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector; use Rector\Config\RectorConfig; -use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector; -use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector; +use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector; +use Rector\Php81\Rector\Property\ReadOnlyPropertyRector; use Rector\Set\ValueObject\LevelSetList; return static function (RectorConfig $rectorConfig): void { @@ -22,11 +22,11 @@ // define sets of rules $rectorConfig->sets([ - LevelSetList::UP_TO_PHP_80, + LevelSetList::UP_TO_PHP_81, ]); $rectorConfig->skip([ - ClosureToArrowFunctionRector::class, - JsonThrowOnErrorRector::class, + NullToStrictStringFuncCallArgRector::class, + ReadOnlyPropertyRector::class, ]); }; diff --git a/src/DQLQueryBuilder.php b/src/DQLQueryBuilder.php index 2dbeaa921..b01d59534 100644 --- a/src/DQLQueryBuilder.php +++ b/src/DQLQueryBuilder.php @@ -16,7 +16,6 @@ use Yiisoft\Db\QueryBuilder\Condition\InCondition; use Yiisoft\Db\QueryBuilder\Condition\LikeCondition; -use function array_merge; use function preg_match; /** @@ -47,11 +46,12 @@ public function selectExists(string $rawSql): string protected function defaultExpressionBuilders(): array { - return array_merge(parent::defaultExpressionBuilders(), [ + return [ + ...parent::defaultExpressionBuilders(), InCondition::class => InConditionBuilder::class, LikeCondition::class => LikeConditionBuilder::class, Expression::class => ExpressionBuilder::class, - ]); + ]; } /** diff --git a/src/Quoter.php b/src/Quoter.php index 33d76a242..0d50d1c61 100644 --- a/src/Quoter.php +++ b/src/Quoter.php @@ -30,7 +30,7 @@ public function getTableNameParts(string $name, bool $withColumn = false): array if (preg_match_all('/([^.\[\]]+)|\[([^\[\]]+)]/', $name, $matches) > 0) { $parts = array_slice($matches[0], -4, 4); - return array_map([$this, 'unquoteSimpleTableName'], $parts); + return array_map($this->unquoteSimpleTableName(...), $parts); } return [$this->unquoteSimpleTableName($name)]; diff --git a/src/Schema.php b/src/Schema.php index 226c7e743..c7cfc9d24 100644 --- a/src/Schema.php +++ b/src/Schema.php @@ -19,6 +19,7 @@ use Yiisoft\Db\Schema\Column\ColumnSchemaInterface; use Yiisoft\Db\Schema\TableSchemaInterface; +use function array_change_key_case; use function array_map; use function explode; use function is_array; @@ -333,7 +334,7 @@ protected function loadTableIndexes(string $tableName): array $indexes = $this->db->createCommand($sql, [':fullName' => $resolvedName->getFullName()])->queryAll(); /** @psalm-var array[] $indexes */ - $indexes = array_map('array_change_key_case', $indexes); + $indexes = array_map(array_change_key_case(...), $indexes); $indexes = DbArrayHelper::index($indexes, null, ['name']); $result = []; @@ -840,7 +841,7 @@ private function loadTableConstraints(string $tableName, string $returnType): mi $constraints = $this->db->createCommand($sql, [':fullName' => $resolvedName->getFullName()])->queryAll(); /** @psalm-var array[] $constraints */ - $constraints = array_map('array_change_key_case', $constraints); + $constraints = array_map(array_change_key_case(...), $constraints); $constraints = DbArrayHelper::index($constraints, null, ['type', 'name']); $result = [ @@ -909,12 +910,10 @@ private function loadTableConstraints(string $tableName, string $returnType): mi * @param string $name The table name. * * @return array The cache key. - * - * @psalm-suppress DeprecatedMethod */ protected function getCacheKey(string $name): array { - return array_merge([self::class], $this->generateCacheKey(), [$this->db->getQuoter()->getRawTableName($name)]); + return [self::class, ...$this->generateCacheKey(), $this->db->getQuoter()->getRawTableName($name)]; } /** @@ -926,7 +925,7 @@ protected function getCacheKey(string $name): array */ protected function getCacheTag(): string { - return md5(serialize(array_merge([self::class], $this->generateCacheKey()))); + return md5(serialize([self::class, ...$this->generateCacheKey()])); } private function parseDefaultValue(string $value): string diff --git a/tests/SchemaTest.php b/tests/SchemaTest.php index 58d2a9eec..3be139c2e 100644 --- a/tests/SchemaTest.php +++ b/tests/SchemaTest.php @@ -155,7 +155,8 @@ function ($params) use ($expectedTableName) { public function withIndexDataProvider(): array { - return array_merge(parent::withIndexDataProvider(), [ + return [ + ...parent::withIndexDataProvider(), [ 'indexType' => SchemaInterface::INDEX_CLUSTERED, 'indexMethod' => null, @@ -166,7 +167,7 @@ public function withIndexDataProvider(): array 'indexMethod' => null, 'columnType' => 'varchar(16)', ], - ]); + ]; } public function testNotConnectionPDO(): void