Skip to content

Commit

Permalink
Fix psalm errors in Socket
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Sep 3, 2019
1 parent feeec53 commit d59cf44
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
10 changes: 0 additions & 10 deletions psalm-baseline.xml
Expand Up @@ -787,16 +787,6 @@
<code>$locale</code>
</PossiblyNullArgument>
</file>
<file src="src/Network/Socket.php">
<InvalidArgument occurrences="1">
<code>[$this, '_connectionErrorHandler']</code>
</InvalidArgument>
<PossiblyNullArgument occurrences="3">
<code>$this-&gt;connection</code>
<code>$this-&gt;connection</code>
<code>$this-&gt;connection</code>
</PossiblyNullArgument>
</file>
<file src="src/ORM/BehaviorRegistry.php">
<MoreSpecificImplementedParamType occurrences="1">
<code>$class</code>
Expand Down
4 changes: 4 additions & 0 deletions src/Network/Socket.php
Expand Up @@ -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'];
Expand Down Expand Up @@ -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']);
}

Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit d59cf44

Please sign in to comment.