From 6235dd94c9351f919eeb7da14e65b9207bf49756 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Sat, 17 Aug 2024 19:39:22 +0700 Subject: [PATCH 1/3] Raise PHP version to 8.1 --- .github/workflows/build.yml | 2 -- .../workflows/composer-require-checker.yml | 1 - .github/workflows/static.yml | 6 ------ README.md | 2 +- composer.json | 6 +++--- psalm4.xml | 20 ------------------- 6 files changed, 4 insertions(+), 33 deletions(-) delete mode 100644 psalm4.xml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a56d4a98d..b5632e7a5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,8 +44,6 @@ jobs: - 16 include: - - php: 8.0 - pgsql: 16 - php: 8.1 pgsql: 16 - php: 8.2 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 1660a1ad9..95e5fd752 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' @@ -66,9 +65,4 @@ jobs: run: composer update --no-interaction --no-progress --optimize-autoloader --ansi - 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 48b5a242a..bb0083a24 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ as stored procedures and server-side cursors. | PHP | PostgreSQL Version | CI-Actions |---------------|---------------------|----------- -| **8.0 - 8.3** | **9.0 - 16.0** |[![build](https://github.com/yiisoft/db-pgsql/actions/workflows/build.yml/badge.svg?branch=dev)](https://github.com/yiisoft/db-pgsql/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-pgsql%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/db-pgsql/master) [![static analysis](https://github.com/yiisoft/db-pgsql/actions/workflows/static.yml/badge.svg?branch=dev)](https://github.com/yiisoft/db-pgsql/actions/workflows/static.yml) [![type-coverage](https://shepherd.dev/github/yiisoft/db-pgsql/coverage.svg)](https://shepherd.dev/github/yiisoft/db-pgsql) +| **8.1 - 8.3** | **9.0 - 16.0** |[![build](https://github.com/yiisoft/db-pgsql/actions/workflows/build.yml/badge.svg?branch=dev)](https://github.com/yiisoft/db-pgsql/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-pgsql%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/db-pgsql/master) [![static analysis](https://github.com/yiisoft/db-pgsql/actions/workflows/static.yml/badge.svg?branch=dev)](https://github.com/yiisoft/db-pgsql/actions/workflows/static.yml) [![type-coverage](https://shepherd.dev/github/yiisoft/db-pgsql/coverage.svg)](https://shepherd.dev/github/yiisoft/db-pgsql) ## Installation diff --git a/composer.json b/composer.json index fa7d17bac..41cd0180a 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ } ], "require": { - "php": "^8.0", + "php": "^8.1", "ext-json": "*", "ext-pdo": "*", "ext-pdo_pgsql": "*", @@ -40,11 +40,11 @@ }, "require-dev": { "maglnet/composer-require-checker": "^4.2", - "phpunit/phpunit": "^9.5|^10.0", + "phpunit/phpunit": "^10.0", "rector/rector": "^1.1.1", "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 54a52e176..000000000 --- a/psalm4.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - From 4fad91adfd4d962acc85bf423eb0736c5d88b04b Mon Sep 17 00:00:00 2001 From: Tigrov Date: Sun, 18 Aug 2024 14:19:41 +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 9e9205640..0bdf02592 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Enh #350: Add array overlaps and JSON overlaps condition builders (@Tigrov) - Enh #353: Update `bit` type according to main PR yiisoft/db#860 (@Tigrov) - Enh #354: Refactor PHP type of `ColumnSchemaInterface` instances (@Tigrov) +- Chg #356: Raise minimum PHP version to `^8.1` (@Tigrov) ## 1.3.0 March 21, 2024 From b6e0b2c0dbe849de0fe7992171cd3b77051e075e Mon Sep 17 00:00:00 2001 From: Tigrov Date: Fri, 23 Aug 2024 10:41:31 +0700 Subject: [PATCH 3/3] Apply rector on PHP 8.1 + minor refactoring --- CHANGELOG.md | 2 +- rector.php | 8 +++++--- src/Column/ArrayColumnSchema.php | 6 +++--- src/DMLQueryBuilder.php | 5 +---- src/DQLQueryBuilder.php | 12 ++++++------ src/Schema.php | 13 +++++-------- 6 files changed, 21 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bdf02592..4dd6d7eba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ - Enh #350: Add array overlaps and JSON overlaps condition builders (@Tigrov) - Enh #353: Update `bit` type according to main PR yiisoft/db#860 (@Tigrov) - Enh #354: Refactor PHP type of `ColumnSchemaInterface` instances (@Tigrov) -- Chg #356: Raise minimum PHP version to `^8.1` (@Tigrov) +- Enh #356: Raise minimum PHP version to `^8.1` with minor refactoring (@Tigrov) ## 1.3.0 March 21, 2024 diff --git a/rector.php b/rector.php index dc433c139..1474cb204 100644 --- a/rector.php +++ b/rector.php @@ -4,7 +4,8 @@ use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector; use Rector\Config\RectorConfig; -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 { @@ -21,10 +22,11 @@ // define sets of rules $rectorConfig->sets([ - LevelSetList::UP_TO_PHP_80, + LevelSetList::UP_TO_PHP_81, ]); $rectorConfig->skip([ - ClosureToArrowFunctionRector::class, + NullToStrictStringFuncCallArgRector::class, + ReadOnlyPropertyRector::class, ]); }; diff --git a/src/Column/ArrayColumnSchema.php b/src/Column/ArrayColumnSchema.php index 0507c4a59..689112809 100644 --- a/src/Column/ArrayColumnSchema.php +++ b/src/Column/ArrayColumnSchema.php @@ -116,7 +116,7 @@ public function dbTypecast(mixed $value): ExpressionInterface|null } if ($this->dimension === 1 && is_array($value)) { - $value = array_map([$this->getColumn(), 'dbTypecast'], $value); + $value = array_map($this->getColumn()->dbTypecast(...), $value); } else { $value = $this->dbTypecastArray($value, $this->dimension); } @@ -141,7 +141,7 @@ public function phpTypecast(mixed $value): array|null $column = $this->getColumn(); if ($this->dimension === 1 && $column->getType() !== SchemaInterface::TYPE_JSON) { - return array_map([$column, 'phpTypecast'], $value); + return array_map($column->phpTypecast(...), $value); } array_walk_recursive($value, function (string|null &$val) use ($column): void { @@ -171,7 +171,7 @@ private function dbTypecastArray(mixed $value, int $dimension): array|null if ($dimension <= 1) { return array_map( - [$this->getColumn(), 'dbTypecast'], + $this->getColumn()->dbTypecast(...), $value instanceof Traversable ? iterator_to_array($value, false) : $value diff --git a/src/DMLQueryBuilder.php b/src/DMLQueryBuilder.php index d727566c6..98c1e6e32 100644 --- a/src/DMLQueryBuilder.php +++ b/src/DMLQueryBuilder.php @@ -23,10 +23,7 @@ public function insertWithReturningPks(string $table, QueryInterface|array $colu $returnColumns = $this->schema->getTableSchema($table)?->getPrimaryKey(); if (!empty($returnColumns)) { - $returnColumns = array_map( - [$this->quoter, 'quoteColumnName'], - $returnColumns, - ); + $returnColumns = array_map($this->quoter->quoteColumnName(...), $returnColumns); $sql .= ' RETURNING ' . implode(', ', $returnColumns); } diff --git a/src/DQLQueryBuilder.php b/src/DQLQueryBuilder.php index 20798d71c..5ad9578a9 100644 --- a/src/DQLQueryBuilder.php +++ b/src/DQLQueryBuilder.php @@ -19,8 +19,6 @@ use Yiisoft\Db\QueryBuilder\Condition\JsonOverlapsCondition; use Yiisoft\Db\QueryBuilder\Condition\LikeCondition; -use function array_merge; - /** * Implements a DQL (Data Query Language) SQL statements for PostgreSQL Server. */ @@ -35,12 +33,13 @@ final class DQLQueryBuilder extends AbstractDQLQueryBuilder */ protected function defaultConditionClasses(): array { - return array_merge(parent::defaultConditionClasses(), [ + return [ + ...parent::defaultConditionClasses(), 'ILIKE' => LikeCondition::class, 'NOT ILIKE' => LikeCondition::class, 'OR ILIKE' => LikeCondition::class, 'OR NOT ILIKE' => LikeCondition::class, - ]); + ]; } /** @@ -54,13 +53,14 @@ protected function defaultConditionClasses(): array */ protected function defaultExpressionBuilders(): array { - return array_merge(parent::defaultExpressionBuilders(), [ + return [ + ...parent::defaultExpressionBuilders(), ArrayExpression::class => ArrayExpressionBuilder::class, ArrayOverlapsCondition::class => ArrayOverlapsConditionBuilder::class, JsonExpression::class => JsonExpressionBuilder::class, JsonOverlapsCondition::class => JsonOverlapsConditionBuilder::class, StructuredExpression::class => StructuredExpressionBuilder::class, Expression::class => ExpressionBuilder::class, - ]); + ]; } } diff --git a/src/Schema.php b/src/Schema.php index 1d093355c..3f3b53d97 100644 --- a/src/Schema.php +++ b/src/Schema.php @@ -33,7 +33,6 @@ use function array_change_key_case; use function array_map; -use function array_merge; use function array_unique; use function array_values; use function explode; @@ -408,7 +407,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 = []; @@ -593,7 +592,7 @@ protected function findConstraints(TableSchemaInterface $table): void foreach ($constraints as $foreingKeyName => $constraint) { $table->foreignKey( (string) $foreingKeyName, - array_merge([$constraint['tableName']], $constraint['columns']) + [$constraint['tableName'], ...$constraint['columns']] ); } } @@ -1001,7 +1000,7 @@ private function loadTableConstraints(string $tableName, string $returnType): ar ])->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 = [ @@ -1101,12 +1100,10 @@ protected function createColumnSchema(string $type, mixed ...$info): ColumnSchem * @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)]; } /** @@ -1118,6 +1115,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()])); } }