Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise PHP version to 8.1 #356

Merged
merged 3 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ jobs:
- 16

include:
- php: 8.0
pgsql: 16
- php: 8.1
pgsql: 16
- php: 8.2
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/composer-require-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ jobs:
- ubuntu-latest

php:
- 8.0
- 8.1
- 8.2
- 8.3
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ jobs:
- ubuntu-latest

php:
- '8.0'
- '8.1'
- '8.2'
- '8.3'
Expand Down Expand Up @@ -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 }}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
- Enh #356: Raise minimum PHP version to `^8.1` with minor refactoring (@Tigrov)

## 1.3.0 March 21, 2024

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
}
],
"require": {
"php": "^8.0",
"php": "^8.1",
"ext-json": "*",
"ext-pdo": "*",
"ext-pdo_pgsql": "*",
Expand All @@ -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"
Expand Down
20 changes: 0 additions & 20 deletions psalm4.xml

This file was deleted.

8 changes: 5 additions & 3 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
]);
};
6 changes: 3 additions & 3 deletions src/Column/ArrayColumnSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions src/DMLQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
12 changes: 6 additions & 6 deletions src/DQLQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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,
]);
];
}

/**
Expand All @@ -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,
]);
];
}
}
13 changes: 5 additions & 8 deletions src/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 = [];

Expand Down Expand Up @@ -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']]
);
}
}
Expand Down Expand Up @@ -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 = [
Expand Down Expand Up @@ -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)];
}

/**
Expand All @@ -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()]));
}
}
Loading