diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0da2c5a87..f03eb0110 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,7 +34,6 @@ jobs: - windows-latest php: - - 8.0 - 8.1 - 8.2 - 8.3 diff --git a/.github/workflows/composer-require-checker.yml b/.github/workflows/composer-require-checker.yml index 15cafd128..798c9df64 100644 --- a/.github/workflows/composer-require-checker.yml +++ b/.github/workflows/composer-require-checker.yml @@ -25,4 +25,4 @@ jobs: os: >- ['ubuntu-latest'] php: >- - ['8.0', '8.1', '8.2', '8.3'] + ['8.1', '8.2', '8.3'] diff --git a/.github/workflows/db-mariadb.yml b/.github/workflows/db-mariadb.yml index 074b0d8f7..4772ca5cc 100644 --- a/.github/workflows/db-mariadb.yml +++ b/.github/workflows/db-mariadb.yml @@ -44,8 +44,6 @@ jobs: - mariadb:latest include: - - php: 8.0 - mariadb: mariadb:latest - php: 8.1 mariadb: mariadb:latest - php: 8.2 diff --git a/.github/workflows/db-mssql.yml b/.github/workflows/db-mssql.yml index 84a737761..885f136fb 100644 --- a/.github/workflows/db-mssql.yml +++ b/.github/workflows/db-mssql.yml @@ -32,7 +32,6 @@ jobs: strategy: matrix: php: - - 8.0 - 8.1 - 8.2 - 8.3 diff --git a/.github/workflows/db-mysql.yml b/.github/workflows/db-mysql.yml index 89282d572..6493a9a89 100644 --- a/.github/workflows/db-mysql.yml +++ b/.github/workflows/db-mysql.yml @@ -39,8 +39,6 @@ jobs: - mysql:latest include: - - php: 8.0 - mysql: mysql:latest - php: 8.1 mysql: mysql:latest - php: 8.2 diff --git a/.github/workflows/db-oracle.yml b/.github/workflows/db-oracle.yml index 6c2d86597..40343234c 100644 --- a/.github/workflows/db-oracle.yml +++ b/.github/workflows/db-oracle.yml @@ -39,8 +39,6 @@ jobs: - 21 include: - - php: 8.0 - oracle: 21 - php: 8.1 oracle: 21 - php: 8.2 diff --git a/.github/workflows/db-pgsql.yml b/.github/workflows/db-pgsql.yml index b881db376..5bf9fc51b 100644 --- a/.github/workflows/db-pgsql.yml +++ b/.github/workflows/db-pgsql.yml @@ -45,8 +45,6 @@ jobs: - 16 include: - - php: 8.0 - pgsql: 16 - php: 8.1 pgsql: 16 - php: 8.2 diff --git a/.github/workflows/db-sqlite.yml b/.github/workflows/db-sqlite.yml index af67bbbc3..e605a4682 100644 --- a/.github/workflows/db-sqlite.yml +++ b/.github/workflows/db-sqlite.yml @@ -36,7 +36,6 @@ jobs: - windows-latest php: - - 8.0 - 8.1 - 8.2 - 8.3 diff --git a/CHANGELOG.md b/CHANGELOG.md index 614264c5e..550d21e56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ - Enh #855: Add array and JSON overlaps conditions (@Tigrov) - Enh #860: Add `bit` abstract type (@Tigrov) - Enh #862: Refactor PHP type of `ColumnSchemaInterface` instances (@Tigrov) +- Enh #865: Raise minimum PHP version to `^8.1` with minor refactoring (@Tigrov, @vjik) - Enh #798: Allow `QueryInterface::one()` and `QueryInterface::all()` to return objects (@darkdef, @Tigrov) ## 1.3.0 March 21, 2024 diff --git a/README.md b/README.md index 1a8c84be3..91e9a430f 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ similar to the way you would use ORM (Object-Relational Mapping) frameworks like ## Requirements -- PHP 8.0 or higher. +- PHP 8.1 or higher. ## Documentation diff --git a/composer.json b/composer.json index 88ca23d33..9bcedb8b6 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ } ], "require": { - "php": "^8.0", + "php": "^8.1", "ext-ctype": "*", "ext-json": "*", "ext-mbstring": "*", @@ -40,11 +40,11 @@ }, "require-dev": { "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.24", + "vimeo/psalm": "^5.25", "yiisoft/aliases": "^3.0", "yiisoft/cache-file": "^3.1", "yiisoft/di": "^1.0", @@ -52,7 +52,7 @@ "yiisoft/json": "^1.0", "yiisoft/log": "^2.0", "yiisoft/var-dumper": "^1.5", - "yiisoft/yii-debug": "dev-master|dev-php80" + "yiisoft/yii-debug": "dev-master" }, "autoload": { "psr-4": { diff --git a/rector.php b/rector.php index c80d86e9a..f6ac9c870 100644 --- a/rector.php +++ b/rector.php @@ -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\Property\ReadOnlyPropertyRector; +use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector; use Rector\Set\ValueObject\LevelSetList; return static function (RectorConfig $rectorConfig): void { @@ -19,11 +19,11 @@ // define sets of rules $rectorConfig->sets([ - LevelSetList::UP_TO_PHP_80, + LevelSetList::UP_TO_PHP_81, ]); $rectorConfig->skip([ - ClosureToArrowFunctionRector::class, - JsonThrowOnErrorRector::class, + ReadOnlyPropertyRector::class, + NullToStrictStringFuncCallArgRector::class, ]); }; diff --git a/src/Debug/CommandInterfaceProxy.php b/src/Debug/CommandInterfaceProxy.php index ed513f8ee..ddd0fc36f 100644 --- a/src/Debug/CommandInterfaceProxy.php +++ b/src/Debug/CommandInterfaceProxy.php @@ -20,7 +20,7 @@ public function __construct( } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function addCheck(string $table, string $name, string $expression): static { @@ -28,7 +28,7 @@ public function addCheck(string $table, string $name, string $expression): stati } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function addColumn(string $table, string $column, ColumnInterface|string $type): static { @@ -36,7 +36,7 @@ public function addColumn(string $table, string $column, ColumnInterface|string } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function addCommentOnColumn(string $table, string $column, string $comment): static { @@ -44,7 +44,7 @@ public function addCommentOnColumn(string $table, string $column, string $commen } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function addCommentOnTable(string $table, string $comment): static { @@ -52,7 +52,7 @@ public function addCommentOnTable(string $table, string $comment): static } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function addDefaultValue(string $table, string $name, string $column, mixed $value): static { @@ -60,7 +60,7 @@ public function addDefaultValue(string $table, string $name, string $column, mix } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function addForeignKey( string $table, @@ -75,7 +75,7 @@ public function addForeignKey( } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function addPrimaryKey(string $table, string $name, array|string $columns): static { @@ -83,7 +83,7 @@ public function addPrimaryKey(string $table, string $name, array|string $columns } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function addUnique(string $table, string $name, array|string $columns): static { @@ -91,7 +91,7 @@ public function addUnique(string $table, string $name, array|string $columns): s } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function alterColumn(string $table, string $column, ColumnInterface|string $type): static { @@ -99,7 +99,7 @@ public function alterColumn(string $table, string $column, ColumnInterface|strin } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function insertBatch(string $table, iterable $rows, array $columns = []): static { @@ -107,7 +107,7 @@ public function insertBatch(string $table, iterable $rows, array $columns = []): } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function bindParam( int|string $name, @@ -120,7 +120,7 @@ public function bindParam( } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function bindValue(int|string $name, mixed $value, int $dataType = null): static { @@ -128,7 +128,7 @@ public function bindValue(int|string $name, mixed $value, int $dataType = null): } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function bindValues(array $values): static { @@ -141,7 +141,7 @@ public function cancel(): void } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function checkIntegrity(string $schema, string $table, bool $check = true): static { @@ -149,7 +149,7 @@ public function checkIntegrity(string $schema, string $table, bool $check = true } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function createIndex( string $table, @@ -162,7 +162,7 @@ public function createIndex( } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function createTable(string $table, array $columns, string $options = null): static { @@ -170,7 +170,7 @@ public function createTable(string $table, array $columns, string $options = nul } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function createView(string $viewName, QueryInterface|string $subQuery): static { @@ -178,7 +178,7 @@ public function createView(string $viewName, QueryInterface|string $subQuery): s } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function delete(string $table, array|string $condition = '', array $params = []): static { @@ -186,7 +186,7 @@ public function delete(string $table, array|string $condition = '', array $param } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function dropCheck(string $table, string $name): static { @@ -194,7 +194,7 @@ public function dropCheck(string $table, string $name): static } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function dropColumn(string $table, string $column): static { @@ -202,7 +202,7 @@ public function dropColumn(string $table, string $column): static } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function dropCommentFromColumn(string $table, string $column): static { @@ -210,7 +210,7 @@ public function dropCommentFromColumn(string $table, string $column): static } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function dropCommentFromTable(string $table): static { @@ -218,7 +218,7 @@ public function dropCommentFromTable(string $table): static } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function dropDefaultValue(string $table, string $name): static { @@ -226,7 +226,7 @@ public function dropDefaultValue(string $table, string $name): static } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function dropForeignKey(string $table, string $name): static { @@ -234,7 +234,7 @@ public function dropForeignKey(string $table, string $name): static } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function dropIndex(string $table, string $name): static { @@ -242,7 +242,7 @@ public function dropIndex(string $table, string $name): static } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function dropPrimaryKey(string $table, string $name): static { @@ -250,7 +250,7 @@ public function dropPrimaryKey(string $table, string $name): static } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function dropTable(string $table): static { @@ -258,7 +258,7 @@ public function dropTable(string $table): static } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function dropUnique(string $table, string $name): static { @@ -266,7 +266,7 @@ public function dropUnique(string $table, string $name): static } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function dropView(string $viewName): static { @@ -308,7 +308,7 @@ public function getSql(): string } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function insert(string $table, QueryInterface|array $columns): static { @@ -425,7 +425,7 @@ public function queryScalar(): bool|string|null|int|float } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function renameColumn(string $table, string $oldName, string $newName): static { @@ -433,7 +433,7 @@ public function renameColumn(string $table, string $oldName, string $newName): s } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function renameTable(string $table, string $newName): static { @@ -441,7 +441,7 @@ public function renameTable(string $table, string $newName): static } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function resetSequence(string $table, int|string $value = null): static { @@ -449,7 +449,7 @@ public function resetSequence(string $table, int|string $value = null): static } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function setRawSql(string $sql): static { @@ -457,7 +457,7 @@ public function setRawSql(string $sql): static } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function setRetryHandler(?Closure $handler): static { @@ -465,7 +465,7 @@ public function setRetryHandler(?Closure $handler): static } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function setSql(string $sql): static { @@ -473,7 +473,7 @@ public function setSql(string $sql): static } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function truncateTable(string $table): static { @@ -481,7 +481,7 @@ public function truncateTable(string $table): static } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function update(string $table, array $columns, array|string $condition = '', array $params = []): static { @@ -489,7 +489,7 @@ public function update(string $table, array $columns, array|string $condition = } /** - * @psalm-suppress MixedArgument + * @psalm-suppress MixedArgument */ public function upsert( string $table, diff --git a/src/Helper/DbArrayHelper.php b/src/Helper/DbArrayHelper.php index a5059a73b..cb824dccd 100644 --- a/src/Helper/DbArrayHelper.php +++ b/src/Helper/DbArrayHelper.php @@ -52,9 +52,7 @@ final class DbArrayHelper public static function getColumn(array $array, string $name): array { return array_map( - static function (array|object $element) use ($name): mixed { - return self::getValueByPath($element, $name); - }, + static fn (array|object $element): mixed => self::getValueByPath($element, $name), $array ); } diff --git a/src/QueryBuilder/AbstractDMLQueryBuilder.php b/src/QueryBuilder/AbstractDMLQueryBuilder.php index 0b283bb76..7097b0f4a 100644 --- a/src/QueryBuilder/AbstractDMLQueryBuilder.php +++ b/src/QueryBuilder/AbstractDMLQueryBuilder.php @@ -91,7 +91,7 @@ public function insertBatch(string $table, iterable $rows, array $columns = [], $query = 'INSERT INTO ' . $this->quoter->quoteTableName($table); if (count($columns) > 0) { - $quotedColumnNames = array_map([$this->quoter, 'quoteColumnName'], $columns); + $quotedColumnNames = array_map($this->quoter->quoteColumnName(...), $columns); $query .= ' (' . implode(', ', $quotedColumnNames) . ')'; } @@ -413,7 +413,7 @@ protected function prepareUpsertColumns( $insertNames = $this->getNormalizeColumnNames(array_keys($insertColumns)); $insertNames = array_map( - [$this->quoter, 'quoteColumnName'], + $this->quoter->quoteColumnName(...), $insertNames, ); } @@ -491,7 +491,7 @@ static function (Constraint $constraint) use ($quoter, $columns, &$columnNames): $constraintColumnNames = (array) $constraint->getColumnNames(); $constraintColumnNames = array_map( - [$quoter, 'quoteColumnName'], + $quoter->quoteColumnName(...), $constraintColumnNames, ); diff --git a/src/Schema/Quoter.php b/src/Schema/Quoter.php index 7ec65b4eb..1c130a9d6 100644 --- a/src/Schema/Quoter.php +++ b/src/Schema/Quoter.php @@ -99,7 +99,7 @@ public function getTableNameParts(string $name): array { $parts = array_slice(explode('.', $name), -2, 2); - return array_map([$this, 'unquoteSimpleTableName'], $parts); + return array_map($this->unquoteSimpleTableName(...), $parts); } public function ensureNameQuoted(string $name): string diff --git a/tests/Common/CommonColumnSchemaBuilderTest.php b/tests/Common/CommonColumnSchemaBuilderTest.php index e5adac2ea..9817a5f40 100644 --- a/tests/Common/CommonColumnSchemaBuilderTest.php +++ b/tests/Common/CommonColumnSchemaBuilderTest.php @@ -12,7 +12,6 @@ use Yiisoft\Db\Tests\Support\TestTrait; use function array_shift; -use function call_user_func_array; abstract class CommonColumnSchemaBuilderTest extends TestCase { @@ -87,7 +86,7 @@ protected function checkBuildString(string $expected, string $type, int|null $le foreach ($calls as $call) { $method = array_shift($call); - call_user_func_array([$builder, $method], $call); + ($builder->$method(...))(...$call); } $this->assertSame($expected, $builder->asString()); @@ -116,7 +115,7 @@ protected function checkCreateColumn(string $expected, string $type, int|null $l foreach ($calls as $call) { $method = array_shift($call); - call_user_func_array([$builder, $method], $call); + ($builder->$method(...))(...$call); } $tableName = '{{%column_schema_builder_types}}'; diff --git a/tests/Common/CommonCommandTest.php b/tests/Common/CommonCommandTest.php index 2c8d7d31b..3dcf8f15d 100644 --- a/tests/Common/CommonCommandTest.php +++ b/tests/Common/CommonCommandTest.php @@ -27,7 +27,6 @@ use Yiisoft\Db\Tests\Support\Stub\Column; use Yiisoft\Db\Transaction\TransactionInterface; -use function call_user_func_array; use function is_string; use function setlocale; @@ -2002,7 +2001,7 @@ protected function performAndCompareUpsertResult(PdoConnectionInterface $db, arr $command = $db->createCommand(); - call_user_func_array([$command, 'upsert'], $params); + ($command->upsert(...))(...$params); $command->execute(); diff --git a/tests/Provider/PopulateProvider.php b/tests/Provider/PopulateProvider.php index a5537f454..cfd4d0126 100644 --- a/tests/Provider/PopulateProvider.php +++ b/tests/Provider/PopulateProvider.php @@ -28,9 +28,7 @@ public static function populateWithIndexByClosure(): array { return [ [ - static function ($row) { - return $row['key']; - }, + static fn($row) => $row['key'], [ ['key' => 'value1'], ['key' => 'value2'], diff --git a/tests/Support/Stub/DQLQueryBuilder.php b/tests/Support/Stub/DQLQueryBuilder.php index 72924bbbf..00e8350a5 100644 --- a/tests/Support/Stub/DQLQueryBuilder.php +++ b/tests/Support/Stub/DQLQueryBuilder.php @@ -11,8 +11,9 @@ final class DQLQueryBuilder extends AbstractDQLQueryBuilder { protected function defaultExpressionBuilders(): array { - return array_merge(parent::defaultExpressionBuilders(), [ + return [ + ...parent::defaultExpressionBuilders(), Expression::class => ExpressionBuilder::class, - ]); + ]; } }