Skip to content

Commit 04225cd

Browse files
authored
Merge pull request #246 from clue-labs/php8-closed
Socket address of closed socket should be null (support PHP 8)
2 parents 3fab905 + 5cdf2ec commit 04225cd

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Connection.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,20 @@ public function handleClose()
138138

139139
public function getRemoteAddress()
140140
{
141-
return $this->parseAddress(@\stream_socket_get_name($this->stream, true));
141+
if (!\is_resource($this->stream)) {
142+
return null;
143+
}
144+
145+
return $this->parseAddress(\stream_socket_get_name($this->stream, true));
142146
}
143147

144148
public function getLocalAddress()
145149
{
146-
return $this->parseAddress(@\stream_socket_get_name($this->stream, false));
150+
if (!\is_resource($this->stream)) {
151+
return null;
152+
}
153+
154+
return $this->parseAddress(\stream_socket_get_name($this->stream, false));
147155
}
148156

149157
private function parseAddress($address)

0 commit comments

Comments
 (0)