From 2b0e9716e18b254114dc6b5dc80d5fa7052ce190 Mon Sep 17 00:00:00 2001 From: Sergei Tigrov Date: Fri, 23 Aug 2024 14:22:56 +0700 Subject: [PATCH] Raise PHP version to 8.1 (#277) --- .github/workflows/build.yml | 2 -- .../workflows/composer-require-checker.yml | 1 - .github/workflows/static.yml | 6 ------ CHANGELOG.md | 1 + README.md | 6 +++--- composer.json | 6 +++--- psalm4.xml | 20 ------------------- rector.php | 8 +++++--- src/DMLQueryBuilder.php | 2 +- src/DQLQueryBuilder.php | 15 ++++++-------- src/Schema.php | 13 +++++------- .../Provider/ColumnSchemaBuilderProvider.php | 10 ++++------ 12 files changed, 28 insertions(+), 62 deletions(-) delete mode 100644 psalm4.xml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1f017a15..59ae210a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,8 +42,6 @@ jobs: - 21 include: - - php: 8.0 - oracle: 21 - php: 8.1 oracle: 21 - php: 8.2 diff --git a/.github/workflows/composer-require-checker.yml b/.github/workflows/composer-require-checker.yml index e1348e45..d37dffd5 100644 --- a/.github/workflows/composer-require-checker.yml +++ b/.github/workflows/composer-require-checker.yml @@ -33,7 +33,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 fa0c3622..2f4ca817 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -35,7 +35,6 @@ jobs: - ubuntu-latest php: - - '8.0' - '8.1' - '8.2' - '8.3' @@ -67,9 +66,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 b0e82790..629f90f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ for type casting performance. Related with yiisoft/db#752 (@Tigrov) - Chg #272: Replace call of `SchemaInterface::getRawTableName()` to `QuoterInterface::getRawTableName()` (@Tigrov) - Enh #275: Refactor PHP type of `ColumnSchemaInterface` instances (@Tigrov) +- Enh #277: Raise minimum PHP version to `^8.1` with minor refactoring (@Tigrov) ## 1.3.0 March 21, 2024 diff --git a/README.md b/README.md index 19d7c3f0..9ab2c264 100644 --- a/README.md +++ b/README.md @@ -29,9 +29,9 @@ your Oracle database and perform various database operations as needed. ## Support version -| PHP | Oracle Version | CI-Actions | -|-----|----------------|------------| -|**8.0 - 8.2**| **12c - 21c**|[![build](https://github.com/yiisoft/db-oracle/actions/workflows/build.yml/badge.svg?branch=dev)](https://github.com/yiisoft/db-oracle/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-oracle%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/db-oracle/master) [![static analysis](https://github.com/yiisoft/db-oracle/actions/workflows/static.yml/badge.svg?branch=dev)](https://github.com/yiisoft/db-oracle/actions/workflows/static.yml) [![type-coverage](https://shepherd.dev/github/yiisoft/db-oracle/coverage.svg)](https://shepherd.dev/github/yiisoft/db-oracle) +| PHP | Oracle Version | CI-Actions | +|---------------|----------------|------------| +| **8.1 - 8.3** | **12c - 21c**|[![build](https://github.com/yiisoft/db-oracle/actions/workflows/build.yml/badge.svg?branch=dev)](https://github.com/yiisoft/db-oracle/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-oracle%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/db-oracle/master) [![static analysis](https://github.com/yiisoft/db-oracle/actions/workflows/static.yml/badge.svg?branch=dev)](https://github.com/yiisoft/db-oracle/actions/workflows/static.yml) [![type-coverage](https://shepherd.dev/github/yiisoft/db-oracle/coverage.svg)](https://shepherd.dev/github/yiisoft/db-oracle) ## Installation diff --git a/composer.json b/composer.json index d76ca26e..a9b12247 100644 --- a/composer.json +++ b/composer.json @@ -31,16 +31,16 @@ ], "require": { "ext-pdo": "*", - "php": "^8.0", + "php": "^8.1", "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 54a52e17..00000000 --- a/psalm4.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - diff --git a/rector.php b/rector.php index 34351531..7ee7d903 100644 --- a/rector.php +++ b/rector.php @@ -5,7 +5,8 @@ use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector; use Rector\Config\RectorConfig; use Rector\Php73\Rector\String_\SensitiveHereNowDocRector; -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 +23,12 @@ // define sets of rules $rectorConfig->sets([ - LevelSetList::UP_TO_PHP_80, + LevelSetList::UP_TO_PHP_81, ]); $rectorConfig->skip([ - ClosureToArrowFunctionRector::class, + NullToStrictStringFuncCallArgRector::class, + ReadOnlyPropertyRector::class, SensitiveHereNowDocRector::class, ]); }; diff --git a/src/DMLQueryBuilder.php b/src/DMLQueryBuilder.php index 639eef69..b9c028d0 100644 --- a/src/DMLQueryBuilder.php +++ b/src/DMLQueryBuilder.php @@ -40,7 +40,7 @@ public function insertBatch(string $table, iterable $rows, array $columns = [], $tableAndColumns = ' INTO ' . $this->quoter->quoteTableName($table); if (count($columns) > 0) { - $quotedColumnNames = array_map([$this->quoter, 'quoteColumnName'], $columns); + $quotedColumnNames = array_map($this->quoter->quoteColumnName(...), $columns); $tableAndColumns .= ' (' . implode(', ', $quotedColumnNames) . ')'; } diff --git a/src/DQLQueryBuilder.php b/src/DQLQueryBuilder.php index f798ccb0..1735254e 100644 --- a/src/DQLQueryBuilder.php +++ b/src/DQLQueryBuilder.php @@ -14,7 +14,6 @@ use Yiisoft\Db\QueryBuilder\Condition\InCondition; use Yiisoft\Db\QueryBuilder\Condition\LikeCondition; -use function array_merge; use function implode; /** @@ -84,13 +83,11 @@ public function buildWithQueries(array $withs, array &$params): string protected function defaultExpressionBuilders(): array { - return array_merge( - parent::defaultExpressionBuilders(), - [ - InCondition::class => InConditionBuilder::class, - LikeCondition::class => LikeConditionBuilder::class, - Expression::class => ExpressionBuilder::class, - ], - ); + return [ + ...parent::defaultExpressionBuilders(), + InCondition::class => InConditionBuilder::class, + LikeCondition::class => LikeConditionBuilder::class, + Expression::class => ExpressionBuilder::class, + ]; } } diff --git a/src/Schema.php b/src/Schema.php index 755088e6..b7b5a972 100644 --- a/src/Schema.php +++ b/src/Schema.php @@ -24,7 +24,6 @@ use function array_change_key_case; use function array_map; -use function array_merge; use function array_reverse; use function implode; use function is_array; @@ -290,7 +289,7 @@ protected function loadTableIndexes(string $tableName): array ])->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 = []; @@ -605,7 +604,7 @@ protected function findConstraints(TableSchemaInterface $table): void } foreach ($constraints as $index => $constraint) { - $table->foreignKey($index, array_merge([$constraint['tableName']], $constraint['columns'])); + $table->foreignKey($index, [$constraint['tableName'], ...$constraint['columns']]); } } @@ -737,7 +736,7 @@ private function loadTableConstraints(string $tableName, string $returnType): mi ])->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 = [ @@ -827,12 +826,10 @@ protected function findViewNames(string $schema = ''): array * @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)]; } /** @@ -844,6 +841,6 @@ 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()])); } } diff --git a/tests/Provider/ColumnSchemaBuilderProvider.php b/tests/Provider/ColumnSchemaBuilderProvider.php index 1a3747bf..5badb0e7 100644 --- a/tests/Provider/ColumnSchemaBuilderProvider.php +++ b/tests/Provider/ColumnSchemaBuilderProvider.php @@ -17,12 +17,10 @@ public static function types(): array $types[0][0] = 'integer UNSIGNED DEFAULT NULL NULL'; $types[1][0] = 'integer(10) UNSIGNED'; - return array_merge( - $types, - [ - ['integer UNSIGNED', SchemaInterface::TYPE_INTEGER, null, [['unsigned']]], - ], - ); + return [ + ...$types, + ['integer UNSIGNED', SchemaInterface::TYPE_INTEGER, null, [['unsigned']]], + ]; } public static function createColumnTypes(): array