瀏覽代碼

Return; by default return null

Joanhey 6 年之前
父節點
當前提交
19b289eae9
共有 3 個文件被更改,包括 9 次插入11 次删除
  1. 1 1
      Connection/AsyncUdpConnection.php
  2. 7 9
      Connection/TcpConnection.php
  3. 1 1
      Connection/UdpConnection.php

+ 1 - 1
Connection/AsyncUdpConnection.php

@@ -121,7 +121,7 @@ class AsyncUdpConnection extends UdpConnection
             $parser      = $this->protocol;
             $send_buffer = $parser::encode($send_buffer, $this);
             if ($send_buffer === '') {
-                return null;
+                return;
             }
         }
         if ($this->connected === false) {

+ 7 - 9
Connection/TcpConnection.php

@@ -343,22 +343,20 @@ class TcpConnection extends ConnectionInterface
             $parser      = $this->protocol;
             $send_buffer = $parser::encode($send_buffer, $this);
             if ($send_buffer === '') {
-                return null;
+                return;
             }
         }
 
         if ($this->_status !== self::STATUS_ESTABLISHED ||
             ($this->transport === 'ssl' && $this->_sslHandshakeCompleted !== true)
         ) {
-            if ($this->_sendBuffer) {
-                if ($this->bufferIsFull()) {
-                    self::$statistics['send_fail']++;
-                    return false;
-                }
+            if ($this->_sendBuffer && $this->bufferIsFull()) {
+                self::$statistics['send_fail']++;
+                return false;
             }
             $this->_sendBuffer .= $send_buffer;
             $this->checkBufferWillFull();
-            return null;
+            return;
         }
 
         // Attempt to send data directly.
@@ -367,7 +365,7 @@ class TcpConnection extends ConnectionInterface
                 Worker::$globalEvent->add($this->_socket, EventInterface::EV_WRITE, array($this, 'baseWrite'));
                 $this->_sendBuffer = $send_buffer;
                 $this->checkBufferWillFull();
-                return null;
+                return;
             }
             \set_error_handler(function(){});
             $len = \fwrite($this->_socket, $send_buffer);
@@ -404,7 +402,7 @@ class TcpConnection extends ConnectionInterface
             Worker::$globalEvent->add($this->_socket, EventInterface::EV_WRITE, array($this, 'baseWrite'));
             // Check if the send buffer will be full.
             $this->checkBufferWillFull();
-            return null;
+            return;
         } else {
             if ($this->bufferIsFull()) {
                 self::$statistics['send_fail']++;

+ 1 - 1
Connection/UdpConnection.php

@@ -65,7 +65,7 @@ class UdpConnection extends ConnectionInterface
             $parser      = $this->protocol;
             $send_buffer = $parser::encode($send_buffer, $this);
             if ($send_buffer === '') {
-                return null;
+                return;
             }
         }
         return \strlen($send_buffer) === \stream_socket_sendto($this->_socket, $send_buffer, 0, $this->_remoteAddress);