Skip to content

Commit 4a08ca3

Browse files
Tigrovvjik
andauthored
Fix psalm issues (#802)
Co-authored-by: Sergei Predvoditelev <[email protected]>
1 parent 9b10e92 commit 4a08ca3

File tree

7 files changed

+8
-6
lines changed

7 files changed

+8
-6
lines changed

.github/workflows/static.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ jobs:
2828
os: >-
2929
['ubuntu-latest']
3030
php: >-
31-
['8.1', '8.2']
31+
['8.1', '8.2', '8.3']

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Enh #789: Remove unnecessary type casting to array in `AbstractDMLQueryBuilder::getTableUniqueColumnNames()` (@Tigrov)
1919
- Enh #795: Allow to use `DMLQueryBuilderInterface::batchInsert()` method with empty columns (@Tigrov)
2020
- Enh #794: Add message type to log context (@darkdef)
21+
- Enh #802: Minor refactoring of `SchemaCache`, `AbstractPdoCommand` and `AbstractDDLQueryBuilder` (@Tigrov)
2122

2223
## 1.2.0 November 12, 2023
2324

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"rector/rector": "^0.19",
3535
"roave/infection-static-analysis-plugin": "^1.16",
3636
"spatie/phpunit-watcher": "^1.23",
37-
"vimeo/psalm": "^4.30|^5.12",
37+
"vimeo/psalm": "^4.30|^5.20",
3838
"yiisoft/aliases": "^3.0",
3939
"yiisoft/cache-file": "^3.1",
4040
"yiisoft/di": "^1.0",

psalm.xml

+1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616
</projectFiles>
1717
<issueHandlers>
1818
<MixedAssignment errorLevel="suppress" />
19+
<RiskyTruthyFalsyComparison errorLevel="suppress" />
1920
</issueHandlers>
2021
</psalm>

src/Cache/SchemaCache.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,12 @@ private function normalize(mixed $key): string
201201
if (is_string($key) || is_int($key)) {
202202
$key = (string)$key;
203203
$length = mb_strlen($key, '8bit');
204-
return (strpbrk($key, '{}()/\@:') || $length < 1 || $length > 64) ? md5($key) : $key;
204+
return (strpbrk($key, '{}()/\@:') !== false || $length < 1 || $length > 64) ? md5($key) : $key;
205205
}
206206

207207
$key = json_encode($key);
208208

209-
if (!$key) {
209+
if ($key === false) {
210210
throw new PsrInvalidArgumentException('Invalid key. ' . json_last_error_msg());
211211
}
212212

src/Driver/Pdo/AbstractPdoCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ protected function internalExecute(string|null $rawSql): void
211211
}
212212
break;
213213
} catch (PDOException $e) {
214-
$rawSql = $rawSql ?: $this->getRawSql();
214+
$rawSql ??= $this->getRawSql();
215215
$e = (new ConvertException($e, $rawSql))->run();
216216

217217
if ($this->retryHandler === null || !($this->retryHandler)($e, $attempt)) {

src/QueryBuilder/AbstractDDLQueryBuilder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public function createIndex(
159159
string $indexType = null,
160160
string $indexMethod = null
161161
): string {
162-
return 'CREATE ' . ($indexType ? ($indexType . ' ') : '') . 'INDEX '
162+
return 'CREATE ' . (!empty($indexType) ? $indexType . ' ' : '') . 'INDEX '
163163
. $this->quoter->quoteTableName($name)
164164
. ' ON ' . $this->quoter->quoteTableName($table)
165165
. ' (' . $this->queryBuilder->buildColumns($columns) . ')';

0 commit comments

Comments
 (0)