From d59cf441b70bd31578904449a34947aac0b2a082 Mon Sep 17 00:00:00 2001 From: ADmad Date: Tue, 3 Sep 2019 19:17:28 +0530 Subject: [PATCH] Fix psalm errors in Socket --- psalm-baseline.xml | 10 ---------- src/Network/Socket.php | 4 ++++ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 9c7b310621ed..f74923641a07 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -787,16 +787,6 @@ $locale - - - [$this, '_connectionErrorHandler'] - - - $this->connection - $this->connection - $this->connection - - $class diff --git a/src/Network/Socket.php b/src/Network/Socket.php index d40d6f294b9b..6d9d400058eb 100644 --- a/src/Network/Socket.php +++ b/src/Network/Socket.php @@ -154,6 +154,7 @@ public function connect(): bool $connectAs |= STREAM_CLIENT_PERSISTENT; } + /** @psalm-suppress InvalidArgument */ set_error_handler([$this, '_connectionErrorHandler']); $remoteSocketTarget = $scheme . $this->_config['host']; $port = (int)$this->_config['port']; @@ -185,6 +186,7 @@ public function connect(): bool $this->connected = is_resource($this->connection); if ($this->connected) { + /** @psalm-suppress PossiblyNullArgument */ stream_set_timeout($this->connection, $this->_config['timeout']); } @@ -364,6 +366,7 @@ public function write(string $data): int $totalBytes = strlen($data); $written = 0; while ($written < $totalBytes) { + /** @psalm-suppress PossiblyNullArgument */ $rv = fwrite($this->connection, substr($data, $written)); if ($rv === false || $rv === 0) { return $written; @@ -387,6 +390,7 @@ public function read(int $length = 1024): ?string return null; } + /** @psalm-suppress PossiblyNullArgument */ if (!feof($this->connection)) { $buffer = fread($this->connection, $length); $info = stream_get_meta_data($this->connection);