Skip to content

Commit f0acbe5

Browse files
Tigrovvjik
andauthored
Fix psalm issues (#288)
Co-authored-by: Sergei Predvoditelev <sergei@predvoditelev.ru>
1 parent 05ebf54 commit f0acbe5

File tree

7 files changed

+31
-4
lines changed

7 files changed

+31
-4
lines changed

.github/workflows/static.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
- '8.0'
4040
- '8.1'
4141
- '8.2'
42+
- '8.3'
4243

4344
steps:
4445
- name: Checkout.
@@ -70,4 +71,9 @@ jobs:
7071
run: composer update --no-interaction --no-progress --optimize-autoloader --ansi
7172

7273
- name: Static analysis.
74+
if: ${{ matrix.php != '8.0' }}
7375
run: vendor/bin/psalm --config=${{ inputs.psalm-config }} --shepherd --stats --output-format=github --php-version=${{ matrix.php }}
76+
77+
- name: Static analysis.
78+
if: ${{ matrix.php == '8.0' }}
79+
run: vendor/bin/psalm --config=psalm4.xml --shepherd --stats --output-format=github --php-version=${{ matrix.php }}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Enh #281: Remove unused code in `Command` class (@vjik)
66
- Enh #282: Change property `Schema::$typeMap` to constant `Schema::TYPE_MAP` (@Tigrov)
77
- Enh #283: Remove unnecessary check for array type in `Schema::loadTableIndexes()` (@Tigrov)
8+
- Enh #288: Minor refactoring of `DDLQueryBuilder` and `Schema` (@Tigrov)
89

910
## 1.1.0 November 12, 2023
1011

composer.json

Lines changed: 1 addition & 1 deletion
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.3|^5.6",
37+
"vimeo/psalm": "^4.30|^5.20",
3838
"yiisoft/aliases": "^2.0",
3939
"yiisoft/cache-file": "^3.1",
4040
"yiisoft/json": "^1.0",

psalm.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
</projectFiles>
1616
<issueHandlers>
1717
<MixedAssignment errorLevel="suppress"/>
18+
<RiskyTruthyFalsyComparison errorLevel="suppress" />
1819
</issueHandlers>
1920
</psalm>

psalm4.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
errorLevel="1"
4+
findUnusedBaselineEntry="true"
5+
findUnusedCode="false"
6+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7+
xmlns="https://getpsalm.org/schema/config"
8+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
9+
>
10+
<projectFiles>
11+
<directory name="src"/>
12+
<ignoreFiles>
13+
<directory name="vendor"/>
14+
</ignoreFiles>
15+
</projectFiles>
16+
<issueHandlers>
17+
<MixedAssignment errorLevel="suppress"/>
18+
</issueHandlers>
19+
</psalm>

src/DDLQueryBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ public function createIndex(
105105
[$schema, $table] = $tableParts;
106106
}
107107

108-
return 'CREATE ' . ($indexType ? ($indexType . ' ') : '') . 'INDEX '
109-
. $this->quoter->quoteTableName(($schema ? $schema . '.' : '') . $name)
108+
return 'CREATE ' . (!empty($indexType) ? $indexType . ' ' : '') . 'INDEX '
109+
. $this->quoter->quoteTableName((!empty($schema) ? $schema . '.' : '') . $name)
110110
. ' ON '
111111
. $this->quoter->quoteTableName($table)
112112
. ' (' . $this->queryBuilder->buildColumns($columns) . ')';

src/Schema.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ private function getJsonColumns(TableSchemaInterface $table): array
752752
$regexp = '/\bjson_valid\(\s*["`\[]?(.+?)["`\]]?\s*\)/i';
753753

754754
foreach ($checks as $check) {
755-
if (preg_match_all($regexp, $check->getExpression(), $matches, PREG_SET_ORDER)) {
755+
if (preg_match_all($regexp, $check->getExpression(), $matches, PREG_SET_ORDER) > 0) {
756756
foreach ($matches as $match) {
757757
$result[] = $match[1];
758758
}

0 commit comments

Comments
 (0)