From 617e87c30800648bdc2aa2f27533ab96931eb850 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Thu, 9 Jul 2026 09:41:44 +0300 Subject: [PATCH] Fix psalm --- .github/workflows/static.yml | 32 +++++++++++--------------------- composer.json | 5 +++-- psalm.xml | 7 +++++++ src/PgsqlMutex.php | 8 +++++++- 4 files changed, 28 insertions(+), 24 deletions(-) diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index a106b6e..475179e 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -1,25 +1,15 @@ +name: static analysis + on: pull_request: - paths-ignore: - - 'docs/**' - - 'README.md' - - 'CHANGELOG.md' - - '.gitignore' - - '.gitattributes' - - 'infection.json.dist' - - 'phpunit.xml.dist' - + paths: &paths + - '.github/workflows/static.yml' + - 'src/**' + - 'psalm*.xml' + - 'composer.json' push: - paths-ignore: - - 'docs/**' - - 'README.md' - - 'CHANGELOG.md' - - '.gitignore' - - '.gitattributes' - - 'infection.json.dist' - - 'phpunit.xml.dist' - -name: static analysis + branches: ['master'] + paths: *paths permissions: contents: read @@ -30,6 +20,6 @@ jobs: with: extensions: pdo, pdo_pgsql os: >- - ["ubuntu-latest"] + ['ubuntu-latest'] php: >- - ["8.1"] + ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5'] diff --git a/composer.json b/composer.json index f547a2e..f3ae4dc 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ "phpunit/phpunit": "^9.6.35", "roave/infection-static-analysis-plugin": "^1.16", "spatie/phpunit-watcher": "^1.23", - "vimeo/psalm": "^4.30|^5.3|^6.0" + "vimeo/psalm": "^4.30 || ^5.26.1 || ^6.16.1" }, "autoload": { "psr-4": { @@ -56,6 +56,7 @@ }, "scripts": { "test": "phpunit --testdox --no-interaction", - "test-watch": "phpunit-watcher watch" + "test-watch": "phpunit-watcher watch", + "psalm": "psalm" } } diff --git a/psalm.xml b/psalm.xml index 5a95a3a..fa5f129 100644 --- a/psalm.xml +++ b/psalm.xml @@ -1,6 +1,10 @@ + + + diff --git a/src/PgsqlMutex.php b/src/PgsqlMutex.php index c178491..373acfd 100644 --- a/src/PgsqlMutex.php +++ b/src/PgsqlMutex.php @@ -26,7 +26,13 @@ final class PgsqlMutex extends Mutex */ public function __construct(string $name, PDO $connection) { - // Converts a string into two 16-bit integer keys using the SHA1 hash function. + /** + * Converts a string into two 16-bit integer keys using the SHA1 hash function. + * + * @psalm-suppress PossiblyFalseArgument `unpack()` never returns `false` here because `sha1(...)` with raw + * output always returns a 20-byte string, which is more than enough for the 4 bytes required by the 'n2' format + * (two unsigned 16-bit big-endian integers). + */ $this->lockKeys = array_values(unpack('n2', sha1($name, true))); $this->connection = $connection;