Completed
Push — master ( 05544f...34252d )
by Maxime
02:24
created
src/Http/HttpHeadersBag.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
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)
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/Http/Request.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@
 block discarded – undo
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.
Please login to merge, or discard this patch.
src/Http/Response.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
src/Utils/BitManipulation.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
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
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
         if (is_string($frame)) {
59 59
             $len = BitManipulation::frameSize($frame);
60 60
 
61
-            if ($byteNumber < 0 || $byteNumber > ($len-1)) {
61
+            if ($byteNumber < 0 || $byteNumber > ($len - 1)) {
62 62
                 throw new \InvalidArgumentException(
63 63
                     sprintf('The frame is only %s bytes larges but you tried to get the %sth byte.', $len, $byteNumber)
64 64
                 );
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
             $res = 0;
167 167
 
168 168
             // for each byte, getting ord
169
-            for($i = 0; $i < $subStringLength; $i++) {
169
+            for ($i = 0; $i < $subStringLength; $i++) {
170 170
                 $res <<= 8;
171 171
                 $res += ord($subString[$i]);
172 172
             }
Please login to merge, or discard this patch.
src/Rfc6455/Frame.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -140,7 +140,7 @@
 block discarded – undo
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
      */
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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:
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
     {
587 587
         $this->config = array_merge([
588 588
             'maxPayloadSize' => Frame::$defaultMaxPayloadSize,
589
-        ],$config);
589
+        ], $config);
590 590
 
591 591
         return $this;
592 592
     }
Please login to merge, or discard this patch.
src/Rfc6455/MessageProcessor.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
118 118
                 $socket->end();
119 119
                 $data = '';
120 120
             }
121
-        } while(!empty($data));
121
+        } while (!empty($data));
122 122
     }
123 123
 
124 124
     /**
Please login to merge, or discard this patch.
src/Server/WebSocketServer.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,6 @@
 block discarded – undo
23 23
 use Nekland\Woketo\Rfc6455\ServerHandshake;
24 24
 use Nekland\Woketo\Utils\SimpleLogger;
25 25
 use Psr\Log\LoggerInterface;
26
-use Psr\Log\LogLevel;
27 26
 use React\EventLoop\LoopInterface;
28 27
 use React\Socket\ConnectionInterface;
29 28
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
         $this->buildMessageProcessor();
96 96
 
97 97
         // Some optimization
98
-        \gc_enable();       // As the process never stops, the garbage collector will be usefull, you may need to call it manually sometimes for performance purpose
98
+        \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 99
         \set_time_limit(0); // It's by default on most server for cli apps but better be sure of that fact
100 100
     }
101 101
 
@@ -105,13 +105,13 @@  discard block
 block discarded – undo
105 105
      */
106 106
     public function setMessageHandler($messageHandler, $uri = '*')
107 107
     {
108
-        if (!$messageHandler instanceof MessageHandlerInterface &&  !\is_string($messageHandler)) {
108
+        if (!$messageHandler instanceof MessageHandlerInterface && !\is_string($messageHandler)) {
109 109
             throw new \InvalidArgumentException('The message handler must be an instance of MessageHandlerInterface or a string.');
110 110
         }
111 111
         if (\is_string($messageHandler)) {
112 112
             try {
113 113
                 $reflection = new \ReflectionClass($messageHandler);
114
-                if(!$reflection->implementsInterface('Nekland\Woketo\Message\MessageHandlerInterface')) {
114
+                if (!$reflection->implementsInterface('Nekland\Woketo\Message\MessageHandlerInterface')) {
115 115
                     throw new \InvalidArgumentException('The messageHandler must implement MessageHandlerInterface');
116 116
                 }
117 117
             } catch (\ReflectionException $e) {
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
         $this->loop = $this->loop ?? \React\EventLoop\Factory::create();
136 136
         $this->server = $this->server ?? new \React\Socket\Server($this->loop);
137 137
 
138
-        $this->server->on('connection', function ($socketStream) {
138
+        $this->server->on('connection', function($socketStream) {
139 139
             $this->onNewConnection($socketStream);
140 140
         });
141 141
         $this->server->listen($this->port);
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      */
151 151
     private function onNewConnection(ConnectionInterface $socketStream)
152 152
     {
153
-        $connection = new Connection($socketStream, function ($uri, Connection $connection) {
153
+        $connection = new Connection($socketStream, function($uri, Connection $connection) {
154 154
             return $this->getMessageHandler($uri, $connection);
155 155
         }, $this->loop, $this->messageProcessor);
156 156
 
Please login to merge, or discard this patch.
src/Server/Connection.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -91,10 +91,10 @@  discard block
 block discarded – undo
91 91
 
92 92
     private function initListeners()
93 93
     {
94
-        $this->socketStream->on('data', function ($data) {
94
+        $this->socketStream->on('data', function($data) {
95 95
             $this->processData($data);
96 96
         });
97
-        $this->socketStream->on('error', function ($data) {
97
+        $this->socketStream->on('error', function($data) {
98 98
             $this->error($data);
99 99
         });
100 100
     }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
             $this->currentMessage = $message;
134 134
             if ($this->currentMessage->isComplete()) {
135 135
                 // Sending the message through the woketo API.
136
-                switch($this->currentMessage->getOpcode()) {
136
+                switch ($this->currentMessage->getOpcode()) {
137 137
                     case Frame::OP_TEXT:
138 138
                         $this->handler->onMessage($this->currentMessage->getContent(), $this);
139 139
                         break;
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 
146 146
             } else {
147 147
                 // We wait for more data so we start a timeout.
148
-                $this->timeout = $this->loop->addTimer(Connection::DEFAULT_TIMEOUT, function () {
148
+                $this->timeout = $this->loop->addTimer(Connection::DEFAULT_TIMEOUT, function() {
149 149
                     $this->logger->notice('Connection to ' . $this->getIp() . ' timed out.');
150 150
                     $this->messageProcessor->timeout($this->socketStream);
151 151
                 });
Please login to merge, or discard this patch.
src/Utils/SimpleLogger.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.