Skip to content

Commit

Permalink
Fix psalm and mutation testing (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik authored Feb 16, 2024
1 parent f16c5b0 commit 642f32f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 20 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/mutation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ jobs:
- ubuntu-latest

php:
- 8.1
- 8.2
- 8.3

services:
postgres:
Expand Down Expand Up @@ -74,6 +73,6 @@ jobs:

- name: Run infection.
run: |
vendor/bin/roave-infection-static-analysis-plugin -j2 --ignore-msi-with-no-mutations --only-covered --test-framework-options="--testsuite=Pgsql"
vendor/bin/roave-infection-static-analysis-plugin --threads=2 --ignore-msi-with-no-mutations --only-covered --test-framework-options="--testsuite=Pgsql"
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
3 changes: 2 additions & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ concurrency:
cancel-in-progress: true

jobs:
mutation:
psalm:
name: PHP ${{ matrix.php }}-${{ matrix.os }}

runs-on: ${{ matrix.os }}
Expand All @@ -40,6 +40,7 @@ jobs:
php:
- '8.1'
- '8.2'
- '8.3'

steps:
- name: Checkout.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"rector/rector": "^1.0.1",
"roave/infection-static-analysis-plugin": "^1.25|^1.30",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.8|^5.8",
"vimeo/psalm": "^4.30|^5.22",
"yiisoft/cache": "^3.0",
"yiisoft/log": "^2.0"
},
Expand Down
29 changes: 16 additions & 13 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
findUnusedBaselineEntry="true"
findUnusedCode="false"
resolveFromConfigFile="true"
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"
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>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<MixedAssignment errorLevel="suppress" />
<RiskyTruthyFalsyComparison errorLevel="suppress" />
</issueHandlers>
</psalm>
5 changes: 3 additions & 2 deletions src/DbCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ public function set(string $key, mixed $value, DateInterval|int|string|null $ttl
}

try {
/**
* @psalm-suppress MixedArgumentTypeCoercion `$this->buildDataRow()` next returns `array<string, mixed>`
*/
$this->db
->createCommand()
->upsert($this->table, $this->buildDataRow($key, $ttl, $value, true))
Expand Down Expand Up @@ -158,7 +161,6 @@ public function setMultiple(iterable $values, DateInterval|int|string|null $ttl
$values = $this->iterableToArray($values);
$rows = $keys = [];

/** @psalm-var mixed $value */
foreach ($values as $key => $value) {
$key = (string) $key;
$this->validateKey($key);
Expand Down Expand Up @@ -366,7 +368,6 @@ private function validateKey(mixed $key): void
*/
private function validateKeys(array $keys): void
{
/** @psalm-var mixed $key */
foreach ($keys as $key) {
$this->validateKey($key);
}
Expand Down

0 comments on commit 642f32f

Please sign in to comment.