From c015d68d8f444b819d32fccef84af0c0cf3c09bc Mon Sep 17 00:00:00 2001 From: Tigrov Date: Tue, 30 Jan 2024 14:13:54 +0700 Subject: [PATCH 1/5] Fix psalm issues --- .github/workflows/static.yml | 2 +- composer.json | 2 +- psalm.xml | 1 + src/Cache/SchemaCache.php | 4 ++-- src/Driver/Pdo/AbstractPdoCommand.php | 2 +- src/QueryBuilder/AbstractDDLQueryBuilder.php | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 301ab7c15..cc4ab5a8a 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -28,4 +28,4 @@ jobs: os: >- ['ubuntu-latest'] php: >- - ['8.1', '8.2'] + ['8.3'] diff --git a/composer.json b/composer.json index f9199cc8b..2272a2539 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ "rector/rector": "^0.19", "roave/infection-static-analysis-plugin": "^1.16", "spatie/phpunit-watcher": "^1.23", - "vimeo/psalm": "^4.30|^5.12", + "vimeo/psalm": "^5.20", "yiisoft/aliases": "^3.0", "yiisoft/cache-file": "^3.1", "yiisoft/di": "^1.0", diff --git a/psalm.xml b/psalm.xml index 54a52e176..fc5771199 100644 --- a/psalm.xml +++ b/psalm.xml @@ -16,5 +16,6 @@ + diff --git a/src/Cache/SchemaCache.php b/src/Cache/SchemaCache.php index 27a7b6d31..fcfbab66d 100644 --- a/src/Cache/SchemaCache.php +++ b/src/Cache/SchemaCache.php @@ -201,12 +201,12 @@ private function normalize(mixed $key): string if (is_string($key) || is_int($key)) { $key = (string)$key; $length = mb_strlen($key, '8bit'); - return (strpbrk($key, '{}()/\@:') || $length < 1 || $length > 64) ? md5($key) : $key; + return (strpbrk($key, '{}()/\@:') !== false || $length < 1 || $length > 64) ? md5($key) : $key; } $key = json_encode($key); - if (!$key) { + if ($key === false) { throw new PsrInvalidArgumentException('Invalid key. ' . json_last_error_msg()); } diff --git a/src/Driver/Pdo/AbstractPdoCommand.php b/src/Driver/Pdo/AbstractPdoCommand.php index 3f632e3ce..0611c834e 100644 --- a/src/Driver/Pdo/AbstractPdoCommand.php +++ b/src/Driver/Pdo/AbstractPdoCommand.php @@ -211,7 +211,7 @@ protected function internalExecute(string|null $rawSql): void } break; } catch (PDOException $e) { - $rawSql = $rawSql ?: $this->getRawSql(); + $rawSql ??= $this->getRawSql(); $e = (new ConvertException($e, $rawSql))->run(); if ($this->retryHandler === null || !($this->retryHandler)($e, $attempt)) { diff --git a/src/QueryBuilder/AbstractDDLQueryBuilder.php b/src/QueryBuilder/AbstractDDLQueryBuilder.php index d73f57853..095cf04fb 100644 --- a/src/QueryBuilder/AbstractDDLQueryBuilder.php +++ b/src/QueryBuilder/AbstractDDLQueryBuilder.php @@ -159,7 +159,7 @@ public function createIndex( string $indexType = null, string $indexMethod = null ): string { - return 'CREATE ' . ($indexType ? ($indexType . ' ') : '') . 'INDEX ' + return 'CREATE ' . (!empty($indexType) ? $indexType . ' ' : '') . 'INDEX ' . $this->quoter->quoteTableName($name) . ' ON ' . $this->quoter->quoteTableName($table) . ' (' . $this->queryBuilder->buildColumns($columns) . ')'; From 11c3bbdb06867e73ba2d698a9662c03da032c6ea Mon Sep 17 00:00:00 2001 From: Tigrov Date: Tue, 30 Jan 2024 15:20:15 +0700 Subject: [PATCH 2/5] Change to `"vimeo/psalm": "^4.30|^5.20",` --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2272a2539..61911ce17 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ "rector/rector": "^0.19", "roave/infection-static-analysis-plugin": "^1.16", "spatie/phpunit-watcher": "^1.23", - "vimeo/psalm": "^5.20", + "vimeo/psalm": "^4.30|^5.20", "yiisoft/aliases": "^3.0", "yiisoft/cache-file": "^3.1", "yiisoft/di": "^1.0", From c654a52d23dd36af187872a1fd48b67b3bee4415 Mon Sep 17 00:00:00 2001 From: Tigrov Date: Wed, 31 Jan 2024 10:44:21 +0700 Subject: [PATCH 3/5] Run psalm on PHP 8.1, 8.2, 8.3 --- .github/workflows/static.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index cc4ab5a8a..abebcd189 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -28,4 +28,4 @@ jobs: os: >- ['ubuntu-latest'] php: >- - ['8.3'] + ['8.1', '8.2', '8.3'] From eee7f380d416ef949c0383509c53c9487b7349df Mon Sep 17 00:00:00 2001 From: Tigrov Date: Wed, 31 Jan 2024 14:03:01 +0700 Subject: [PATCH 4/5] Add line to CHANGELOG.md [skip ci] --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22389beb9..face3086f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - Enh #789: Remove unnecessary type casting to array in `AbstractDMLQueryBuilder::getTableUniqueColumnNames()` (@Tigrov) - Enh #795: Allow to use `DMLQueryBuilderInterface::batchInsert()` method with empty columns (@Tigrov) - Enh #794: Add message type to log context (@darkdef) +- Enh #802: Resolve psalm issues (@Tigrov) ## 1.2.0 November 12, 2023 From fe8d87cfc4232011238c5c245ac0a190209d5dcd Mon Sep 17 00:00:00 2001 From: Sergei Tigrov Date: Sat, 3 Feb 2024 10:17:40 +0700 Subject: [PATCH 5/5] Update CHANGELOG.md [skip ci] Co-authored-by: Sergei Predvoditelev --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index face3086f..dfd63bfa1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ - Enh #789: Remove unnecessary type casting to array in `AbstractDMLQueryBuilder::getTableUniqueColumnNames()` (@Tigrov) - Enh #795: Allow to use `DMLQueryBuilderInterface::batchInsert()` method with empty columns (@Tigrov) - Enh #794: Add message type to log context (@darkdef) -- Enh #802: Resolve psalm issues (@Tigrov) +- Enh #802: Minor refactoring of `SchemaCache`, `AbstractPdoCommand` and `AbstractDDLQueryBuilder` (@Tigrov) ## 1.2.0 November 12, 2023