Skip to content

Commit

Permalink
Fix psalm warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
xepozz committed Feb 14, 2024
1 parent 2959358 commit d0caf53
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Message/HandlerEnvelope.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public function __construct(
) {
}

Check warning on line 20 in src/Message/HandlerEnvelope.php

View check run for this annotation

Codecov / codecov/patch

src/Message/HandlerEnvelope.php#L20

Added line #L20 was not covered by tests

/**
* @psalm-param class-string<MessageHandlerInterface> $handlerClass
*/
public function setHandler(string $handlerClass): void

Check warning on line 25 in src/Message/HandlerEnvelope.php

View check run for this annotation

Codecov / codecov/patch

src/Message/HandlerEnvelope.php#L25

Added line #L25 was not covered by tests
{
$this->handlerClass = $handlerClass;

Check warning on line 27 in src/Message/HandlerEnvelope.php

View check run for this annotation

Codecov / codecov/patch

src/Message/HandlerEnvelope.php#L27

Added line #L27 was not covered by tests
Expand All @@ -29,6 +32,7 @@ public function setHandler(string $handlerClass): void
*/
public function getHandler(): string

Check warning on line 33 in src/Message/HandlerEnvelope.php

View check run for this annotation

Codecov / codecov/patch

src/Message/HandlerEnvelope.php#L33

Added line #L33 was not covered by tests
{
/** @psalm-suppress LessSpecificReturnStatement */
return $this->handlerClass ?: $this->message->getMetadata()[self::HANDLER_CLASS_KEY];

Check warning on line 36 in src/Message/HandlerEnvelope.php

View check run for this annotation

Codecov / codecov/patch

src/Message/HandlerEnvelope.php#L36

Added line #L36 was not covered by tests
}

Expand Down
12 changes: 11 additions & 1 deletion src/Message/JsonMessageSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ public function unserialize(string $value): MessageInterface
}
$class = $payload['class'] ?? Message::class;

if (!is_subclass_of($class, MessageInterface::class)) {
throw new InvalidArgumentException(sprintf(
'Class "%s" must implement "%s" interface.',
$class,
MessageInterface::class,
));
}

/**
* @var MessageInterface $message
*/
$message = new $class($payload['data'] ?? null, $meta);

if (isset($meta[EnvelopeInterface::ENVELOPE_STACK_KEY]) && is_array($meta[EnvelopeInterface::ENVELOPE_STACK_KEY])) {
Expand All @@ -57,7 +68,6 @@ public function unserialize(string $value): MessageInterface
}
}


return $message;
}
}

0 comments on commit d0caf53

Please sign in to comment.