Skip to content

Commit

Permalink
fix: phpstan level 9 errors (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
EJTJ3 authored Oct 28, 2024
1 parent 10f7cc0 commit 6fdbaf6
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/Connection/HMsg.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

final class HMsg implements MessageInterface
{
/**
* @var array<string, string|int|null>
*/
private array $headers;

public ?string $payload;
Expand Down
1 change: 1 addition & 0 deletions src/Connection/NatsConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ public function validatePing(): void
*/
public function request(string $subject, string $payload = '', ?string $reply = null): MessageInterface
{
/** @var string $replySubject */
$replySubject = StringUtil::isEmpty($reply) ? self::createSid() : $reply;

$sub = $this->subscribe($replySubject, null);
Expand Down
2 changes: 1 addition & 1 deletion src/Connection/ServerInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function getMaxPayload(): int
return $this->maxPayload;
}

public function getClientId(): int
public function getClientId(): ?int
{
return $this->clientId;
}
Expand Down
9 changes: 6 additions & 3 deletions src/Encoder/EncoderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@

namespace EJTJ3\PhpNats\Encoder;

/**
* @author Evert Jan Hakvoort <[email protected]>
*/
interface EncoderInterface
{
/**
* @param object|string|array<string, mixed> $payload
*/
public function encode(object|string|array $payload): string;

/**
* @return array<string, mixed>
*/
public function decode(string $payload): object|array;
}
3 changes: 2 additions & 1 deletion src/Encoder/JsonEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ public function encode(object|string|array $payload): string
}

/**
* @return array<string, mixed>
* @return array<mixed>
*/
public function decode(string $payload): array
{
// @phpstan-ignore-next-line
return json_decode($payload, true);
}
}
2 changes: 1 addition & 1 deletion src/Logger/NullLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

final class NullLogger extends AbstractLogger implements LoggerInterface
{
public function log($level, $message, array $context = []): void
public function log($level, string|\Stringable $message, array $context = []): void
{
}
}

0 comments on commit 6fdbaf6

Please sign in to comment.