Skip to content

Commit

Permalink
Fix psalm issues (#288)
Browse files Browse the repository at this point in the history
Co-authored-by: Sergei Predvoditelev <[email protected]>
  • Loading branch information
Tigrov and vjik authored Feb 3, 2024
1 parent 05ebf54 commit f0acbe5
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
- '8.0'
- '8.1'
- '8.2'
- '8.3'

steps:
- name: Checkout.
Expand Down Expand Up @@ -70,4 +71,9 @@ jobs:
run: composer update --no-interaction --no-progress --optimize-autoloader --ansi

- name: Static analysis.
if: ${{ matrix.php != '8.0' }}
run: vendor/bin/psalm --config=${{ inputs.psalm-config }} --shepherd --stats --output-format=github --php-version=${{ matrix.php }}

- name: Static analysis.
if: ${{ matrix.php == '8.0' }}
run: vendor/bin/psalm --config=psalm4.xml --shepherd --stats --output-format=github --php-version=${{ matrix.php }}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Enh #281: Remove unused code in `Command` class (@vjik)
- Enh #282: Change property `Schema::$typeMap` to constant `Schema::TYPE_MAP` (@Tigrov)
- Enh #283: Remove unnecessary check for array type in `Schema::loadTableIndexes()` (@Tigrov)
- Enh #288: Minor refactoring of `DDLQueryBuilder` and `Schema` (@Tigrov)

## 1.1.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.3|^5.6",
"vimeo/psalm": "^4.30|^5.20",
"yiisoft/aliases": "^2.0",
"yiisoft/cache-file": "^3.1",
"yiisoft/json": "^1.0",
Expand Down
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
</projectFiles>
<issueHandlers>
<MixedAssignment errorLevel="suppress"/>
<RiskyTruthyFalsyComparison errorLevel="suppress" />
</issueHandlers>
</psalm>
19 changes: 19 additions & 0 deletions psalm4.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
findUnusedBaselineEntry="true"
findUnusedCode="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src"/>
<ignoreFiles>
<directory name="vendor"/>
</ignoreFiles>
</projectFiles>
<issueHandlers>
<MixedAssignment errorLevel="suppress"/>
</issueHandlers>
</psalm>
4 changes: 2 additions & 2 deletions src/DDLQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ public function createIndex(
[$schema, $table] = $tableParts;
}

return 'CREATE ' . ($indexType ? ($indexType . ' ') : '') . 'INDEX '
. $this->quoter->quoteTableName(($schema ? $schema . '.' : '') . $name)
return 'CREATE ' . (!empty($indexType) ? $indexType . ' ' : '') . 'INDEX '
. $this->quoter->quoteTableName((!empty($schema) ? $schema . '.' : '') . $name)
. ' ON '
. $this->quoter->quoteTableName($table)
. ' (' . $this->queryBuilder->buildColumns($columns) . ')';
Expand Down
2 changes: 1 addition & 1 deletion src/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ private function getJsonColumns(TableSchemaInterface $table): array
$regexp = '/\bjson_valid\(\s*["`\[]?(.+?)["`\]]?\s*\)/i';

foreach ($checks as $check) {
if (preg_match_all($regexp, $check->getExpression(), $matches, PREG_SET_ORDER)) {
if (preg_match_all($regexp, $check->getExpression(), $matches, PREG_SET_ORDER) > 0) {
foreach ($matches as $match) {
$result[] = $match[1];
}
Expand Down

0 comments on commit f0acbe5

Please sign in to comment.