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

Fix psalm issues #802

Merged
merged 5 commits into from
Feb 3, 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
2 changes: 1 addition & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.1', '8.2']
['8.1', '8.2', '8.3']
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: Minor refactoring of `SchemaCache`, `AbstractPdoCommand` and `AbstractDDLQueryBuilder` (@Tigrov)

## 1.2.0 November 12, 2023

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "^4.30|^5.20",
"yiisoft/aliases": "^3.0",
"yiisoft/cache-file": "^3.1",
"yiisoft/di": "^1.0",
Expand Down
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
</projectFiles>
<issueHandlers>
<MixedAssignment errorLevel="suppress" />
<RiskyTruthyFalsyComparison errorLevel="suppress" />
</issueHandlers>
</psalm>
4 changes: 2 additions & 2 deletions src/Cache/SchemaCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
2 changes: 1 addition & 1 deletion src/Driver/Pdo/AbstractPdoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/QueryBuilder/AbstractDDLQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) . ')';
Expand Down