@@ -89,7 +89,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | $uidKey = array_search('UID', $tokens[2]) + 1; |
| 581 | 581 | } |
| 582 | 582 | } |
@@ -592,7 +592,7 @@ discard block |
||
| 592 | 592 | $data = $tokens[2][1]; |
| 593 | 593 | } elseif ($uid && $tokens[2][2] == $items[0]) { |
| 594 | 594 | $data = $tokens[2][3]; |
| 595 | - } else { |
|
| 595 | + }else { |
|
| 596 | 596 | $expectedResponse = 0; |
| 597 | 597 | // maybe the server send an other field we didn't wanted |
| 598 | 598 | $count = count($tokens[2]); |
@@ -609,7 +609,7 @@ discard block |
||
| 609 | 609 | continue; |
| 610 | 610 | } |
| 611 | 611 | } |
| 612 | - } else { |
|
| 612 | + }else { |
|
| 613 | 613 | $data = []; |
| 614 | 614 | while (key($tokens[2]) !== null) { |
| 615 | 615 | $data[current($tokens[2])] = next($tokens[2]); |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | } |
| 627 | 627 | if ($uid) { |
| 628 | 628 | $result[$tokens[2][$uidKey]] = $data; |
| 629 | - }else{ |
|
| 629 | + }else { |
|
| 630 | 630 | $result[$tokens[0]] = $data; |
| 631 | 631 | } |
| 632 | 632 | } |
@@ -691,7 +691,7 @@ discard block |
||
| 691 | 691 | |
| 692 | 692 | if ($this->enable_uid_cache && $this->uid_cache) { |
| 693 | 693 | $uids = $this->uid_cache; |
| 694 | - } else { |
|
| 694 | + }else { |
|
| 695 | 695 | try { |
| 696 | 696 | $uids = $this->fetch('UID', 1, INF); |
| 697 | 697 | $this->setUidCache($uids); // set cache for this folder |
@@ -785,7 +785,7 @@ discard block |
||
| 785 | 785 | $response = $this->requestAndResponse($command, [$set, $item, $flags], $silent); |
| 786 | 786 | |
| 787 | 787 | if ($silent) { |
| 788 | - return (bool)$response; |
|
| 788 | + return (bool) $response; |
|
| 789 | 789 | } |
| 790 | 790 | |
| 791 | 791 | $result = []; |
@@ -1086,7 +1086,7 @@ discard block |
||
| 1086 | 1086 | $ids = []; |
| 1087 | 1087 | foreach ($uids as $msgn => $v) { |
| 1088 | 1088 | $id = $uid ? $v : $msgn; |
| 1089 | - if ( ($to >= $id && $from <= $id) || ($to === "*" && $from <= $id) ){ |
|
| 1089 | + if (($to >= $id && $from <= $id) || ($to === "*" && $from <= $id)) { |
|
| 1090 | 1090 | $ids[] = $id; |
| 1091 | 1091 | } |
| 1092 | 1092 | } |
@@ -1100,14 +1100,14 @@ discard block |
||
| 1100 | 1100 | /** |
| 1101 | 1101 | * Enable the debug mode |
| 1102 | 1102 | */ |
| 1103 | - public function enableDebug(){ |
|
| 1103 | + public function enableDebug() { |
|
| 1104 | 1104 | $this->debug = true; |
| 1105 | 1105 | } |
| 1106 | 1106 | |
| 1107 | 1107 | /** |
| 1108 | 1108 | * Disable the debug mode |
| 1109 | 1109 | */ |
| 1110 | - public function disableDebug(){ |
|
| 1110 | + public function disableDebug() { |
|
| 1111 | 1111 | $this->debug = false; |
| 1112 | 1112 | } |
| 1113 | 1113 | |
@@ -1119,9 +1119,9 @@ discard block |
||
| 1119 | 1119 | * @return int|string |
| 1120 | 1120 | */ |
| 1121 | 1121 | public function buildSet($from, $to = null) { |
| 1122 | - $set = (int)$from; |
|
| 1122 | + $set = (int) $from; |
|
| 1123 | 1123 | if ($to !== null) { |
| 1124 | - $set .= ':' . ($to == INF ? '*' : (int)$to); |
|
| 1124 | + $set .= ':'.($to == INF ? '*' : (int) $to); |
|
| 1125 | 1125 | } |
| 1126 | 1126 | return $set; |
| 1127 | 1127 | } |