From ef5391bc6632f88b24409040e91e63919058b5d1 Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Sat, 10 Oct 2026 00:15:07 +0400 Subject: [PATCH] refactor: enforce `#[\Override]` and drop unused psalm suppressions The remaining suppressions cover runtime guards against callers that ignore docblock types, and untyped class constants, which need PHP 8.3. Assisted-By: Claude Opus 5.5 --- psalm.xml | 8 +++----- src/Method.php | 3 --- src/Server.php | 3 --- tests/Stub/TestService.php | 5 +++++ 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/psalm.xml b/psalm.xml index f6603e7..e05e5e0 100644 --- a/psalm.xml +++ b/psalm.xml @@ -10,18 +10,16 @@ findUnusedPsalmSuppress="true" findUnusedBaselineEntry="true" findUnusedCode="false" - ensureOverrideAttribute="false" + ensureOverrideAttribute="true" findUnusedVariablesAndParams="true" ensureArrayStringOffsetsExist="true" addParamDefaultToDocblockType="true" > + - - - - + diff --git a/src/Method.php b/src/Method.php index b1e821a..fcebbad 100644 --- a/src/Method.php +++ b/src/Method.php @@ -124,7 +124,6 @@ private static function assertContextParameter(\ReflectionMethod $method, \Refle // If the type is not declared as a generic "mixed" or "object", // then it can only be a type that implements ContextInterface. if (!\in_array($type->getName(), ['mixed', 'object'], true)) { - /** @psalm-suppress ArgumentTypeCoercion */ $isContextImplementedType = !$type->isBuiltin() && (new \ReflectionClass($type->getName()))->implementsInterface(ContextInterface::class); @@ -172,7 +171,6 @@ private static function assertInputParameter(\ReflectionMethod $method, \Reflect throw new \DomainException($message, 0x05); } - /** @psalm-suppress ArgumentTypeCoercion */ $isProtobufMessageType = !$type->isBuiltin() && (new \ReflectionClass($type->getName())) ->isSubclassOf(Message::class); @@ -207,7 +205,6 @@ private static function assertOutputReturnType(\ReflectionMethod $method): void throw new \DomainException($message, 0x08); } - /** @psalm-suppress ArgumentTypeCoercion */ $isProtobufMessageType = !$type->isBuiltin() && (new \ReflectionClass($type->getName()))->isSubclassOf(Message::class); diff --git a/src/Server.php b/src/Server.php index 78607fc..a782314 100644 --- a/src/Server.php +++ b/src/Server.php @@ -140,9 +140,6 @@ private function workerError(WorkerInterface $worker, string $message): void $worker->error($message); } - /** - * @psalm-suppress InaccessibleMethod - */ private function workerSend(WorkerInterface $worker, string $body, string $headers): void { $worker->respond(new Payload($body, $headers)); diff --git a/tests/Stub/TestService.php b/tests/Stub/TestService.php index b98d914..23730ab 100644 --- a/tests/Stub/TestService.php +++ b/tests/Stub/TestService.php @@ -15,11 +15,13 @@ class TestService implements TestInterface { + #[Override] public function Echo(ContextInterface $ctx, Message $in): Message { return $in->setMsg('pong'); } + #[Override] public function Throw(ContextInterface $ctx, Message $in): Message { $out = new Message(); @@ -55,6 +57,7 @@ public function Throw(ContextInterface $ctx, Message $in): Message return $out; } + #[Override] public function Die(ContextInterface $ctx, Message $in): Message { \error_log($in->getMsg()); @@ -62,6 +65,7 @@ public function Die(ContextInterface $ctx, Message $in): Message return $in; } + #[Override] public function Info(ContextInterface $ctx, Message $in): Message { $out = new Message(); @@ -86,6 +90,7 @@ public function Info(ContextInterface $ctx, Message $in): Message return $out; } + #[Override] public function Ping(GRPC\ContextInterface $ctx, EmptyMessage $in): EmptyMessage { return new EmptyMessage();