|
|
@@ -23,34 +23,6 @@ use Workerman\Events\EventInterface;
|
|
|
use Workerman\Protocols\Http\Request;
|
|
|
use Workerman\Protocols\ProtocolInterface;
|
|
|
use Workerman\Worker;
|
|
|
-use function ceil;
|
|
|
-use function count;
|
|
|
-use function fclose;
|
|
|
-use function feof;
|
|
|
-use function fread;
|
|
|
-use function function_exists;
|
|
|
-use function fwrite;
|
|
|
-use function is_object;
|
|
|
-use function is_resource;
|
|
|
-use function key;
|
|
|
-use function method_exists;
|
|
|
-use function posix_getpid;
|
|
|
-use function restore_error_handler;
|
|
|
-use function set_error_handler;
|
|
|
-use function stream_set_blocking;
|
|
|
-use function stream_set_read_buffer;
|
|
|
-use function stream_socket_enable_crypto;
|
|
|
-use function stream_socket_get_name;
|
|
|
-use function strlen;
|
|
|
-use function strrchr;
|
|
|
-use function strrpos;
|
|
|
-use function substr;
|
|
|
-use function var_export;
|
|
|
-use const PHP_INT_MAX;
|
|
|
-use const STREAM_CRYPTO_METHOD_SSLv23_CLIENT;
|
|
|
-use const STREAM_CRYPTO_METHOD_SSLv23_SERVER;
|
|
|
-use const STREAM_CRYPTO_METHOD_SSLv2_CLIENT;
|
|
|
-use const STREAM_CRYPTO_METHOD_SSLv2_SERVER;
|
|
|
|
|
|
/**
|
|
|
* TcpConnection.
|
|
|
@@ -193,7 +165,7 @@ class TcpConnection extends ConnectionInterface implements JsonSerializable
|
|
|
|
|
|
/**
|
|
|
* Sets the maximum send buffer size for the current connection.
|
|
|
- * OnBufferFull callback will be emited When send buffer is full.
|
|
|
+ * OnBufferFull callback will be emitted When send buffer is full.
|
|
|
*
|
|
|
* @var int
|
|
|
*/
|
|
|
@@ -567,7 +539,7 @@ class TcpConnection extends ConnectionInterface implements JsonSerializable
|
|
|
*
|
|
|
* @return void
|
|
|
*/
|
|
|
- public function pauseRecv()
|
|
|
+ public function pauseRecv(): void
|
|
|
{
|
|
|
$this->eventLoop->offReadable($this->socket);
|
|
|
$this->isPaused = true;
|
|
|
@@ -579,7 +551,7 @@ class TcpConnection extends ConnectionInterface implements JsonSerializable
|
|
|
* @return void
|
|
|
* @throws Throwable
|
|
|
*/
|
|
|
- public function resumeRecv()
|
|
|
+ public function resumeRecv(): void
|
|
|
{
|
|
|
if ($this->isPaused === true) {
|
|
|
$this->eventLoop->onReadable($this->socket, [$this, 'baseRead']);
|
|
|
@@ -597,7 +569,7 @@ class TcpConnection extends ConnectionInterface implements JsonSerializable
|
|
|
* @return void
|
|
|
* @throws Throwable
|
|
|
*/
|
|
|
- public function baseRead($socket, bool $checkEof = true)
|
|
|
+ public function baseRead($socket, bool $checkEof = true): void
|
|
|
{
|
|
|
static $requests = [];
|
|
|
// SSL handshake.
|
|
|
@@ -737,7 +709,7 @@ class TcpConnection extends ConnectionInterface implements JsonSerializable
|
|
|
* @return void
|
|
|
* @throws Throwable
|
|
|
*/
|
|
|
- public function baseWrite()
|
|
|
+ public function baseWrite(): void
|
|
|
{
|
|
|
$len = 0;
|
|
|
try {
|
|
|
@@ -833,7 +805,7 @@ class TcpConnection extends ConnectionInterface implements JsonSerializable
|
|
|
* @param self $dest
|
|
|
* @return void
|
|
|
*/
|
|
|
- public function pipe(self $dest)
|
|
|
+ public function pipe(self $dest): void
|
|
|
{
|
|
|
$source = $this;
|
|
|
$this->onMessage = function ($source, $data) use ($dest) {
|
|
|
@@ -856,7 +828,7 @@ class TcpConnection extends ConnectionInterface implements JsonSerializable
|
|
|
* @param int $length
|
|
|
* @return void
|
|
|
*/
|
|
|
- public function consumeRecvBuffer(int $length)
|
|
|
+ public function consumeRecvBuffer(int $length): void
|
|
|
{
|
|
|
$this->recvBuffer = substr($this->recvBuffer, $length);
|
|
|
}
|
|
|
@@ -869,7 +841,7 @@ class TcpConnection extends ConnectionInterface implements JsonSerializable
|
|
|
* @return void
|
|
|
* @throws Throwable
|
|
|
*/
|
|
|
- public function close(mixed $data = null, bool $raw = false)
|
|
|
+ public function close(mixed $data = null, bool $raw = false): void
|
|
|
{
|
|
|
if ($this->status === self::STATUS_CONNECTING) {
|
|
|
$this->destroy();
|
|
|
@@ -937,7 +909,7 @@ class TcpConnection extends ConnectionInterface implements JsonSerializable
|
|
|
* @return void
|
|
|
* @throws Throwable
|
|
|
*/
|
|
|
- protected function checkBufferWillFull()
|
|
|
+ protected function checkBufferWillFull(): void
|
|
|
{
|
|
|
if ($this->maxSendBufferSize <= strlen($this->sendBuffer)) {
|
|
|
if ($this->onBufferFull) {
|
|
|
@@ -988,7 +960,7 @@ class TcpConnection extends ConnectionInterface implements JsonSerializable
|
|
|
* @return void
|
|
|
* @throws Throwable
|
|
|
*/
|
|
|
- public function destroy()
|
|
|
+ public function destroy(): void
|
|
|
{
|
|
|
// Avoid repeated calls.
|
|
|
if ($this->status === self::STATUS_CLOSED) {
|