@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @throws ConnectionFailedException |
85 | 85 | * @throws RuntimeException |
86 | 86 | */ |
87 | - protected function enableTls(){ |
|
87 | + protected function enableTls() { |
|
88 | 88 | $response = $this->requestAndResponse('STARTTLS'); |
89 | 89 | $result = $response && stream_socket_enable_crypto($this->stream, true, $this->getCryptoMethod()); |
90 | 90 | if (!$result) { |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | $stack = []; |
147 | 147 | |
148 | 148 | // replace any trailing <NL> including spaces with a single space |
149 | - $line = rtrim($line) . ' '; |
|
149 | + $line = rtrim($line).' '; |
|
150 | 150 | while (($pos = strpos($line, ' ')) !== false) { |
151 | 151 | $token = substr($line, 0, $pos); |
152 | 152 | if (!strlen($token)) { |
@@ -176,11 +176,11 @@ discard block |
||
176 | 176 | if (strlen($token) > $chars) { |
177 | 177 | $line = substr($token, $chars); |
178 | 178 | $token = substr($token, 0, $chars); |
179 | - } else { |
|
179 | + }else { |
|
180 | 180 | $line .= $this->nextLine(); |
181 | 181 | } |
182 | 182 | $tokens[] = $token; |
183 | - $line = trim($line) . ' '; |
|
183 | + $line = trim($line).' '; |
|
184 | 184 | continue; |
185 | 185 | } |
186 | 186 | } |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $line = $this->nextTaggedLine($tag); // get next tag |
231 | 231 | if (!$dontParse) { |
232 | 232 | $tokens = $this->decodeLine($line); |
233 | - } else { |
|
233 | + }else { |
|
234 | 234 | $tokens = $line; |
235 | 235 | } |
236 | 236 | |
@@ -257,9 +257,9 @@ discard block |
||
257 | 257 | // First two chars are still needed for the response code |
258 | 258 | $tokens = [substr($tokens, 0, 2)]; |
259 | 259 | } |
260 | - if (is_array($lines)){ |
|
260 | + if (is_array($lines)) { |
|
261 | 261 | if ($this->debug) echo "<< ".json_encode($lines)."\n"; |
262 | - }else{ |
|
262 | + }else { |
|
263 | 263 | if ($this->debug) echo "<< ".$lines."\n"; |
264 | 264 | } |
265 | 265 | |
@@ -284,27 +284,27 @@ discard block |
||
284 | 284 | public function sendRequest($command, $tokens = [], &$tag = null) { |
285 | 285 | if (!$tag) { |
286 | 286 | $this->noun++; |
287 | - $tag = 'TAG' . $this->noun; |
|
287 | + $tag = 'TAG'.$this->noun; |
|
288 | 288 | } |
289 | 289 | |
290 | - $line = $tag . ' ' . $command; |
|
290 | + $line = $tag.' '.$command; |
|
291 | 291 | |
292 | 292 | foreach ($tokens as $token) { |
293 | 293 | if (is_array($token)) { |
294 | - if (fwrite($this->stream, $line . ' ' . $token[0] . "\r\n") === false) { |
|
294 | + if (fwrite($this->stream, $line.' '.$token[0]."\r\n") === false) { |
|
295 | 295 | throw new RuntimeException('failed to write - connection closed?'); |
296 | 296 | } |
297 | 297 | if (!$this->assumedNextLine('+ ')) { |
298 | 298 | throw new RuntimeException('failed to send literal string'); |
299 | 299 | } |
300 | 300 | $line = $token[1]; |
301 | - } else { |
|
302 | - $line .= ' ' . $token; |
|
301 | + }else { |
|
302 | + $line .= ' '.$token; |
|
303 | 303 | } |
304 | 304 | } |
305 | 305 | if ($this->debug) echo ">> ".$line."\n"; |
306 | 306 | |
307 | - if (fwrite($this->stream, $line . "\r\n") === false) { |
|
307 | + if (fwrite($this->stream, $line."\r\n") === false) { |
|
308 | 308 | throw new RuntimeException('failed to write - connection closed?'); |
309 | 309 | } |
310 | 310 | } |
@@ -334,9 +334,9 @@ discard block |
||
334 | 334 | public function escapeString($string) { |
335 | 335 | if (func_num_args() < 2) { |
336 | 336 | if (strpos($string, "\n") !== false) { |
337 | - return ['{' . strlen($string) . '}', $string]; |
|
338 | - } else { |
|
339 | - return '"' . str_replace(['\\', '"'], ['\\\\', '\\"'], $string) . '"'; |
|
337 | + return ['{'.strlen($string).'}', $string]; |
|
338 | + }else { |
|
339 | + return '"'.str_replace(['\\', '"'], ['\\\\', '\\"'], $string).'"'; |
|
340 | 340 | } |
341 | 341 | } |
342 | 342 | $result = []; |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | } |
362 | 362 | $result[] = $this->escapeList($v); |
363 | 363 | } |
364 | - return '(' . implode(' ', $result) . ')'; |
|
364 | + return '('.implode(' ', $result).')'; |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | /** |
@@ -401,12 +401,12 @@ discard block |
||
401 | 401 | error_log("got an extra server challenge: $response"); |
402 | 402 | // respond with an empty response. |
403 | 403 | $this->sendRequest(''); |
404 | - } else { |
|
404 | + }else { |
|
405 | 405 | if (preg_match('/^NO /i', $response) || |
406 | 406 | preg_match('/^BAD /i', $response)) { |
407 | 407 | error_log("got failure response: $response"); |
408 | 408 | return false; |
409 | - } else if (preg_match("/^OK /i", $response)) { |
|
409 | + }else if (preg_match("/^OK /i", $response)) { |
|
410 | 410 | return true; |
411 | 411 | } |
412 | 412 | } |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | * |
440 | 440 | * @return bool |
441 | 441 | */ |
442 | - public function connected(){ |
|
442 | + public function connected() { |
|
443 | 443 | return (boolean) $this->stream; |
444 | 444 | } |
445 | 445 | |
@@ -486,10 +486,10 @@ discard block |
||
486 | 486 | $result[strtolower($tokens[1])] = $tokens[0]; |
487 | 487 | break; |
488 | 488 | case '[UIDVALIDITY': |
489 | - $result['uidvalidity'] = (int)$tokens[2]; |
|
489 | + $result['uidvalidity'] = (int) $tokens[2]; |
|
490 | 490 | break; |
491 | 491 | case '[UIDNEXT': |
492 | - $result['uidnext'] = (int)$tokens[2]; |
|
492 | + $result['uidnext'] = (int) $tokens[2]; |
|
493 | 493 | break; |
494 | 494 | default: |
495 | 495 | // ignore |
@@ -543,17 +543,17 @@ discard block |
||
543 | 543 | if (is_array($from)) { |
544 | 544 | $set = implode(',', $from); |
545 | 545 | } elseif ($to === null) { |
546 | - $set = (int)$from; |
|
546 | + $set = (int) $from; |
|
547 | 547 | } elseif ($to === INF) { |
548 | - $set = (int)$from . ':*'; |
|
549 | - } else { |
|
550 | - $set = (int)$from . ':' . (int)$to; |
|
548 | + $set = (int) $from.':*'; |
|
549 | + }else { |
|
550 | + $set = (int) $from.':'.(int) $to; |
|
551 | 551 | } |
552 | 552 | |
553 | - $items = (array)$items; |
|
553 | + $items = (array) $items; |
|
554 | 554 | $itemList = $this->escapeList($items); |
555 | 555 | |
556 | - $this->sendRequest(($uid ? 'UID ' : '') . 'FETCH', [$set, $itemList], $tag); |
|
556 | + $this->sendRequest(($uid ? 'UID ' : '').'FETCH', [$set, $itemList], $tag); |
|
557 | 557 | |
558 | 558 | $result = []; |
559 | 559 | $tokens = null; // define $tokens variable before first use |
@@ -568,9 +568,9 @@ discard block |
||
568 | 568 | $count = count($tokens[2]); |
569 | 569 | if ($tokens[2][$count - 2] == 'UID') { |
570 | 570 | $uidKey = $count - 1; |
571 | - } else if ($tokens[2][0] == 'UID') { |
|
571 | + }else if ($tokens[2][0] == 'UID') { |
|
572 | 572 | $uidKey = 1; |
573 | - } else { |
|
573 | + }else { |
|
574 | 574 | $uidKey = array_search('UID', $tokens[2]) + 1; |
575 | 575 | } |
576 | 576 | } |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | $data = $tokens[2][1]; |
587 | 587 | } elseif ($uid && $tokens[2][2] == $items[0]) { |
588 | 588 | $data = $tokens[2][3]; |
589 | - } else { |
|
589 | + }else { |
|
590 | 590 | // maybe the server send an other field we didn't wanted |
591 | 591 | $count = count($tokens[2]); |
592 | 592 | // we start with 2, because 0 was already checked |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | break; |
599 | 599 | } |
600 | 600 | } |
601 | - } else { |
|
601 | + }else { |
|
602 | 602 | $data = []; |
603 | 603 | while (key($tokens[2]) !== null) { |
604 | 604 | $data[current($tokens[2])] = next($tokens[2]); |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | } |
616 | 616 | if ($uid) { |
617 | 617 | $result[$tokens[2][$uidKey]] = $data; |
618 | - }else{ |
|
618 | + }else { |
|
619 | 619 | $result[$tokens[0]] = $data; |
620 | 620 | } |
621 | 621 | } |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | * @return array |
650 | 650 | * @throws RuntimeException |
651 | 651 | */ |
652 | - public function headers($uids, $rfc = "RFC822", $uid = false){ |
|
652 | + public function headers($uids, $rfc = "RFC822", $uid = false) { |
|
653 | 653 | return $this->fetch(["$rfc.HEADER"], $uids, null, $uid); |
654 | 654 | } |
655 | 655 | |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | * @return array |
662 | 662 | * @throws RuntimeException |
663 | 663 | */ |
664 | - public function flags($uids, $uid = false){ |
|
664 | + public function flags($uids, $uid = false) { |
|
665 | 665 | return $this->fetch(["FLAGS"], $uids, null, $uid); |
666 | 666 | } |
667 | 667 | |
@@ -746,23 +746,23 @@ discard block |
||
746 | 746 | public function store(array $flags, $from, $to = null, $mode = null, $silent = true, $uid = false) { |
747 | 747 | $item = 'FLAGS'; |
748 | 748 | if ($mode == '+' || $mode == '-') { |
749 | - $item = $mode . $item; |
|
749 | + $item = $mode.$item; |
|
750 | 750 | } |
751 | 751 | if ($silent) { |
752 | 752 | $item .= '.SILENT'; |
753 | 753 | } |
754 | 754 | |
755 | 755 | $flags = $this->escapeList($flags); |
756 | - $set = (int)$from; |
|
756 | + $set = (int) $from; |
|
757 | 757 | if ($to !== null) { |
758 | - $set .= ':' . ($to == INF ? '*' : (int)$to); |
|
758 | + $set .= ':'.($to == INF ? '*' : (int) $to); |
|
759 | 759 | } |
760 | 760 | |
761 | 761 | $command = ($uid ? "UID " : "")."STORE"; |
762 | 762 | $result = $this->requestAndResponse($command, [$set, $item, $flags], $silent); |
763 | 763 | |
764 | 764 | if ($silent) { |
765 | - return (bool)$result; |
|
765 | + return (bool) $result; |
|
766 | 766 | } |
767 | 767 | |
768 | 768 | $tokens = $result; |
@@ -813,9 +813,9 @@ discard block |
||
813 | 813 | * @throws RuntimeException |
814 | 814 | */ |
815 | 815 | public function copyMessage($folder, $from, $to = null, $uid = false) { |
816 | - $set = (int)$from; |
|
816 | + $set = (int) $from; |
|
817 | 817 | if ($to !== null) { |
818 | - $set .= ':' . ($to == INF ? '*' : (int)$to); |
|
818 | + $set .= ':'.($to == INF ? '*' : (int) $to); |
|
819 | 819 | } |
820 | 820 | $command = ($uid ? "UID " : "")."COPY"; |
821 | 821 | |
@@ -834,9 +834,9 @@ discard block |
||
834 | 834 | * @throws RuntimeException |
835 | 835 | */ |
836 | 836 | public function moveMessage($folder, $from, $to = null, $uid = false) { |
837 | - $set = (int)$from; |
|
837 | + $set = (int) $from; |
|
838 | 838 | if ($to !== null) { |
839 | - $set .= ':' . ($to == INF ? '*' : (int)$to); |
|
839 | + $set .= ':'.($to == INF ? '*' : (int) $to); |
|
840 | 840 | } |
841 | 841 | $command = ($uid ? "UID " : "")."MOVE"; |
842 | 842 | |
@@ -1005,7 +1005,7 @@ discard block |
||
1005 | 1005 | $uids = $this->getUid(); |
1006 | 1006 | $ids = []; |
1007 | 1007 | foreach ($uids as $msgn => $v) { |
1008 | - if ( ($to >= $msgn && $from <= $msgn) || ($to === "*" && $from <= $msgn) ){ |
|
1008 | + if (($to >= $msgn && $from <= $msgn) || ($to === "*" && $from <= $msgn)) { |
|
1009 | 1009 | $ids[] = $uid ? $v : $msgn; |
1010 | 1010 | } |
1011 | 1011 | } |
@@ -1019,14 +1019,14 @@ discard block |
||
1019 | 1019 | /** |
1020 | 1020 | * Enable the debug mode |
1021 | 1021 | */ |
1022 | - public function enableDebug(){ |
|
1022 | + public function enableDebug() { |
|
1023 | 1023 | $this->debug = true; |
1024 | 1024 | } |
1025 | 1025 | |
1026 | 1026 | /** |
1027 | 1027 | * Disable the debug mode |
1028 | 1028 | */ |
1029 | - public function disableDebug(){ |
|
1029 | + public function disableDebug() { |
|
1030 | 1030 | $this->debug = false; |
1031 | 1031 | } |
1032 | 1032 | } |
1033 | 1033 | \ No newline at end of file |