Completed
Branch master (ec9c11)
by y
01:23
created
src/AbstractClient.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
      *
19 19
      * @return string
20 20
      */
21
-    public function __toString () {
21
+    public function __toString() {
22 22
         try {
23 23
             return implode(':', $this->getPeerName());
24 24
         }
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      * @return $this
42 42
      * @throws SocketError
43 43
      */
44
-    public function connect (string $address, int $port = 0) {
44
+    public function connect(string $address, int $port = 0) {
45 45
         if (!@socket_connect($this->resource, $address, $port)) {
46 46
             // ignore expected errors for non-blocking connections
47 47
             $errno = SocketError::getLast($this->resource);
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      * @return array `[ 0 => address, 1 => port ]`
62 62
      * @throws SocketError
63 63
      */
64
-    public function getPeerName (): array {
64
+    public function getPeerName(): array {
65 65
         if ($this->getDomain() === AF_UNIX) {
66 66
             return [$this->getOption(17), 0]; // SO_PEERCRED is not exposed by PHP
67 67
         }
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      * @return int Total bytes sent.
82 82
      * @throws SocketError
83 83
      */
84
-    public function send (string $data, int $flags = 0): int {
84
+    public function send(string $data, int $flags = 0): int {
85 85
         $count = @socket_send($this->resource, $data, strlen($data), $flags);
86 86
         if ($count === false) {
87 87
             throw new SocketError($this->resource); // reliable errno
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
      * @return $this
97 97
      * @throws SocketError `int` total bytes sent is set as the extra data.
98 98
      */
99
-    public function write (string $data) {
99
+    public function write(string $data) {
100 100
         $length = strlen($data);
101 101
         $total = 0;
102 102
         while ($total < $length) {
Please login to merge, or discard this patch.
src/SocketInterface.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,20 +27,20 @@
 block discarded – undo
27 27
      *
28 28
      * @return int
29 29
      */
30
-    public function getId (): int;
30
+    public function getId(): int;
31 31
 
32 32
     /**
33 33
      * Returns the underlying socket resource.
34 34
      *
35 35
      * @return resource
36 36
      */
37
-    public function getResource ();
37
+    public function getResource();
38 38
 
39 39
     /**
40 40
      * Whether the underlying resource is usable.
41 41
      *
42 42
      * @return bool
43 43
      */
44
-    public function isOpen (): bool;
44
+    public function isOpen(): bool;
45 45
 
46 46
 }
47 47
\ No newline at end of file
Please login to merge, or discard this patch.
src/SocketError.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      * @param resource $resource PHP socket resource, or `null` for the global error.
30 30
      * @return int If the resource is closed or not a socket, `SOCKET_EBADF` is returned.
31 31
      */
32
-    public static function getLast ($resource = null) {
32
+    public static function getLast($resource = null) {
33 33
         if (isset($resource)) {
34 34
             if (@get_resource_type($resource) !== 'Socket') {
35 35
                 return SOCKET_EBADF; // Bad file descriptor
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
      * @param int $fallback Code to assume if one can't be found via the subject.
63 63
      * @param SocketError|null $previous Slippage of a prior error.
64 64
      */
65
-    public function __construct ($subject = null, $fallback = 0, SocketError $previous = null) {
65
+    public function __construct($subject = null, $fallback = 0, SocketError $previous = null) {
66 66
         if ($errno = is_int($subject) ? $subject : static::getLast($subject)) {
67 67
             $message = socket_strerror($errno);
68 68
         }
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
     /**
78 78
      * @return mixed
79 79
      */
80
-    public function getExtra () {
80
+    public function getExtra() {
81 81
         return $this->extra;
82 82
     }
83 83
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
      * @param mixed $extra
86 86
      * @return $this
87 87
      */
88
-    public function setExtra ($extra) {
88
+    public function setExtra($extra) {
89 89
         $this->extra = $extra;
90 90
         return $this;
91 91
     }
Please login to merge, or discard this patch.
src/WebSocket/FrameHandler.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -53,21 +53,21 @@  discard block
 block discarded – undo
53 53
      */
54 54
     protected $text = '';
55 55
 
56
-    public function __construct (WebSocketClient $client) {
56
+    public function __construct(WebSocketClient $client) {
57 57
         $this->client = $client;
58 58
     }
59 59
 
60 60
     /**
61 61
      * @return int
62 62
      */
63
-    public function getFragmentSize (): int {
63
+    public function getFragmentSize(): int {
64 64
         return $this->fragmentSize;
65 65
     }
66 66
 
67 67
     /**
68 68
      * @return int
69 69
      */
70
-    public function getMaxLength (): int {
70
+    public function getMaxLength(): int {
71 71
         return $this->maxLength;
72 72
     }
73 73
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
      * @param Frame $binary
80 80
      * @throws WebSocketError
81 81
      */
82
-    protected function onBinary (Frame $binary): void {
82
+    protected function onBinary(Frame $binary): void {
83 83
         $this->binary .= $binary->getPayload();
84 84
         if ($binary->isFinal()) {
85 85
             $message = $this->binary;
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
      *
100 100
      * @param Frame $close
101 101
      */
102
-    protected function onClose (Frame $close): void {
102
+    protected function onClose(Frame $close): void {
103 103
         $this->client->close($close->getCloseCode());
104 104
     }
105 105
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      * @param Frame $frame
110 110
      * @throws WebSocketError
111 111
      */
112
-    protected function onContinue (Frame $frame): void {
112
+    protected function onContinue(Frame $frame): void {
113 113
         switch ($this->continue) {
114 114
             case Frame::OP_TEXT:
115 115
                 $this->onText($frame);
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
      *
136 136
      * @param Frame $control
137 137
      */
138
-    protected function onControl (Frame $control): void {
138
+    protected function onControl(Frame $control): void {
139 139
         if ($control->isClose()) {
140 140
             $this->onClose($control);
141 141
         }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
      *
153 153
      * @param Frame $data
154 154
      */
155
-    protected function onData (Frame $data): void {
155
+    protected function onData(Frame $data): void {
156 156
         if (!$data->isFinal()) {
157 157
             $this->onData_SetContinue($data);
158 158
         }
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         }
165 165
     }
166 166
 
167
-    protected function onData_SetContinue (Frame $data): void {
167
+    protected function onData_SetContinue(Frame $data): void {
168 168
         if ($this->continue) {
169 169
             $existing = Frame::NAMES[$this->continue];
170 170
             throw new WebSocketError(
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
      *
184 184
      * @param Frame $frame
185 185
      */
186
-    public function onFrame (Frame $frame): void {
186
+    public function onFrame(Frame $frame): void {
187 187
         $this->onFrame_CheckRsv($frame);
188 188
         $this->onFrame_CheckLength($frame);
189 189
         if ($frame->isControl()) {
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
     /**
201 201
      * @param Frame $frame
202 202
      */
203
-    protected function onFrame_CheckLength (Frame $frame): void {
203
+    protected function onFrame_CheckLength(Frame $frame): void {
204 204
         if ($frame->isData()) {
205 205
             if ($frame->isBinary()) {
206 206
                 $length = strlen($this->binary);
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
      * @param Frame $frame
225 225
      * @throws WebSocketError
226 226
      */
227
-    protected function onFrame_CheckRsv (Frame $frame): void {
227
+    protected function onFrame_CheckRsv(Frame $frame): void {
228 228
         if ($badRsv = $frame->getRsv() & ~$this->client->getHandshake()->getRsv()) {
229 229
             $badRsv = str_pad(base_convert($badRsv >> 4, 10, 2), 3, '0', STR_PAD_LEFT);
230 230
             throw new WebSocketError(Frame::CLOSE_PROTOCOL_ERROR, "Received unknown RSV bits: 0b{$badRsv}");
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
      *
239 239
      * @param Frame $ping
240 240
      */
241
-    protected function onPing (Frame $ping): void {
241
+    protected function onPing(Frame $ping): void {
242 242
         $this->writePong($ping->getPayload());
243 243
     }
244 244
 
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
      *
250 250
      * @param Frame $pong
251 251
      */
252
-    protected function onPong (Frame $pong): void {
252
+    protected function onPong(Frame $pong): void {
253 253
         // stub
254 254
     }
255 255
 
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
      * @param Frame $text
262 262
      * @throws WebSocketError
263 263
      */
264
-    protected function onText (Frame $text): void {
264
+    protected function onText(Frame $text): void {
265 265
         $this->text .= $text->getPayload();
266 266
         if ($text->isFinal()) {
267 267
             $message = $this->text;
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
      * @param int $bytes
275 275
      * @return $this
276 276
      */
277
-    public function setFragmentSize (int $bytes) {
277
+    public function setFragmentSize(int $bytes) {
278 278
         $this->fragmentSize = $bytes;
279 279
         return $this;
280 280
     }
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
      * @param int $bytes
284 284
      * @return $this
285 285
      */
286
-    public function setMaxLength (int $bytes) {
286
+    public function setMaxLength(int $bytes) {
287 287
         $this->maxLength = $bytes;
288 288
         return $this;
289 289
     }
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
      * @param int $opCode
295 295
      * @param string $payload
296 296
      */
297
-    public function write (int $opCode, string $payload): void {
297
+    public function write(int $opCode, string $payload): void {
298 298
         $offset = 0;
299 299
         $total = strlen($payload);
300 300
         do {
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
     /**
311 311
      * @param string $payload
312 312
      */
313
-    public function writeBinary (string $payload): void {
313
+    public function writeBinary(string $payload): void {
314 314
         $this->write(Frame::OP_BINARY, $payload);
315 315
     }
316 316
 
@@ -318,8 +318,8 @@  discard block
 block discarded – undo
318 318
      * @param int $code
319 319
      * @param string $reason
320 320
      */
321
-    public function writeClose (int $code = Frame::CLOSE_NORMAL, string $reason = ''): void {
322
-        $this->writeFrame(true, Frame::OP_CLOSE, pack('n', $code) . $reason);
321
+    public function writeClose(int $code = Frame::CLOSE_NORMAL, string $reason = ''): void {
322
+        $this->writeFrame(true, Frame::OP_CLOSE, pack('n', $code).$reason);
323 323
     }
324 324
 
325 325
     /**
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
      * @param int $opCode
330 330
      * @param string $payload
331 331
      */
332
-    protected function writeFrame (bool $final, int $opCode, string $payload): void {
332
+    protected function writeFrame(bool $final, int $opCode, string $payload): void {
333 333
         if ($opCode & 0x08 and !$final) {
334 334
             throw new WebSocketError(
335 335
                 Frame::CLOSE_INTERNAL_ERROR,
@@ -349,27 +349,27 @@  discard block
 block discarded – undo
349 349
         else {
350 350
             $head .= chr($length);
351 351
         }
352
-        $this->client->write($head . $payload);
352
+        $this->client->write($head.$payload);
353 353
     }
354 354
 
355 355
     /**
356 356
      * @param string $payload
357 357
      */
358
-    public function writePing (string $payload = ''): void {
358
+    public function writePing(string $payload = ''): void {
359 359
         $this->writeFrame(true, Frame::OP_PING, $payload);
360 360
     }
361 361
 
362 362
     /**
363 363
      * @param string $payload
364 364
      */
365
-    public function writePong (string $payload = ''): void {
365
+    public function writePong(string $payload = ''): void {
366 366
         $this->writeFrame(true, Frame::OP_PONG, $payload);
367 367
     }
368 368
 
369 369
     /**
370 370
      * @param string $payload
371 371
      */
372
-    public function writeText (string $payload): void {
372
+    public function writeText(string $payload): void {
373 373
         $this->write(Frame::OP_TEXT, $payload);
374 374
     }
375 375
 }
376 376
\ No newline at end of file
Please login to merge, or discard this patch.
src/WebSocket/WebSocketServer.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      * @param $resource
30 30
      * @param Reactor $reactor
31 31
      */
32
-    public function __construct ($resource, Reactor $reactor) {
32
+    public function __construct($resource, Reactor $reactor) {
33 33
         parent::__construct($resource);
34 34
         $reactor->add($this);
35 35
         $this->reactor = $reactor;
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
     /**
39 39
      * @return WebSocketClient
40 40
      */
41
-    public function accept () {
41
+    public function accept() {
42 42
         /** @var WebSocketClient $client */
43 43
         $client = parent::accept();
44 44
         $this->clients[$client->getId()] = $client;
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
      * @param int $opCode
53 53
      * @param string $payload
54 54
      */
55
-    public function broadcast (int $opCode, string $payload) {
55
+    public function broadcast(int $opCode, string $payload) {
56 56
         foreach ($this->clients as $client) {
57 57
             if ($client->isOk()) {
58 58
                 $client->getFrameHandler()->write($opCode, $payload);
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     /**
64 64
      * @param string $payload
65 65
      */
66
-    public function broadcastBinary (string $payload) {
66
+    public function broadcastBinary(string $payload) {
67 67
         $this->broadcast(Frame::OP_BINARY, $payload);
68 68
     }
69 69
 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      *
73 73
      * @param string $payload
74 74
      */
75
-    public function broadcastPing (string $payload = '') {
75
+    public function broadcastPing(string $payload = '') {
76 76
         $this->broadcast(Frame::OP_PING, $payload);
77 77
     }
78 78
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      *
82 82
      * @param string $text
83 83
      */
84
-    public function broadcastText (string $text) {
84
+    public function broadcastText(string $text) {
85 85
         $this->broadcast(Frame::OP_TEXT, $text);
86 86
     }
87 87
 
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      * @param string $reason
93 93
      * @return StreamServer
94 94
      */
95
-    public function close (int $code = Frame::CLOSE_INTERRUPT, $reason = '') {
95
+    public function close(int $code = Frame::CLOSE_INTERRUPT, $reason = '') {
96 96
         foreach ($this->clients as $client) {
97 97
             try {
98 98
                 $client->close($code, $reason);
@@ -110,14 +110,14 @@  discard block
 block discarded – undo
110 110
      *
111 111
      * @return int
112 112
      */
113
-    public function count (): int {
113
+    public function count(): int {
114 114
         return count($this->clients);
115 115
     }
116 116
 
117 117
     /**
118 118
      * @return WebSocketClient[]
119 119
      */
120
-    public function getClients () {
120
+    public function getClients() {
121 121
         return $this->clients;
122 122
     }
123 123
 
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
      * @param resource $resource
126 126
      * @return WebSocketClient
127 127
      */
128
-    protected function newClient ($resource) {
128
+    protected function newClient($resource) {
129 129
         return new WebSocketClient($resource, $this);
130 130
     }
131 131
 
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
      *
135 135
      * @inheritDoc
136 136
      */
137
-    final public function onOutOfBand (): void {
137
+    final public function onOutOfBand(): void {
138 138
     }
139 139
 
140 140
     /**
141 141
      * @inheritDoc
142 142
      */
143
-    public function onReadable (): void {
143
+    public function onReadable(): void {
144 144
         $this->accept();
145 145
     }
146 146
 
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
      *
150 150
      * @param WebSocketClient $client
151 151
      */
152
-    public function remove (WebSocketClient $client) {
152
+    public function remove(WebSocketClient $client) {
153 153
         unset($this->clients[$client->getId()]);
154 154
         $this->reactor->remove($client);
155 155
     }
Please login to merge, or discard this patch.
src/WebSocket/WebSocketClient.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      * @param $resource
52 52
      * @param WebSocketServer $server
53 53
      */
54
-    public function __construct ($resource, WebSocketServer $server) {
54
+    public function __construct($resource, WebSocketServer $server) {
55 55
         parent::__construct($resource);
56 56
         $this->server = $server;
57 57
     }
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      * @param string $reason
75 75
      * @return StreamClient|void
76 76
      */
77
-    public function close (int $code = null, string $reason = '') {
77
+    public function close(int $code = null, string $reason = '') {
78 78
         try {
79 79
             if ($code >= 1000 and $this->state === self::STATE_OK) {
80 80
                 $this->getFrameHandler()->writeClose($code, $reason);
@@ -91,49 +91,49 @@  discard block
 block discarded – undo
91 91
     /**
92 92
      * @return FrameHandler
93 93
      */
94
-    public function getFrameHandler () {
94
+    public function getFrameHandler() {
95 95
         return $this->frameHandler ?? $this->frameHandler = new FrameHandler($this);
96 96
     }
97 97
 
98 98
     /**
99 99
      * @return FrameReader
100 100
      */
101
-    public function getFrameReader () {
101
+    public function getFrameReader() {
102 102
         return $this->frameReader ?? $this->frameReader = new FrameReader($this);
103 103
     }
104 104
 
105 105
     /**
106 106
      * @return HandShake
107 107
      */
108
-    public function getHandshake () {
108
+    public function getHandshake() {
109 109
         return $this->handshake ?? $this->handshake = new HandShake($this);
110 110
     }
111 111
 
112 112
     /**
113 113
      * @return MessageHandler
114 114
      */
115
-    public function getMessageHandler () {
115
+    public function getMessageHandler() {
116 116
         return $this->messageHandler ?? $this->messageHandler = new MessageHandler($this);
117 117
     }
118 118
 
119 119
     /**
120 120
      * @return WebSocketServer
121 121
      */
122
-    public function getServer () {
122
+    public function getServer() {
123 123
         return $this->server;
124 124
     }
125 125
 
126 126
     /**
127 127
      * @return int
128 128
      */
129
-    public function getState (): int {
129
+    public function getState(): int {
130 130
         return $this->state;
131 131
     }
132 132
 
133 133
     /**
134 134
      * @return bool
135 135
      */
136
-    final public function isOk (): bool {
136
+    final public function isOk(): bool {
137 137
         return $this->state === self::STATE_OK;
138 138
     }
139 139
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
      *
143 143
      * The RFC says the connection must be dropped if any unsupported activity occurs.
144 144
      */
145
-    final public function onOutOfBand (): void {
145
+    final public function onOutOfBand(): void {
146 146
         $this->close(Frame::CLOSE_PROTOCOL_ERROR, "Received out-of-band data.");
147 147
     }
148 148
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
      *
152 152
      * @throws Exception
153 153
      */
154
-    public function onReadable (): void {
154
+    public function onReadable(): void {
155 155
         if (!strlen($this->recv(1, MSG_PEEK))) { // peer has shut down writing, or closed.
156 156
             $this->close();
157 157
             return;
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
     /**
188 188
      * Stub.
189 189
      */
190
-    protected function onStateOk (): void {
190
+    protected function onStateOk(): void {
191 191
 
192 192
     }
193 193
 
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
      * @param FrameHandler $frameHandler
196 196
      * @return $this
197 197
      */
198
-    public function setFrameHandler (FrameHandler $frameHandler) {
198
+    public function setFrameHandler(FrameHandler $frameHandler) {
199 199
         $this->frameHandler = $frameHandler;
200 200
         return $this;
201 201
     }
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
      * @param FrameReader $frameReader
205 205
      * @return $this
206 206
      */
207
-    public function setFrameReader (FrameReader $frameReader) {
207
+    public function setFrameReader(FrameReader $frameReader) {
208 208
         $this->frameReader = $frameReader;
209 209
         return $this;
210 210
     }
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
      * @param MessageHandler $messageHandler
214 214
      * @return $this
215 215
      */
216
-    public function setMessageHandler (MessageHandler $messageHandler) {
216
+    public function setMessageHandler(MessageHandler $messageHandler) {
217 217
         $this->messageHandler = $messageHandler;
218 218
         return $this;
219 219
     }
Please login to merge, or discard this patch.
src/WebSocket/MessageHandler.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@  discard block
 block discarded – undo
12 12
     /**
13 13
      * @param WebSocketClient $client
14 14
      */
15
-    public function __construct (WebSocketClient $client) {
15
+    public function __construct(WebSocketClient $client) {
16 16
         $this->client = $client;
17 17
     }
18 18
 
19 19
     /**
20 20
      * @param string $binary
21 21
      */
22
-    public function onBinary (string $binary): void {
22
+    public function onBinary(string $binary): void {
23 23
         unset($binary);
24 24
         throw new WebSocketError(Frame::CLOSE_UNHANDLED_DATA, "I don't handle binary data.");
25 25
     }
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     /**
28 28
      * @param string $text
29 29
      */
30
-    public function onText (string $text): void {
30
+    public function onText(string $text): void {
31 31
         $this->onText_CheckUtf8($text);
32 32
         throw new WebSocketError(Frame::CLOSE_UNHANDLED_DATA, "I don't handle text.");
33 33
     }
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      *
38 38
      * @param string $text
39 39
      */
40
-    protected function onText_CheckUtf8 (string $text): void {
40
+    protected function onText_CheckUtf8(string $text): void {
41 41
         if (!mb_detect_encoding($text, 'UTF-8', true)) {
42 42
             throw new WebSocketError(Frame::CLOSE_BAD_DATA, "Received TEXT is not UTF-8.");
43 43
         }
Please login to merge, or discard this patch.
src/WebSocket/FrameReader.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
      */
47 47
     protected $maxLength = 10 * 1024 * 1024;
48 48
 
49
-    public function __construct (WebSocketClient $client) {
49
+    public function __construct(WebSocketClient $client) {
50 50
         $this->client = $client;
51 51
     }
52 52
 
53 53
     /**
54 54
      * @return Frame|null
55 55
      */
56
-    protected function getFrame () {
56
+    protected function getFrame() {
57 57
         if (!$this->head) {
58 58
             if (preg_match(self::REGEXP, $this->buffer, $head)) {
59 59
                 [, $op, $len] = unpack('C2', $head[0]);
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
      *
96 96
      * @return Generator|Frame[]
97 97
      */
98
-    public function getFrames () {
98
+    public function getFrames() {
99 99
         $this->buffer .= $this->client->recvAll();
100 100
         while ($frame = $this->getFrame()) {
101 101
             yield $frame;
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
     /**
106 106
      * @return int
107 107
      */
108
-    public function getMaxLength (): int {
108
+    public function getMaxLength(): int {
109 109
         return $this->maxLength;
110 110
     }
111 111
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
      * @param int $bytes
114 114
      * @return $this
115 115
      */
116
-    public function setMaxLength (int $bytes) {
116
+    public function setMaxLength(int $bytes) {
117 117
         if ($bytes < self::MAX_LENGTH_RANGE[0] or $bytes > self::MAX_LENGTH_RANGE[1]) {
118 118
             throw new InvalidArgumentException('Max length must be within range [125,2^63-1]');
119 119
         }
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      *
127 127
      * @throws WebSocketError
128 128
      */
129
-    protected function validate (): void {
129
+    protected function validate(): void {
130 130
         if ($this->head['length'] > $this->maxLength) {
131 131
             throw new WebSocketError(Frame::CLOSE_TOO_LARGE, "Payload would exceed {$this->maxLength} bytes");
132 132
         }
Please login to merge, or discard this patch.
src/AbstractServer.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
      *
19 19
      * @return string
20 20
      */
21
-    public function __toString () {
21
+    public function __toString() {
22 22
         try {
23 23
             return implode(':', $this->getSockName());
24 24
         }
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      * @return $this
41 41
      * @throws SocketError
42 42
      */
43
-    public function bind (string $address, int $port = 0) {
43
+    public function bind(string $address, int $port = 0) {
44 44
         if (!@socket_bind($this->resource, $address, $port)) {
45 45
             throw new SocketError($this->resource, SOCKET_EOPNOTSUPP);
46 46
         }
Please login to merge, or discard this patch.