Passed
Push — master ( 190707...14a343 )
by Malte
02:09
created
src/Connection/Protocols/ImapProtocol.php 1 patch
Spacing   +38 added lines, -38 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($command, $tokens = [], &$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
     /**
@@ -403,12 +403,12 @@  discard block
 block discarded – undo
403 403
                     error_log("got an extra server challenge: $response");
404 404
                     // respond with an empty response.
405 405
                     $this->sendRequest('');
406
-                } else {
406
+                }else {
407 407
                     if (preg_match('/^NO /i', $response) ||
408 408
                         preg_match('/^BAD /i', $response)) {
409 409
                         error_log("got failure response: $response");
410 410
                         return false;
411
-                    } else if (preg_match("/^OK /i", $response)) {
411
+                    }else if (preg_match("/^OK /i", $response)) {
412 412
                         return true;
413 413
                     }
414 414
                 }
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
      *
442 442
      * @return bool
443 443
      */
444
-    public function connected(){
444
+    public function connected() {
445 445
         return (boolean) $this->stream;
446 446
     }
447 447
 
@@ -488,10 +488,10 @@  discard block
 block discarded – undo
488 488
                     $result[strtolower($tokens[1])] = $tokens[0];
489 489
                     break;
490 490
                 case '[UIDVALIDITY':
491
-                    $result['uidvalidity'] = (int)$tokens[2];
491
+                    $result['uidvalidity'] = (int) $tokens[2];
492 492
                     break;
493 493
                 case '[UIDNEXT':
494
-                    $result['uidnext'] = (int)$tokens[2];
494
+                    $result['uidnext'] = (int) $tokens[2];
495 495
                     break;
496 496
                 default:
497 497
                     // ignore
@@ -546,14 +546,14 @@  discard block
 block discarded – undo
546 546
         if (is_array($from)) {
547 547
             $set = implode(',', $from);
548 548
         } elseif ($to === null) {
549
-            $set = (int)$from;
549
+            $set = (int) $from;
550 550
         } elseif ($to === INF) {
551
-            $set = (int)$from . ':*';
552
-        } else {
553
-            $set = (int)$from . ':' . (int)$to;
551
+            $set = (int) $from.':*';
552
+        }else {
553
+            $set = (int) $from.':'.(int) $to;
554 554
         }
555 555
 
556
-        $items = (array)$items;
556
+        $items = (array) $items;
557 557
         $itemList = $this->escapeList($items);
558 558
 
559 559
         $this->sendRequest($this->buildUIDCommand("FETCH", $uid), [$set, $itemList], $tag);
@@ -570,9 +570,9 @@  discard block
 block discarded – undo
570 570
                 $count = count($tokens[2]);
571 571
                 if ($tokens[2][$count - 2] == 'UID') {
572 572
                     $uidKey = $count - 1;
573
-                } else if ($tokens[2][0] == 'UID') {
573
+                }else if ($tokens[2][0] == 'UID') {
574 574
                     $uidKey = 1;
575
-                } else {
575
+                }else {
576 576
                     $uidKey = array_search('UID', $tokens[2]) + 1;
577 577
                 }
578 578
             }
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
                     $data = $tokens[2][1];
589 589
                 } elseif ($uid && $tokens[2][2] == $items[0]) {
590 590
                     $data = $tokens[2][3];
591
-                } else {
591
+                }else {
592 592
                     // maybe the server send an other field we didn't wanted
593 593
                     $count = count($tokens[2]);
594 594
                     // we start with 2, because 0 was already checked
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
                         break;
601 601
                     }
602 602
                 }
603
-            } else {
603
+            }else {
604 604
                 $data = [];
605 605
                 while (key($tokens[2]) !== null) {
606 606
                     $data[current($tokens[2])] = next($tokens[2]);
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
             }
618 618
             if ($uid) {
619 619
                 $result[$tokens[2][$uidKey]] = $data;
620
-            }else{
620
+            }else {
621 621
                 $result[$tokens[0]] = $data;
622 622
             }
623 623
         }
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
      * @return array
654 654
      * @throws RuntimeException
655 655
      */
656
-    public function headers($uids, $rfc = "RFC822", $uid = IMAP::ST_UID){
656
+    public function headers($uids, $rfc = "RFC822", $uid = IMAP::ST_UID) {
657 657
         return $this->fetch(["$rfc.HEADER"], $uids, null, $uid);
658 658
     }
659 659
 
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
      * @return array
667 667
      * @throws RuntimeException
668 668
      */
669
-    public function flags($uids, $uid = IMAP::ST_UID){
669
+    public function flags($uids, $uid = IMAP::ST_UID) {
670 670
         return $this->fetch(["FLAGS"], $uids, null, $uid);
671 671
     }
672 672
 
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
         $response = $this->requestAndResponse($command, [$set, $item, $flags], $silent);
763 763
 
764 764
         if ($silent) {
765
-            return (bool)$response;
765
+            return (bool) $response;
766 766
         }
767 767
 
768 768
         $result = [];
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
         $ids = [];
1064 1064
         foreach ($uids as $msgn => $v) {
1065 1065
             $id = $uid ? $v : $msgn;
1066
-            if ( ($to >= $id && $from <= $id) || ($to === "*" && $from <= $id) ){
1066
+            if (($to >= $id && $from <= $id) || ($to === "*" && $from <= $id)) {
1067 1067
                 $ids[] = $id;
1068 1068
             }
1069 1069
         }
@@ -1077,14 +1077,14 @@  discard block
 block discarded – undo
1077 1077
     /**
1078 1078
      * Enable the debug mode
1079 1079
      */
1080
-    public function enableDebug(){
1080
+    public function enableDebug() {
1081 1081
         $this->debug = true;
1082 1082
     }
1083 1083
 
1084 1084
     /**
1085 1085
      * Disable the debug mode
1086 1086
      */
1087
-    public function disableDebug(){
1087
+    public function disableDebug() {
1088 1088
         $this->debug = false;
1089 1089
     }
1090 1090
 
@@ -1096,9 +1096,9 @@  discard block
 block discarded – undo
1096 1096
      * @return int|string
1097 1097
      */
1098 1098
     public function buildSet($from, $to = null) {
1099
-        $set = (int)$from;
1099
+        $set = (int) $from;
1100 1100
         if ($to !== null) {
1101
-            $set .= ':' . ($to == INF ? '*' : (int)$to);
1101
+            $set .= ':'.($to == INF ? '*' : (int) $to);
1102 1102
         }
1103 1103
         return $set;
1104 1104
     }
Please login to merge, or discard this patch.