Completed
Push — master ( 5ca077...18143e )
by y
01:27
created
src/DatagramClient.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
      *
13 13
      * @return int
14 14
      */
15
-    final public static function getType (): int {
15
+    final public static function getType(): int {
16 16
         return SOCK_DGRAM;
17 17
     }
18 18
 
Please login to merge, or discard this patch.
src/ReactiveInterface.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@
 block discarded – undo
14 14
      *
15 15
      * @return void
16 16
      */
17
-    public function onOutOfBand (): void;
17
+    public function onOutOfBand(): void;
18 18
 
19 19
     /**
20 20
      * Called by the reactor when the socket has readable data.
21 21
      *
22 22
      * @return void
23 23
      */
24
-    public function onReadable (): void;
24
+    public function onReadable(): void;
25 25
 
26 26
 }
27 27
\ No newline at end of file
Please login to merge, or discard this patch.
src/WebSocket/HandShake.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -45,32 +45,32 @@  discard block
 block discarded – undo
45 45
      */
46 46
     protected $sizeLimit = 4096;
47 47
 
48
-    public function __construct (WebSocketClient $client) {
48
+    public function __construct(WebSocketClient $client) {
49 49
         $this->client = $client;
50 50
     }
51 51
 
52 52
     /**
53 53
      * @return string[]
54 54
      */
55
-    public function getHeaders () {
55
+    public function getHeaders() {
56 56
         return $this->headers;
57 57
     }
58 58
 
59 59
     /**
60 60
      * @return string
61 61
      */
62
-    public function getMethod (): string {
62
+    public function getMethod(): string {
63 63
         return $this->method;
64 64
     }
65 65
 
66 66
     /**
67 67
      * @return int
68 68
      */
69
-    public function getRsv (): int {
69
+    public function getRsv(): int {
70 70
         return $this->rsv;
71 71
     }
72 72
 
73
-    public function negotiate (): bool {
73
+    public function negotiate(): bool {
74 74
         $this->buffer .= $this->client->recvAll();
75 75
         try {
76 76
             if (strlen($this->buffer) > $this->sizeLimit) {
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
                 $key = strtolower(trim($key));
91 91
                 $value = trim($value);
92 92
                 if (isset($this->headers[$key])) {
93
-                    $this->headers[$key] .= ', ' . $value;
93
+                    $this->headers[$key] .= ', '.$value;
94 94
                 }
95 95
                 else {
96 96
                     $this->headers[$key] = $value;
@@ -108,19 +108,19 @@  discard block
 block discarded – undo
108 108
         }
109 109
     }
110 110
 
111
-    protected function upgrade (): void {
111
+    protected function upgrade(): void {
112 112
         $this->client->write(implode("\r\n", [
113 113
             "HTTP/1.1 101 Switching Protocols",
114 114
             "Connection: Upgrade",
115 115
             "Upgrade: websocket",
116
-            "Sec-WebSocket-Accept: " . base64_encode(sha1($this->headers['sec-websocket-key'] . self::RFC_GUID, true)),
116
+            "Sec-WebSocket-Accept: ".base64_encode(sha1($this->headers['sec-websocket-key'].self::RFC_GUID, true)),
117 117
         ]));
118 118
     }
119 119
 
120 120
     /**
121 121
      * Validates the received HTTP handshake headers, or throws.
122 122
      */
123
-    protected function validate (): void {
123
+    protected function validate(): void {
124 124
         if (!(
125 125
             $check = 'method = http 1.1'
126 126
             and preg_match('/HTTP\/1\.1$/i', $this->method)
Please login to merge, or discard this patch.
src/WebSocket/WebSocketError.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
      */
26 26
     protected $frame;
27 27
 
28
-    public function __construct (int $code, string $message = '', Frame $frame = null, Throwable $previous = null) {
28
+    public function __construct(int $code, string $message = '', Frame $frame = null, Throwable $previous = null) {
29 29
         parent::__construct($message, $code, $previous);
30 30
         $this->frame = $frame;
31 31
     }
@@ -33,14 +33,14 @@  discard block
 block discarded – undo
33 33
     /**
34 34
      * @return mixed
35 35
      */
36
-    public function getExtra () {
36
+    public function getExtra() {
37 37
         return $this->extra;
38 38
     }
39 39
 
40 40
     /**
41 41
      * @return Frame|null
42 42
      */
43
-    public function getFrame () {
43
+    public function getFrame() {
44 44
         return $this->frame;
45 45
     }
46 46
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      * @param mixed $extra
49 49
      * @return $this
50 50
      */
51
-    public function setExtra ($extra) {
51
+    public function setExtra($extra) {
52 52
         $this->extra = $extra;
53 53
         return $this;
54 54
     }
Please login to merge, or discard this patch.
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/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.