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 #315

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
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ jobs:
- windows-latest

php:
- 8.0
- 8.1
- 8.2
- 8.3
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 @@ -8,6 +8,7 @@
- Chg #307: Replace call of `SchemaInterface::getRawTableName()` to `QuoterInterface::getRawTableName()` (@Tigrov)
- Enh #310: Add JSON overlaps condition builder (@Tigrov)
- Enh #312: Update `bit` type according to main PR yiisoft/db#860 (@Tigrov)
- Enh #315: Raise minimum PHP version to `^8.1` with minor refactoring (@Tigrov)

## 1.2.0 March 21, 2024

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ perform advanced database operations such as joins and aggregates.

## Support version

| PHP | Sqlite Version | CI-Actions |
|-----|---------------------------|------------|
|**8.0 - 8.2**| **3:latest**|[![build](https://github.com/yiisoft/db-sqlite/actions/workflows/build.yml/badge.svg?branch=dev)](https://github.com/yiisoft/db-sqlite/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-sqlite%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/db-sqlite/master) [![static analysis](https://github.com/yiisoft/db-sqlite/actions/workflows/static.yml/badge.svg?branch=dev)](https://github.com/yiisoft/db-sqlite/actions/workflows/static.yml) [![type-coverage](https://shepherd.dev/github/yiisoft/db-sqlite/coverage.svg)](https://shepherd.dev/github/yiisoft/db-sqlite)
| PHP | Sqlite Version | CI-Actions |
|---------------|---------------------------|------------|
| **8.1 - 8.3** | **3:latest**|[![build](https://github.com/yiisoft/db-sqlite/actions/workflows/build.yml/badge.svg?branch=dev)](https://github.com/yiisoft/db-sqlite/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-sqlite%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/db-sqlite/master) [![static analysis](https://github.com/yiisoft/db-sqlite/actions/workflows/static.yml/badge.svg?branch=dev)](https://github.com/yiisoft/db-sqlite/actions/workflows/static.yml) [![type-coverage](https://shepherd.dev/github/yiisoft/db-sqlite/coverage.svg)](https://shepherd.dev/github/yiisoft/db-sqlite)

## 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-mbstring": "*",
"ext-pdo": "*",
"yiisoft/db": "dev-master",
Expand All @@ -40,11 +40,11 @@
"require-dev": {
"ext-json": "*",
"maglnet/composer-require-checker": "^4.2",
"phpunit/phpunit": "^9.6|^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/json": "^1.0",
Expand Down
19 changes: 0 additions & 19 deletions psalm4.xml

This file was deleted.

9 changes: 8 additions & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
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 @@ -22,6 +24,11 @@

// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_80,
LevelSetList::UP_TO_PHP_81,
]);

$rectorConfig->skip([
NullToStrictStringFuncCallArgRector::class,
ReadOnlyPropertyRector::class,
]);
};
5 changes: 3 additions & 2 deletions src/DQLQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,13 @@ public function buildUnion(array $unions, array &$params = []): string
*/
protected function defaultExpressionBuilders(): array
{
return array_merge(parent::defaultExpressionBuilders(), [
return [
...parent::defaultExpressionBuilders(),
JsonOverlapsCondition::class => JsonOverlapsConditionBuilder::class,
LikeCondition::class => LikeConditionBuilder::class,
InCondition::class => InConditionBuilder::class,
JsonExpression::class => JsonExpressionBuilder::class,
Expression::class => ExpressionBuilder::class,
]);
];
}
}
18 changes: 8 additions & 10 deletions src/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
use Yiisoft\Db\Schema\Column\ColumnSchemaInterface;
use Yiisoft\Db\Schema\TableSchemaInterface;

use function array_change_key_case;
use function array_column;
use function array_map;
use function array_merge;
use function count;
use function explode;
use function md5;
Expand Down Expand Up @@ -205,7 +205,7 @@ protected function loadTableForeignKeys(string $tableName): array

$foreignKeysList = $this->getPragmaForeignKeyList($tableName);
/** @psalm-var ForeignKeyInfo[] $foreignKeysList */
$foreignKeysList = array_map('array_change_key_case', $foreignKeysList);
$foreignKeysList = array_map(array_change_key_case(...), $foreignKeysList);
$foreignKeysList = DbArrayHelper::index($foreignKeysList, null, ['table']);
DbArrayHelper::multisort($foreignKeysList, 'seq');

Expand Down Expand Up @@ -409,7 +409,7 @@ protected function findConstraints(TableSchemaInterface $table): void
$columnNames = (array) $foreignKey->getColumnNames();
$columnNames = array_combine($columnNames, $foreignKey->getForeignColumnNames());

$foreignReference = array_merge([$foreignKey->getForeignTableName()], $columnNames);
$foreignReference = [$foreignKey->getForeignTableName(), ...$columnNames];

/** @psalm-suppress InvalidCast */
$table->foreignKey((string) $foreignKey->getName(), $foreignReference);
Expand Down Expand Up @@ -563,7 +563,7 @@ private function loadTableColumnsInfo(string $tableName): array
{
$tableColumns = $this->getPragmaTableInfo($tableName);
/** @psalm-var ColumnInfo[] $tableColumns */
$tableColumns = array_map('array_change_key_case', $tableColumns);
$tableColumns = array_map(array_change_key_case(...), $tableColumns);

/** @psalm-var ColumnInfo[] */
return DbArrayHelper::index($tableColumns, 'cid');
Expand All @@ -585,7 +585,7 @@ private function loadTableConstraints(string $tableName, string $returnType): Co
{
$indexList = $this->getPragmaIndexList($tableName);
/** @psalm-var IndexListInfo[] $indexes */
$indexes = array_map('array_change_key_case', $indexList);
$indexes = array_map(array_change_key_case(...), $indexList);
$result = [
self::PRIMARY_KEY => null,
self::INDEXES => [],
Expand Down Expand Up @@ -663,7 +663,7 @@ private function getPragmaIndexInfo(string $name): array
$column = $this->db
->createCommand('PRAGMA INDEX_INFO(' . (string) $this->db->getQuoter()->quoteValue($name) . ')')
->queryAll();
$column = array_map('array_change_key_case', $column);
$column = array_map(array_change_key_case(...), $column);
DbArrayHelper::multisort($column, 'seqno');

/** @psalm-var IndexInfo[] $column */
Expand Down Expand Up @@ -727,12 +727,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)];
}

/**
Expand All @@ -744,7 +742,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()]));
}

/**
Expand Down
10 changes: 4 additions & 6 deletions tests/Provider/ColumnSchemaBuilderProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ public static function types(): array
$types[0][0] = 'integer UNSIGNED NULL DEFAULT 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
Expand Down
5 changes: 3 additions & 2 deletions tests/Provider/QueryBuilderProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public static function buildCondition(): array
$buildCondition['inCondition-custom-6'],
);

return array_merge($buildCondition, [
return [
...$buildCondition,
'composite in using array objects' => [
[
'in',
Expand Down Expand Up @@ -154,7 +155,7 @@ public static function buildCondition(): array
['=', new Expression("(json_col->>'$.someKey')"), 42],
"(json_col->>'$.someKey') = :qp0", [':qp0' => 42],
],
]);
];
}

public static function insert(): array
Expand Down
Loading