Skip to content

Commit

Permalink
Raise PHP version to 8.1 (#317)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov authored Aug 23, 2024
1 parent 9e39ada commit fbbd88a
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 48 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ jobs:
strategy:
matrix:
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 @@ -63,9 +62,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 }}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Chg #308: Replace call of `SchemaInterface::getRawTableName()` to `QuoterInterface::getRawTableName()` (@Tigrov)
- Enh #312: Refactor `bit` type (@Tigrov)
- Enh #315: Refactor PHP type of `ColumnSchemaInterface` instances (@Tigrov)
- Enh #317: 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 @@ -29,9 +29,9 @@ have access to a SQL Server database and the necessary credentials to connect to

## Support version

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

## Installation

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

This file was deleted.

10 changes: 5 additions & 5 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

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

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

$rectorConfig->skip([
ClosureToArrowFunctionRector::class,
JsonThrowOnErrorRector::class,
NullToStrictStringFuncCallArgRector::class,
ReadOnlyPropertyRector::class,
]);
};
6 changes: 3 additions & 3 deletions src/DQLQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Yiisoft\Db\QueryBuilder\Condition\InCondition;
use Yiisoft\Db\QueryBuilder\Condition\LikeCondition;

use function array_merge;
use function preg_match;

/**
Expand Down Expand Up @@ -47,11 +46,12 @@ public function selectExists(string $rawSql): string

protected function defaultExpressionBuilders(): array
{
return array_merge(parent::defaultExpressionBuilders(), [
return [
...parent::defaultExpressionBuilders(),
InCondition::class => InConditionBuilder::class,
LikeCondition::class => LikeConditionBuilder::class,
Expression::class => ExpressionBuilder::class,
]);
];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Quoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function getTableNameParts(string $name, bool $withColumn = false): array
if (preg_match_all('/([^.\[\]]+)|\[([^\[\]]+)]/', $name, $matches) > 0) {
$parts = array_slice($matches[0], -4, 4);

return array_map([$this, 'unquoteSimpleTableName'], $parts);
return array_map($this->unquoteSimpleTableName(...), $parts);
}

return [$this->unquoteSimpleTableName($name)];
Expand Down
11 changes: 5 additions & 6 deletions src/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Yiisoft\Db\Schema\Column\ColumnSchemaInterface;
use Yiisoft\Db\Schema\TableSchemaInterface;

use function array_change_key_case;
use function array_map;
use function explode;
use function is_array;
Expand Down Expand Up @@ -333,7 +334,7 @@ protected function loadTableIndexes(string $tableName): array
$indexes = $this->db->createCommand($sql, [':fullName' => $resolvedName->getFullName()])->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 @@ -840,7 +841,7 @@ private function loadTableConstraints(string $tableName, string $returnType): mi
$constraints = $this->db->createCommand($sql, [':fullName' => $resolvedName->getFullName()])->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 @@ -909,12 +910,10 @@ private function loadTableConstraints(string $tableName, string $returnType): mi
* @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 @@ -926,7 +925,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()]));
}

private function parseDefaultValue(string $value): string
Expand Down
5 changes: 3 additions & 2 deletions tests/SchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ function ($params) use ($expectedTableName) {

public function withIndexDataProvider(): array
{
return array_merge(parent::withIndexDataProvider(), [
return [
...parent::withIndexDataProvider(),
[
'indexType' => SchemaInterface::INDEX_CLUSTERED,
'indexMethod' => null,
Expand All @@ -166,7 +167,7 @@ public function withIndexDataProvider(): array
'indexMethod' => null,
'columnType' => 'varchar(16)',
],
]);
];
}

public function testNotConnectionPDO(): void
Expand Down

0 comments on commit fbbd88a

Please sign in to comment.