Skip to content

Commit 03a6340

Browse files
authored
Raise PHP version to 8.1 (#356)
1 parent d21a9ac commit 03a6340

12 files changed

+25
-57
lines changed

.github/workflows/build.yml

-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ jobs:
4444
- 16
4545

4646
include:
47-
- php: 8.0
48-
pgsql: 16
4947
- php: 8.1
5048
pgsql: 16
5149
- php: 8.2

.github/workflows/composer-require-checker.yml

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ jobs:
2929
- ubuntu-latest
3030

3131
php:
32-
- 8.0
3332
- 8.1
3433
- 8.2
3534
- 8.3

.github/workflows/static.yml

-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ jobs:
3131
- ubuntu-latest
3232

3333
php:
34-
- '8.0'
3534
- '8.1'
3635
- '8.2'
3736
- '8.3'
@@ -66,9 +65,4 @@ jobs:
6665
run: composer update --no-interaction --no-progress --optimize-autoloader --ansi
6766

6867
- name: Static analysis.
69-
if: ${{ matrix.php != '8.0' }}
7068
run: vendor/bin/psalm --config=${{ inputs.psalm-config }} --shepherd --stats --output-format=github --php-version=${{ matrix.php }}
71-
72-
- name: Static analysis.
73-
if: ${{ matrix.php == '8.0' }}
74-
run: vendor/bin/psalm --config=psalm4.xml --shepherd --stats --output-format=github --php-version=${{ matrix.php }}

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- Enh #350: Add array overlaps and JSON overlaps condition builders (@Tigrov)
1111
- Enh #353: Update `bit` type according to main PR yiisoft/db#860 (@Tigrov)
1212
- Enh #354: Refactor PHP type of `ColumnSchemaInterface` instances (@Tigrov)
13+
- Enh #356: Raise minimum PHP version to `^8.1` with minor refactoring (@Tigrov)
1314

1415
## 1.3.0 March 21, 2024
1516

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ as stored procedures and server-side cursors.
2727

2828
| PHP | PostgreSQL Version | CI-Actions
2929
|---------------|---------------------|-----------
30-
| **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)
30+
| **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)
3131

3232
## Installation
3333

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
}
3232
],
3333
"require": {
34-
"php": "^8.0",
34+
"php": "^8.1",
3535
"ext-json": "*",
3636
"ext-pdo": "*",
3737
"ext-pdo_pgsql": "*",
@@ -40,11 +40,11 @@
4040
},
4141
"require-dev": {
4242
"maglnet/composer-require-checker": "^4.2",
43-
"phpunit/phpunit": "^9.5|^10.0",
43+
"phpunit/phpunit": "^10.0",
4444
"rector/rector": "^1.1.1",
4545
"roave/infection-static-analysis-plugin": "^1.16",
4646
"spatie/phpunit-watcher": "^1.23",
47-
"vimeo/psalm": "^4.30|^5.20",
47+
"vimeo/psalm": "^5.25",
4848
"yiisoft/aliases": "^2.0",
4949
"yiisoft/cache-file": "^3.1",
5050
"yiisoft/var-dumper": "^1.5"

psalm4.xml

-20
This file was deleted.

rector.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
66
use Rector\Config\RectorConfig;
7-
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
7+
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
8+
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
89
use Rector\Set\ValueObject\LevelSetList;
910

1011
return static function (RectorConfig $rectorConfig): void {
@@ -21,10 +22,11 @@
2122

2223
// define sets of rules
2324
$rectorConfig->sets([
24-
LevelSetList::UP_TO_PHP_80,
25+
LevelSetList::UP_TO_PHP_81,
2526
]);
2627

2728
$rectorConfig->skip([
28-
ClosureToArrowFunctionRector::class,
29+
NullToStrictStringFuncCallArgRector::class,
30+
ReadOnlyPropertyRector::class,
2931
]);
3032
};

src/Column/ArrayColumnSchema.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function dbTypecast(mixed $value): ExpressionInterface|null
116116
}
117117

118118
if ($this->dimension === 1 && is_array($value)) {
119-
$value = array_map([$this->getColumn(), 'dbTypecast'], $value);
119+
$value = array_map($this->getColumn()->dbTypecast(...), $value);
120120
} else {
121121
$value = $this->dbTypecastArray($value, $this->dimension);
122122
}
@@ -141,7 +141,7 @@ public function phpTypecast(mixed $value): array|null
141141
$column = $this->getColumn();
142142

143143
if ($this->dimension === 1 && $column->getType() !== SchemaInterface::TYPE_JSON) {
144-
return array_map([$column, 'phpTypecast'], $value);
144+
return array_map($column->phpTypecast(...), $value);
145145
}
146146

147147
array_walk_recursive($value, function (string|null &$val) use ($column): void {
@@ -171,7 +171,7 @@ private function dbTypecastArray(mixed $value, int $dimension): array|null
171171

172172
if ($dimension <= 1) {
173173
return array_map(
174-
[$this->getColumn(), 'dbTypecast'],
174+
$this->getColumn()->dbTypecast(...),
175175
$value instanceof Traversable
176176
? iterator_to_array($value, false)
177177
: $value

src/DMLQueryBuilder.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ public function insertWithReturningPks(string $table, QueryInterface|array $colu
2323
$returnColumns = $this->schema->getTableSchema($table)?->getPrimaryKey();
2424

2525
if (!empty($returnColumns)) {
26-
$returnColumns = array_map(
27-
[$this->quoter, 'quoteColumnName'],
28-
$returnColumns,
29-
);
26+
$returnColumns = array_map($this->quoter->quoteColumnName(...), $returnColumns);
3027

3128
$sql .= ' RETURNING ' . implode(', ', $returnColumns);
3229
}

src/DQLQueryBuilder.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
use Yiisoft\Db\QueryBuilder\Condition\JsonOverlapsCondition;
2020
use Yiisoft\Db\QueryBuilder\Condition\LikeCondition;
2121

22-
use function array_merge;
23-
2422
/**
2523
* Implements a DQL (Data Query Language) SQL statements for PostgreSQL Server.
2624
*/
@@ -35,12 +33,13 @@ final class DQLQueryBuilder extends AbstractDQLQueryBuilder
3533
*/
3634
protected function defaultConditionClasses(): array
3735
{
38-
return array_merge(parent::defaultConditionClasses(), [
36+
return [
37+
...parent::defaultConditionClasses(),
3938
'ILIKE' => LikeCondition::class,
4039
'NOT ILIKE' => LikeCondition::class,
4140
'OR ILIKE' => LikeCondition::class,
4241
'OR NOT ILIKE' => LikeCondition::class,
43-
]);
42+
];
4443
}
4544

4645
/**
@@ -54,13 +53,14 @@ protected function defaultConditionClasses(): array
5453
*/
5554
protected function defaultExpressionBuilders(): array
5655
{
57-
return array_merge(parent::defaultExpressionBuilders(), [
56+
return [
57+
...parent::defaultExpressionBuilders(),
5858
ArrayExpression::class => ArrayExpressionBuilder::class,
5959
ArrayOverlapsCondition::class => ArrayOverlapsConditionBuilder::class,
6060
JsonExpression::class => JsonExpressionBuilder::class,
6161
JsonOverlapsCondition::class => JsonOverlapsConditionBuilder::class,
6262
StructuredExpression::class => StructuredExpressionBuilder::class,
6363
Expression::class => ExpressionBuilder::class,
64-
]);
64+
];
6565
}
6666
}

src/Schema.php

+5-8
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434
use function array_change_key_case;
3535
use function array_map;
36-
use function array_merge;
3736
use function array_unique;
3837
use function array_values;
3938
use function explode;
@@ -408,7 +407,7 @@ protected function loadTableIndexes(string $tableName): array
408407
])->queryAll();
409408

410409
/** @psalm-var array[] $indexes */
411-
$indexes = array_map('array_change_key_case', $indexes);
410+
$indexes = array_map(array_change_key_case(...), $indexes);
412411
$indexes = DbArrayHelper::index($indexes, null, ['name']);
413412
$result = [];
414413

@@ -593,7 +592,7 @@ protected function findConstraints(TableSchemaInterface $table): void
593592
foreach ($constraints as $foreingKeyName => $constraint) {
594593
$table->foreignKey(
595594
(string) $foreingKeyName,
596-
array_merge([$constraint['tableName']], $constraint['columns'])
595+
[$constraint['tableName'], ...$constraint['columns']]
597596
);
598597
}
599598
}
@@ -1001,7 +1000,7 @@ private function loadTableConstraints(string $tableName, string $returnType): ar
10011000
])->queryAll();
10021001

10031002
/** @psalm-var array[][] $constraints */
1004-
$constraints = array_map('array_change_key_case', $constraints);
1003+
$constraints = array_map(array_change_key_case(...), $constraints);
10051004
$constraints = DbArrayHelper::index($constraints, null, ['type', 'name']);
10061005

10071006
$result = [
@@ -1101,12 +1100,10 @@ protected function createColumnSchema(string $type, mixed ...$info): ColumnSchem
11011100
* @param string $name The table name.
11021101
*
11031102
* @return array The cache key.
1104-
*
1105-
* @psalm-suppress DeprecatedMethod
11061103
*/
11071104
protected function getCacheKey(string $name): array
11081105
{
1109-
return array_merge([self::class], $this->generateCacheKey(), [$this->db->getQuoter()->getRawTableName($name)]);
1106+
return [self::class, ...$this->generateCacheKey(), $this->db->getQuoter()->getRawTableName($name)];
11101107
}
11111108

11121109
/**
@@ -1118,6 +1115,6 @@ protected function getCacheKey(string $name): array
11181115
*/
11191116
protected function getCacheTag(): string
11201117
{
1121-
return md5(serialize(array_merge([self::class], $this->generateCacheKey())));
1118+
return md5(serialize([self::class, ...$this->generateCacheKey()]));
11221119
}
11231120
}

0 commit comments

Comments
 (0)