diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e5f26f51..b1de761f 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 58107cb7..c2ca43f8 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 9ba84818..26f5cda2 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/CHANGELOG.md b/CHANGELOG.md index aae45259..acae62be 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) +- Enh #317: Raise minimum PHP version to `^8.1` with minor refactoring (@Tigrov) ## 1.2.0 March 21, 2024 diff --git a/README.md b/README.md index 39f49dea..71097fc3 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 2d9c69ee..fe47d418 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 23bfcce1..00000000 --- a/psalm4.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - diff --git a/rector.php b/rector.php index 7e1860ee..1474cb20 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 2dbeaa92..b01d5953 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 33d76a24..0d50d1c6 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 226c7e74..c7cfc9d2 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 58d2a9ee..3be139c2 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