@@ -57,7 +57,7 @@ |
||
57 | 57 | |
58 | 58 | /** |
59 | 59 | * @param string $name |
60 | - * @param mixed $value |
|
60 | + * @param string $value |
|
61 | 61 | * @return self |
62 | 62 | */ |
63 | 63 | public function add(string $name, $value) |
@@ -63,7 +63,7 @@ |
||
63 | 63 | public function add(string $name, $value) |
64 | 64 | { |
65 | 65 | if (!empty($this->headers[$name])) { |
66 | - if (!\is_array($this->headers[$name])){ |
|
66 | + if (!\is_array($this->headers[$name])) { |
|
67 | 67 | $this->headers[$name] = [$this->headers[$name]]; |
68 | 68 | } |
69 | 69 | $this->headers[$name][] = $value; |
@@ -47,7 +47,7 @@ |
||
47 | 47 | $stringResponse = $this->getHttpVersion() . ' ' . $this->httpResponse . "\r\n"; |
48 | 48 | |
49 | 49 | foreach ($this->getHeaders() as $name => $content) { |
50 | - $stringResponse .= $name . ': '. $content . "\r\n"; |
|
50 | + $stringResponse .= $name . ': ' . $content . "\r\n"; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | // No content to concatenate |
@@ -140,7 +140,7 @@ |
||
140 | 140 | /** |
141 | 141 | * It also run checks on data. |
142 | 142 | * |
143 | - * @param string|int $rawData Probably more likely a string than an int, but well... why not. |
|
143 | + * @param string $rawData Probably more likely a string than an int, but well... why not. |
|
144 | 144 | * @return self |
145 | 145 | * @throws IncompleteFrameException |
146 | 146 | */ |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * on the root directory of this project |
9 | 9 | */ |
10 | 10 | |
11 | -declare(strict_types=1); |
|
11 | +declare(strict_types = 1); |
|
12 | 12 | namespace Nekland\Woketo\Rfc6455; |
13 | 13 | |
14 | 14 | use Nekland\Woketo\Exception\Frame\ControlFrameException; |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | */ |
27 | 27 | class Frame |
28 | 28 | { |
29 | - const OP_CONTINUE = 0; |
|
30 | - const OP_TEXT = 1; |
|
31 | - const OP_BINARY = 2; |
|
32 | - const OP_CLOSE = 8; |
|
33 | - const OP_PING = 9; |
|
29 | + const OP_CONTINUE = 0; |
|
30 | + const OP_TEXT = 1; |
|
31 | + const OP_BINARY = 2; |
|
32 | + const OP_CLOSE = 8; |
|
33 | + const OP_PING = 9; |
|
34 | 34 | const OP_PONG = 10; |
35 | 35 | |
36 | 36 | // To understand codes, please refer to RFC: |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | { |
589 | 589 | $this->config = \array_merge([ |
590 | 590 | 'maxPayloadSize' => Frame::$defaultMaxPayloadSize, |
591 | - ],$config); |
|
591 | + ], $config); |
|
592 | 592 | |
593 | 593 | return $this; |
594 | 594 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | // Data is now stored in the message, let's clean the variable to stop both loops. |
96 | 96 | $data = null; |
97 | 97 | } |
98 | - } while(!$message->isComplete() && !empty($data)); |
|
98 | + } while (!$message->isComplete() && !empty($data)); |
|
99 | 99 | |
100 | 100 | if ($message->isComplete()) { |
101 | 101 | $this->processHelper($message, $socket); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | $socket->end(); |
119 | 119 | $data = ''; |
120 | 120 | } |
121 | - } while(!empty($data)); |
|
121 | + } while (!empty($data)); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -38,7 +38,7 @@ |
||
38 | 38 | { |
39 | 39 | // Doesn't log everything in not debug context |
40 | 40 | if ($this->debug || \in_array($level, [LogLevel::CRITICAL, LogLevel::ERROR])) { |
41 | - echo '[' . date('Y-m-d H:i:s') . '][' . $level . '] ' . $message ."\n"; |
|
41 | + echo '[' . date('Y-m-d H:i:s') . '][' . $level . '] ' . $message . "\n"; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
@@ -24,7 +24,6 @@ |
||
24 | 24 | use Nekland\Woketo\Rfc6455\ServerHandshake; |
25 | 25 | use Nekland\Woketo\Utils\SimpleLogger; |
26 | 26 | use Psr\Log\LoggerInterface; |
27 | -use Psr\Log\LogLevel; |
|
28 | 27 | use React\EventLoop\LoopInterface; |
29 | 28 | use React\Socket\ConnectionInterface; |
30 | 29 | use React\Socket\ServerInterface; |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $this->buildMessageProcessor(); |
97 | 97 | |
98 | 98 | // Some optimization |
99 | - \gc_enable(); // As the process never stops, the garbage collector will be usefull, you may need to call it manually sometimes for performance purpose |
|
99 | + \gc_enable(); // As the process never stops, the garbage collector will be usefull, you may need to call it manually sometimes for performance purpose |
|
100 | 100 | \set_time_limit(0); // It's by default on most server for cli apps but better be sure of that fact |
101 | 101 | } |
102 | 102 | |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function setMessageHandler($messageHandler, $uri = '*') |
108 | 108 | { |
109 | - if (!$messageHandler instanceof MessageHandlerInterface && !\is_string($messageHandler)) { |
|
109 | + if (!$messageHandler instanceof MessageHandlerInterface && !\is_string($messageHandler)) { |
|
110 | 110 | throw new \InvalidArgumentException('The message handler must be an instance of MessageHandlerInterface or a string.'); |
111 | 111 | } |
112 | 112 | if (\is_string($messageHandler)) { |
113 | 113 | try { |
114 | 114 | $reflection = new \ReflectionClass($messageHandler); |
115 | - if(!$reflection->implementsInterface('Nekland\Woketo\Message\MessageHandlerInterface')) { |
|
115 | + if (!$reflection->implementsInterface('Nekland\Woketo\Message\MessageHandlerInterface')) { |
|
116 | 116 | throw new \InvalidArgumentException('The messageHandler must implement MessageHandlerInterface'); |
117 | 117 | } |
118 | 118 | } catch (\ReflectionException $e) { |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | $this->getLogger()->info('Enabled ssl'); |
145 | 145 | } |
146 | 146 | |
147 | - $this->server->on('connection', function ($socketStream) { |
|
147 | + $this->server->on('connection', function($socketStream) { |
|
148 | 148 | $this->onNewConnection($socketStream); |
149 | 149 | }); |
150 | 150 | $this->server->listen($this->port); |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | */ |
160 | 160 | private function onNewConnection(ConnectionInterface $socketStream) |
161 | 161 | { |
162 | - $connection = new Connection($socketStream, function ($uri, Connection $connection) { |
|
162 | + $connection = new Connection($socketStream, function($uri, Connection $connection) { |
|
163 | 163 | return $this->getMessageHandler($uri, $connection); |
164 | 164 | }, $this->loop, $this->messageProcessor); |
165 | 165 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * For the full license, take a look to the LICENSE file |
9 | 9 | * on the root directory of this project |
10 | 10 | */ |
11 | -declare(strict_types=1); |
|
11 | +declare(strict_types = 1); |
|
12 | 12 | |
13 | 13 | namespace Nekland\Woketo\Utils; |
14 | 14 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | if (\is_string($frame)) { |
65 | 65 | $len = BitManipulation::frameSize($frame); |
66 | 66 | |
67 | - if ($byteNumber < 0 || $byteNumber > ($len-1)) { |
|
67 | + if ($byteNumber < 0 || $byteNumber > ($len - 1)) { |
|
68 | 68 | throw new \InvalidArgumentException( |
69 | 69 | \sprintf('The frame is only %s bytes larges but you tried to get the %sth byte.', $len, $byteNumber) |
70 | 70 | ); |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | $res = 0; |
173 | 173 | |
174 | 174 | // for each byte, getting ord |
175 | - for($i = 0; $i < $subStringLength; $i++) { |
|
175 | + for ($i = 0; $i < $subStringLength; $i++) { |
|
176 | 176 | $res <<= 8; |
177 | 177 | $res += \ord($subString[$i]); |
178 | 178 | } |
@@ -96,7 +96,7 @@ |
||
96 | 96 | |
97 | 97 | if (\count($explodingHeader)) { |
98 | 98 | unset($explodingHeader[0]); // removing the name of the extension |
99 | - foreach($explodingHeader as $variable) { |
|
99 | + foreach ($explodingHeader as $variable) { |
|
100 | 100 | $explodeVariable = \explode('=', $variable); |
101 | 101 | |
102 | 102 | // The value can be with or without quote. We need to remove extra quotes. |
@@ -97,10 +97,10 @@ discard block |
||
97 | 97 | |
98 | 98 | private function initListeners() |
99 | 99 | { |
100 | - $this->socketStream->on('data', function ($data) { |
|
100 | + $this->socketStream->on('data', function($data) { |
|
101 | 101 | $this->processData($data); |
102 | 102 | }); |
103 | - $this->socketStream->on('error', function ($data) { |
|
103 | + $this->socketStream->on('error', function($data) { |
|
104 | 104 | $this->error($data); |
105 | 105 | }); |
106 | 106 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | $this->currentMessage = $message; |
143 | 143 | if ($this->currentMessage->isComplete()) { |
144 | 144 | // Sending the message through the woketo API. |
145 | - switch($this->currentMessage->getOpcode()) { |
|
145 | + switch ($this->currentMessage->getOpcode()) { |
|
146 | 146 | case Frame::OP_TEXT: |
147 | 147 | $this->getHandler()->onMessage($this->currentMessage->getContent(), $this); |
148 | 148 | break; |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | |
155 | 155 | } else { |
156 | 156 | // We wait for more data so we start a timeout. |
157 | - $this->timeout = $this->loop->addTimer(Connection::DEFAULT_TIMEOUT, function () { |
|
157 | + $this->timeout = $this->loop->addTimer(Connection::DEFAULT_TIMEOUT, function() { |
|
158 | 158 | $this->logger->notice('Connection to ' . $this->getIp() . ' timed out.'); |
159 | 159 | $this->messageProcessor->timeout($this->socketStream); |
160 | 160 | }); |