Skip to content

Commit 99bbf2e

Browse files
committed
Consistent CS to return early
1 parent ec44f5f commit 99bbf2e

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

src/Connection.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ class Connection extends Stream implements ConnectionInterface
1616
{
1717
public function handleClose()
1818
{
19-
if (is_resource($this->stream)) {
20-
// http://chat.stackoverflow.com/transcript/message/7727858#7727858
21-
stream_socket_shutdown($this->stream, STREAM_SHUT_RDWR);
22-
stream_set_blocking($this->stream, false);
23-
fclose($this->stream);
19+
if (!is_resource($this->stream)) {
20+
return;
2421
}
22+
23+
// http://chat.stackoverflow.com/transcript/message/7727858#7727858
24+
stream_socket_shutdown($this->stream, STREAM_SHUT_RDWR);
25+
stream_set_blocking($this->stream, false);
26+
fclose($this->stream);
2527
}
2628

2729
public function getRemoteAddress()

src/Server.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,13 @@ public function getPort()
141141

142142
public function shutdown()
143143
{
144-
if (is_resource($this->master)) {
145-
$this->loop->removeStream($this->master);
146-
fclose($this->master);
147-
$this->removeAllListeners();
144+
if (!is_resource($this->master)) {
145+
return;
148146
}
147+
148+
$this->loop->removeStream($this->master);
149+
fclose($this->master);
150+
$this->removeAllListeners();
149151
}
150152

151153
public function createConnection($socket)

0 commit comments

Comments
 (0)