Browse Source

analyse fix: Binary operation "^" between bool|float|int|string and string results in an error

Chance 2 years ago
parent
commit
683ef384ac
1 changed files with 2 additions and 6 deletions
  1. 2 6
      src/Protocols/Ws.php

+ 2 - 6
src/Protocols/Ws.php

@@ -233,17 +233,13 @@ class Ws
     /**
      * Websocket encode.
      *
-     * @param mixed $payload
+     * @param string $payload
      * @param AsyncTcpConnection $connection
      * @return string
      * @throws Throwable
      */
-    public static function encode(mixed $payload, AsyncTcpConnection $connection): string
+    public static function encode(string $payload, AsyncTcpConnection $connection): string
     {
-        if (!is_scalar($payload)) {
-            throw new Exception("You can't send(" . gettype($payload) . ") to client, you need to convert it to string. ");
-        }
-
         if (empty($connection->websocketType)) {
             $connection->websocketType = self::BINARY_TYPE_BLOB;
         }