diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a059b79..0dc72bc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -73,7 +73,7 @@ jobs: uses: ramsey/composer-install@v3 - name: Install PHP tools with phive. - run: "phive install --trust-gpg-keys 'CF1A108D0E7AE720,51C67305FFC2E5C0,99BF4D9A33D65E1E'" + run: "phive install --trust-gpg-keys 'CF1A108D0E7AE720,51C67305FFC2E5C0,99BF4D9A33D65E1E,12CE0F1D262429A5'" - name: Run phpcs if: always() @@ -82,3 +82,7 @@ jobs: - name: Run phpstan if: always() run: tools/phpstan analyse --error-format=github + + - name: Run Psalm + if: always() + run: tools/psalm --output-format=github diff --git a/.phive/phars.xml b/.phive/phars.xml index a6ccdb1..4c7f80f 100644 --- a/.phive/phars.xml +++ b/.phive/phars.xml @@ -1,4 +1,5 @@ + diff --git a/composer.json b/composer.json index c0967a4..4fcf6f6 100644 --- a/composer.json +++ b/composer.json @@ -38,8 +38,12 @@ "cs-check": "phpcs --colors -p", "cs-fix": "phpcbf --colors -p", "phpstan": "tools/phpstan analyse", - "stan": "@phpstan", + "stan": [ + "tools/phpstan analyse", + "tools/psalm" + ], "stan-baseline": "tools/phpstan --generate-baseline", + "psalm-baseline": "tools/psalm --set-baseline=psalm-baseline.xml", "stan-setup": "phive install" }, "config": { diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 0000000..ff07ef7 --- /dev/null +++ b/psalm.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + diff --git a/src/Database/Log/CakeSentryLog.php b/src/Database/Log/CakeSentryLog.php index a20413c..4e01c5c 100644 --- a/src/Database/Log/CakeSentryLog.php +++ b/src/Database/Log/CakeSentryLog.php @@ -198,7 +198,7 @@ public function log($level, string|Stringable $message, array $context = []): vo protected function isSchemaQuery(LoggedQuery $query): bool { $context = $query->getContext(); - $querystring = $context['query'] ?? false; + $querystring = $context['query'] ?? ''; if ($querystring === '') { $querystring = $query->jsonSerialize()['query'] ?? ''; diff --git a/src/DebugTimer.php b/src/DebugTimer.php index eab6679..1f22205 100644 --- a/src/DebugTimer.php +++ b/src/DebugTimer.php @@ -107,7 +107,7 @@ public static function stop(?string $name = null): bool $name = $_name . ' #' . $i; } } - if (!isset(self::$_timers[$name])) { + if ($name && !isset(self::$_timers[$name])) { return false; } if ($name !== null) { diff --git a/src/Log/Engines/SentryLog.php b/src/Log/Engines/SentryLog.php index 6d1ee34..c9511c2 100644 --- a/src/Log/Engines/SentryLog.php +++ b/src/Log/Engines/SentryLog.php @@ -35,6 +35,7 @@ public function __construct(array $config = []) * @param array $context * @return void * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint + * @psalm-suppress MoreSpecificImplementedParamType */ public function log($level, string|Stringable $message, array $context = []): void {