From db3b278eafae79eb19e626c9fedc767d455204cb Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Sat, 10 Oct 2026 00:29:57 +0400 Subject: [PATCH] fix: declare the statuses() error key as present and nullable refactor: drop the redundant Status assertion in Manager::statuses() ci: run psalm on pushes to 2.x statuses() has always returned 'error' => null for a process without an error, while the docblock declared an optional key. ClassMustBeFinal is suppressed instead of making Exception\ServiceException final, which would break users extending it. Assisted-By: Claude Opus 5.5 --- .gitattributes | 1 + .github/workflows/psalm.yml | 5 ++++- psalm.xml | 2 ++ src/Manager.php | 6 +----- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.gitattributes b/.gitattributes index b1d53fb..554d673 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7,3 +7,4 @@ testo.php export-ignore monorepo-builder.php export-ignore infection.json5 export-ignore +psalm.xml export-ignore diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml index adf59f0..b9a6420 100644 --- a/.github/workflows/psalm.yml +++ b/.github/workflows/psalm.yml @@ -1,11 +1,14 @@ on: push: branches: - - '*.*' + - 2.x pull_request: null name: static analysis +permissions: + contents: read + jobs: psalm: uses: spiral/gh-actions/.github/workflows/psalm.yml@master diff --git a/psalm.xml b/psalm.xml index 6e265d0..b904c20 100644 --- a/psalm.xml +++ b/psalm.xml @@ -9,6 +9,8 @@ findUnusedCode="false" > + + diff --git a/src/Manager.php b/src/Manager.php index c0d32d0..88b68eb 100644 --- a/src/Manager.php +++ b/src/Manager.php @@ -9,7 +9,6 @@ use RoadRunner\Service\DTO\V1\PBList; use RoadRunner\Service\DTO\V1\Response; use RoadRunner\Service\DTO\V1\Service; -use RoadRunner\Service\DTO\V1\Status; use RoadRunner\Service\DTO\V1\Statuses; use Spiral\Goridge\RPC\Codec\ProtobufCodec; use Spiral\Goridge\RPC\Exception\ServiceException; @@ -154,7 +153,7 @@ public function terminate(string $name): bool * cpu_percent: float, * memory_usage: positive-int, * pid: positive-int, - * error?: array{ + * error: null|array{ * code: int, * message: non-empty-string, * details: array{message: string, type_url: string}[] @@ -172,11 +171,8 @@ public function statuses(string $name): array \assert($response instanceof Statuses); foreach ($response->getStatus() as $status) { - \assert($status instanceof Status); - $error = null; $statusError = $status->getStatus(); - /** @psalm-suppress RedundantConditionGivenDocblockType */ if ($statusError !== null) { $error = [ 'code' => $statusError->getCode(),