Skip to content

Commit 6d866a3

Browse files
authored
fix: declare the statuses() error key as present and nullable (#24)
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
1 parent 4e87c63 commit 6d866a3

4 files changed

Lines changed: 8 additions & 6 deletions

File tree

‎.gitattributes‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
testo.php export-ignore
88
monorepo-builder.php export-ignore
99
infection.json5 export-ignore
10+
psalm.xml export-ignore

‎.github/workflows/psalm.yml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
on:
22
push:
33
branches:
4-
- '*.*'
4+
- 2.x
55
pull_request: null
66

77
name: static analysis
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
psalm:
1114
uses: spiral/gh-actions/.github/workflows/psalm.yml@master

‎psalm.xml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
findUnusedCode="false"
1010
>
1111
<issueHandlers>
12+
<!-- Making public classes final would break BC for users who extend them -->
13+
<ClassMustBeFinal errorLevel="suppress" />
1214
</issueHandlers>
1315
<projectFiles>
1416
<directory name="src" />

‎src/Manager.php‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use RoadRunner\Service\DTO\V1\PBList;
1010
use RoadRunner\Service\DTO\V1\Response;
1111
use RoadRunner\Service\DTO\V1\Service;
12-
use RoadRunner\Service\DTO\V1\Status;
1312
use RoadRunner\Service\DTO\V1\Statuses;
1413
use Spiral\Goridge\RPC\Codec\ProtobufCodec;
1514
use Spiral\Goridge\RPC\Exception\ServiceException;
@@ -154,7 +153,7 @@ public function terminate(string $name): bool
154153
* cpu_percent: float,
155154
* memory_usage: positive-int,
156155
* pid: positive-int,
157-
* error?: array{
156+
* error: null|array{
158157
* code: int,
159158
* message: non-empty-string,
160159
* details: array{message: string, type_url: string}[]
@@ -172,11 +171,8 @@ public function statuses(string $name): array
172171
\assert($response instanceof Statuses);
173172

174173
foreach ($response->getStatus() as $status) {
175-
\assert($status instanceof Status);
176-
177174
$error = null;
178175
$statusError = $status->getStatus();
179-
/** @psalm-suppress RedundantConditionGivenDocblockType */
180176
if ($statusError !== null) {
181177
$error = [
182178
'code' => $statusError->getCode(),

0 commit comments

Comments
 (0)