Passed
Pull Request — master (#226)
by
unknown
02:19
created
src/Connection/Protocols/ImapProtocol.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
      * @throws ConnectionFailedException
90 90
      * @throws RuntimeException
91 91
      */
92
-    protected function enableStartTls(){
92
+    protected function enableStartTls() {
93 93
         $response = $this->requestAndResponse('STARTTLS');
94 94
         $result = $response && stream_socket_enable_crypto($this->stream, true, $this->getCryptoMethod());
95 95
         if (!$result) {
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
         $stack = [];
152 152
 
153 153
         //  replace any trailing <NL> including spaces with a single space
154
-        $line = rtrim($line) . ' ';
154
+        $line = rtrim($line).' ';
155 155
         while (($pos = strpos($line, ' ')) !== false) {
156 156
             $token = substr($line, 0, $pos);
157 157
             if (!strlen($token)) {
@@ -181,11 +181,11 @@  discard block
 block discarded – undo
181 181
                     if (strlen($token) > $chars) {
182 182
                         $line = substr($token, $chars);
183 183
                         $token = substr($token, 0, $chars);
184
-                    } else {
184
+                    }else {
185 185
                         $line .= $this->nextLine();
186 186
                     }
187 187
                     $tokens[] = $token;
188
-                    $line = trim($line) . ' ';
188
+                    $line = trim($line).' ';
189 189
                     continue;
190 190
                 }
191 191
             }
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
         $line = $this->nextTaggedLine($tag); // get next tag
236 236
         if (!$dontParse) {
237 237
             $tokens = $this->decodeLine($line);
238
-        } else {
238
+        }else {
239 239
             $tokens = $line;
240 240
         }
241 241
         if ($this->debug) echo "<< ".$line."\n";
@@ -286,27 +286,27 @@  discard block
 block discarded – undo
286 286
     public function sendRequest(string $command, array $tokens = [], string &$tag = null) {
287 287
         if (!$tag) {
288 288
             $this->noun++;
289
-            $tag = 'TAG' . $this->noun;
289
+            $tag = 'TAG'.$this->noun;
290 290
         }
291 291
 
292
-        $line = $tag . ' ' . $command;
292
+        $line = $tag.' '.$command;
293 293
 
294 294
         foreach ($tokens as $token) {
295 295
             if (is_array($token)) {
296
-                if (fwrite($this->stream, $line . ' ' . $token[0] . "\r\n") === false) {
296
+                if (fwrite($this->stream, $line.' '.$token[0]."\r\n") === false) {
297 297
                     throw new RuntimeException('failed to write - connection closed?');
298 298
                 }
299 299
                 if (!$this->assumedNextLine('+ ')) {
300 300
                     throw new RuntimeException('failed to send literal string');
301 301
                 }
302 302
                 $line = $token[1];
303
-            } else {
304
-                $line .= ' ' . $token;
303
+            }else {
304
+                $line .= ' '.$token;
305 305
             }
306 306
         }
307 307
         if ($this->debug) echo ">> ".$line."\n";
308 308
 
309
-        if (fwrite($this->stream, $line . "\r\n") === false) {
309
+        if (fwrite($this->stream, $line."\r\n") === false) {
310 310
             throw new RuntimeException('failed to write - connection closed?');
311 311
         }
312 312
     }
@@ -336,9 +336,9 @@  discard block
 block discarded – undo
336 336
     public function escapeString($string) {
337 337
         if (func_num_args() < 2) {
338 338
             if (strpos($string, "\n") !== false) {
339
-                return ['{' . strlen($string) . '}', $string];
340
-            } else {
341
-                return '"' . str_replace(['\\', '"'], ['\\\\', '\\"'], $string) . '"';
339
+                return ['{'.strlen($string).'}', $string];
340
+            }else {
341
+                return '"'.str_replace(['\\', '"'], ['\\\\', '\\"'], $string).'"';
342 342
             }
343 343
         }
344 344
         $result = [];
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
             }
364 364
             $result[] = $this->escapeList($v);
365 365
         }
366
-        return '(' . implode(' ', $result) . ')';
366
+        return '('.implode(' ', $result).')';
367 367
     }
368 368
 
369 369
     /**
@@ -404,12 +404,12 @@  discard block
 block discarded – undo
404 404
                     error_log("got an extra server challenge: $response");
405 405
                     // respond with an empty response.
406 406
                     $this->sendRequest('');
407
-                } else {
407
+                }else {
408 408
                     if (preg_match('/^NO /i', $response) ||
409 409
                         preg_match('/^BAD /i', $response)) {
410 410
                         error_log("got failure response: $response");
411 411
                         return false;
412
-                    } else if (preg_match("/^OK /i", $response)) {
412
+                    }else if (preg_match("/^OK /i", $response)) {
413 413
                         return true;
414 414
                     }
415 415
                 }
@@ -490,10 +490,10 @@  discard block
 block discarded – undo
490 490
                     $result[strtolower($tokens[1])] = $tokens[0];
491 491
                     break;
492 492
                 case '[UIDVALIDITY':
493
-                    $result['uidvalidity'] = (int)$tokens[2];
493
+                    $result['uidvalidity'] = (int) $tokens[2];
494 494
                     break;
495 495
                 case '[UIDNEXT':
496
-                    $result['uidnext'] = (int)$tokens[2];
496
+                    $result['uidnext'] = (int) $tokens[2];
497 497
                     break;
498 498
                 default:
499 499
                     // ignore
@@ -550,14 +550,14 @@  discard block
 block discarded – undo
550 550
         if (is_array($from)) {
551 551
             $set = implode(',', $from);
552 552
         } elseif ($to === null) {
553
-            $set = (int)$from;
553
+            $set = (int) $from;
554 554
         } elseif ($to === INF) {
555
-            $set = (int)$from . ':*';
556
-        } else {
557
-            $set = (int)$from . ':' . (int)$to;
555
+            $set = (int) $from.':*';
556
+        }else {
557
+            $set = (int) $from.':'.(int) $to;
558 558
         }
559 559
 
560
-        $items = (array)$items;
560
+        $items = (array) $items;
561 561
         $itemList = $this->escapeList($items);
562 562
 
563 563
         $this->sendRequest($this->buildUIDCommand("FETCH", $uid), [$set, $itemList], $tag);
@@ -574,9 +574,9 @@  discard block
 block discarded – undo
574 574
                 $count = count($tokens[2]);
575 575
                 if ($tokens[2][$count - 2] == 'UID') {
576 576
                     $uidKey = $count - 1;
577
-                } else if ($tokens[2][0] == 'UID') {
577
+                }else if ($tokens[2][0] == 'UID') {
578 578
                     $uidKey = 1;
579
-                } else {
579
+                }else {
580 580
                     $found = array_search('UID', $tokens[2]);
581 581
                     if ($found === false || $found === -1) {
582 582
                         continue;
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
                     $data = $tokens[2][1];
599 599
                 } elseif ($uid && $tokens[2][2] == $items[0]) {
600 600
                     $data = $tokens[2][3];
601
-                } else {
601
+                }else {
602 602
                     // maybe the server send an other field we didn't wanted
603 603
                     $count = count($tokens[2]);
604 604
                     // we start with 2, because 0 was already checked
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
                         break;
611 611
                     }
612 612
                 }
613
-            } else {
613
+            }else {
614 614
                 $data = [];
615 615
                 while (key($tokens[2]) !== null) {
616 616
                     $data[current($tokens[2])] = next($tokens[2]);
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
             }
628 628
             if ($uid) {
629 629
                 $result[$tokens[2][$uidKey]] = $data;
630
-            }else{
630
+            }else {
631 631
                 $result[$tokens[0]] = $data;
632 632
             }
633 633
         }
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 
693 693
         if ($this->enable_uid_cache && $this->uid_cache) {
694 694
             $uids = $this->uid_cache;
695
-        } else {
695
+        }else {
696 696
             try {
697 697
                 $uids = $this->fetch('UID', 1, INF);
698 698
                 $this->setUidCache($uids); // set cache for this folder
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
         $response = $this->requestAndResponse($command, [$set, $item, $flags], $silent);
787 787
 
788 788
         if ($silent) {
789
-            return (bool)$response;
789
+            return (bool) $response;
790 790
         }
791 791
 
792 792
         $result = [];
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
         $ids = [];
1088 1088
         foreach ($uids as $msgn => $v) {
1089 1089
             $id = $uid ? $v : $msgn;
1090
-            if ( ($to >= $id && $from <= $id) || ($to === "*" && $from <= $id) ){
1090
+            if (($to >= $id && $from <= $id) || ($to === "*" && $from <= $id)) {
1091 1091
                 $ids[] = $id;
1092 1092
             }
1093 1093
         }
@@ -1101,14 +1101,14 @@  discard block
 block discarded – undo
1101 1101
     /**
1102 1102
      * Enable the debug mode
1103 1103
      */
1104
-    public function enableDebug(){
1104
+    public function enableDebug() {
1105 1105
         $this->debug = true;
1106 1106
     }
1107 1107
 
1108 1108
     /**
1109 1109
      * Disable the debug mode
1110 1110
      */
1111
-    public function disableDebug(){
1111
+    public function disableDebug() {
1112 1112
         $this->debug = false;
1113 1113
     }
1114 1114
 
@@ -1120,9 +1120,9 @@  discard block
 block discarded – undo
1120 1120
      * @return int|string
1121 1121
      */
1122 1122
     public function buildSet($from, $to = null) {
1123
-        $set = (int)$from;
1123
+        $set = (int) $from;
1124 1124
         if ($to !== null) {
1125
-            $set .= ':' . ($to == INF ? '*' : (int)$to);
1125
+            $set .= ':'.($to == INF ? '*' : (int) $to);
1126 1126
         }
1127 1127
         return $set;
1128 1128
     }
Please login to merge, or discard this patch.