Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,16 @@
findUnusedPsalmSuppress="true"
findUnusedBaselineEntry="true"
findUnusedCode="false"
ensureOverrideAttribute="false"
ensureOverrideAttribute="true"
findUnusedVariablesAndParams="true"
ensureArrayStringOffsetsExist="true"
addParamDefaultToDocblockType="true"
>
<issueHandlers>
<!-- Runtime guards for callers that ignore docblock types (Context offsets, service interface NAME). -->
<RedundantConditionGivenDocblockType errorLevel="suppress" />
<MixedReturnStatement errorLevel="suppress" />
<UnusedPsalmSuppress errorLevel="suppress" />
<InvalidAttribute errorLevel="suppress" />
<UndefinedAttributeClass errorLevel="suppress" />
<DocblockTypeContradiction errorLevel="suppress" />
<!-- Typed class constants need PHP 8.3, the package supports 8.2. -->
<MissingClassConstType errorLevel="suppress" />
</issueHandlers>
<projectFiles>
Expand Down
3 changes: 0 additions & 3 deletions src/Method.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@
// 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()

Check warning on line 127 in src/Method.php

View workflow job for this annotation

GitHub Actions / mutation

Escaped Mutant for Mutator "LogicalAnd": @@ @@ // 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)) { - $isContextImplementedType = !$type->isBuiltin() - && (new \ReflectionClass($type->getName()))->implementsInterface(ContextInterface::class); + $isContextImplementedType = !$type->isBuiltin() || (new \ReflectionClass($type->getName()))->implementsInterface(ContextInterface::class); // Checking that the signature can accept the context. //
&& (new \ReflectionClass($type->getName()))->implementsInterface(ContextInterface::class);

// Checking that the signature can accept the context.
Expand All @@ -135,13 +134,13 @@
// class Spiral\RoadRunner\GRPC\Context, it may cause an error.
// It might make sense to check for such cases?
if (!$isContextImplementedType) {
$message = \vsprintf(self::ERROR_PARAM_CONTEXT_TYPE, [

Check warning on line 137 in src/Method.php

View workflow job for this annotation

GitHub Actions / mutation

Escaped Mutant for Mutator "ArrayItemRemoval": @@ @@ // It might make sense to check for such cases? if (!$isContextImplementedType) { $message = \vsprintf(self::ERROR_PARAM_CONTEXT_TYPE, [ - $context->getName(), $method->getName(), ContextInterface::class, ]);
$context->getName(),
$method->getName(),
ContextInterface::class,
]);

throw new \DomainException($message, 0x03);

Check warning on line 143 in src/Method.php

View workflow job for this annotation

GitHub Actions / mutation

Escaped Mutant for Mutator "IncrementInteger": @@ @@ ContextInterface::class, ]); - throw new \DomainException($message, 0x03); + throw new \DomainException($message, 4); } } }

Check warning on line 143 in src/Method.php

View workflow job for this annotation

GitHub Actions / mutation

Escaped Mutant for Mutator "Throw_": @@ @@ ContextInterface::class, ]); - throw new \DomainException($message, 0x03); + new \DomainException($message, 0x03); } } }

Check warning on line 143 in src/Method.php

View workflow job for this annotation

GitHub Actions / mutation

Escaped Mutant for Mutator "DecrementInteger": @@ @@ ContextInterface::class, ]); - throw new \DomainException($message, 0x03); + throw new \DomainException($message, 2); } } }
}
}
}
Expand Down Expand Up @@ -172,19 +171,18 @@
throw new \DomainException($message, 0x05);
}

/** @psalm-suppress ArgumentTypeCoercion */
$isProtobufMessageType = !$type->isBuiltin()
&& (new \ReflectionClass($type->getName()))
->isSubclassOf(Message::class);

if (!$isProtobufMessageType) {
$message = \vsprintf(self::ERROR_PARAM_INPUT_TYPE, [

Check warning on line 179 in src/Method.php

View workflow job for this annotation

GitHub Actions / mutation

Escaped Mutant for Mutator "ArrayItemRemoval": @@ @@ if (!$isProtobufMessageType) { $message = \vsprintf(self::ERROR_PARAM_INPUT_TYPE, [ - $input->getName(), $method->getName(), Message::class, $type->getName(),
$input->getName(),
$method->getName(),
Message::class,
$type->getName(),
]);
throw new \DomainException($message, 0x06);

Check warning on line 185 in src/Method.php

View workflow job for this annotation

GitHub Actions / mutation

Escaped Mutant for Mutator "IncrementInteger": @@ @@ Message::class, $type->getName(), ]); - throw new \DomainException($message, 0x06); + throw new \DomainException($message, 7); } }

Check warning on line 185 in src/Method.php

View workflow job for this annotation

GitHub Actions / mutation

Escaped Mutant for Mutator "DecrementInteger": @@ @@ Message::class, $type->getName(), ]); - throw new \DomainException($message, 0x06); + throw new \DomainException($message, 5); } }
}
}

Expand All @@ -207,13 +205,12 @@
throw new \DomainException($message, 0x08);
}

/** @psalm-suppress ArgumentTypeCoercion */
$isProtobufMessageType = !$type->isBuiltin()
&& (new \ReflectionClass($type->getName()))->isSubclassOf(Message::class);

if (!$isProtobufMessageType) {
$message = \sprintf(self::ERROR_RETURN_TYPE, $method->getName(), Message::class, $type->getName());
throw new \DomainException($message, 0x09);

Check warning on line 213 in src/Method.php

View workflow job for this annotation

GitHub Actions / mutation

Escaped Mutant for Mutator "DecrementInteger": @@ @@ if (!$isProtobufMessageType) { $message = \sprintf(self::ERROR_RETURN_TYPE, $method->getName(), Message::class, $type->getName()); - throw new \DomainException($message, 0x09); + throw new \DomainException($message, 8); } }
}
}

Expand Down
3 changes: 0 additions & 3 deletions src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
5 changes: 5 additions & 0 deletions tests/Stub/TestService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -55,13 +57,15 @@ public function Throw(ContextInterface $ctx, Message $in): Message
return $out;
}

#[Override]
public function Die(ContextInterface $ctx, Message $in): Message
{
\error_log($in->getMsg());

return $in;
}

#[Override]
public function Info(ContextInterface $ctx, Message $in): Message
{
$out = new Message();
Expand All @@ -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();
Expand Down
Loading