diff --git a/composer.json b/composer.json index ab45c1e..34c2f3c 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "require-dev": { "phpunit/phpunit": "^9", "flyeralarm/php-code-validator": "^3.2", - "vimeo/psalm": "^3.4" + "vimeo/psalm": "^4.6" }, "autoload": { "psr-4": { diff --git a/psalm.xml b/psalm.xml index 42f355b..7da42dd 100644 --- a/psalm.xml +++ b/psalm.xml @@ -34,7 +34,6 @@ - diff --git a/src/Client.php b/src/Client.php index 67748d8..c77cdcd 100644 --- a/src/Client.php +++ b/src/Client.php @@ -296,7 +296,7 @@ private function send(string $key, $value, string $type, float $sampleRate, arra */ public function setNamespace(string $namespace): void { - $this->namespace = (string) $namespace; + $this->namespace = $namespace; } /** diff --git a/src/Connection/File.php b/src/Connection/File.php index 51d6b87..70d67d3 100644 --- a/src/Connection/File.php +++ b/src/Connection/File.php @@ -9,7 +9,8 @@ class File implements Connection { /** - * @var null|resource|closed-resource + * @psalm-suppress PossiblyInvalidArgument + * @var null|resource */ private $handle; @@ -60,6 +61,7 @@ public function sendMessages(array $messages): void public function close(): void { if (is_resource($this->handle)) { + /** @psalm-suppress InvalidPropertyAssignmentValue */ fclose($this->handle); } diff --git a/src/Connection/InetSocket.php b/src/Connection/InetSocket.php index 2206417..e2a7946 100644 --- a/src/Connection/InetSocket.php +++ b/src/Connection/InetSocket.php @@ -64,7 +64,7 @@ public function __construct( $this->host = $host; $this->port = $port; $this->persistent = $persistent; - $this->maxPayloadSize = (int) $mtu - + $this->maxPayloadSize = $mtu - self::IP_HEADER_SIZE - $this->getProtocolHeaderSize() - strlen(self::LINE_DELIMITER); @@ -144,7 +144,9 @@ private function cutIntoMtuSizedPackets(array $messages): array if ($this->allowFragmentation()) { $message = join(self::LINE_DELIMITER, $messages) . self::LINE_DELIMITER; - return str_split($message, $this->maxPayloadSize); + $result = str_split($message, $this->maxPayloadSize); + + return $result ?: []; } $delimiterLen = strlen(self::LINE_DELIMITER);