@@ -2309,10 +2309,12 @@ discard block |
||
| 2309 | 2309 | * @access private |
| 2310 | 2310 | */ |
| 2311 | 2311 | function io_method() { |
| 2312 | - if ($this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm') || ($this->scheme == 'http' && is_array($this->proxy) && $this->proxy['authtype'] == 'ntlm')) |
|
| 2313 | - return 'curl'; |
|
| 2314 | - if (($this->scheme == 'http' || $this->scheme == 'ssl') && $this->authtype != 'ntlm' && (!is_array($this->proxy) || $this->proxy['authtype'] != 'ntlm')) |
|
| 2315 | - return 'socket'; |
|
| 2312 | + if ($this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm') || ($this->scheme == 'http' && is_array($this->proxy) && $this->proxy['authtype'] == 'ntlm')) { |
|
| 2313 | + return 'curl'; |
|
| 2314 | + } |
|
| 2315 | + if (($this->scheme == 'http' || $this->scheme == 'ssl') && $this->authtype != 'ntlm' && (!is_array($this->proxy) || $this->proxy['authtype'] != 'ntlm')) { |
|
| 2316 | + return 'socket'; |
|
| 2317 | + } |
|
| 2316 | 2318 | return 'unknown'; |
| 2317 | 2319 | } |
| 2318 | 2320 | |
@@ -2396,30 +2398,36 @@ discard block |
||
| 2396 | 2398 | return false; |
| 2397 | 2399 | } |
| 2398 | 2400 | // Avoid warnings when PHP does not have these options |
| 2399 | - if (defined('CURLOPT_CONNECTIONTIMEOUT')) |
|
| 2400 | - $CURLOPT_CONNECTIONTIMEOUT = CURLOPT_CONNECTIONTIMEOUT; |
|
| 2401 | - else |
|
| 2402 | - $CURLOPT_CONNECTIONTIMEOUT = 78; |
|
| 2403 | - if (defined('CURLOPT_HTTPAUTH')) |
|
| 2404 | - $CURLOPT_HTTPAUTH = CURLOPT_HTTPAUTH; |
|
| 2405 | - else |
|
| 2406 | - $CURLOPT_HTTPAUTH = 107; |
|
| 2407 | - if (defined('CURLOPT_PROXYAUTH')) |
|
| 2408 | - $CURLOPT_PROXYAUTH = CURLOPT_PROXYAUTH; |
|
| 2409 | - else |
|
| 2410 | - $CURLOPT_PROXYAUTH = 111; |
|
| 2411 | - if (defined('CURLAUTH_BASIC')) |
|
| 2412 | - $CURLAUTH_BASIC = CURLAUTH_BASIC; |
|
| 2413 | - else |
|
| 2414 | - $CURLAUTH_BASIC = 1; |
|
| 2415 | - if (defined('CURLAUTH_DIGEST')) |
|
| 2416 | - $CURLAUTH_DIGEST = CURLAUTH_DIGEST; |
|
| 2417 | - else |
|
| 2418 | - $CURLAUTH_DIGEST = 2; |
|
| 2419 | - if (defined('CURLAUTH_NTLM')) |
|
| 2420 | - $CURLAUTH_NTLM = CURLAUTH_NTLM; |
|
| 2421 | - else |
|
| 2422 | - $CURLAUTH_NTLM = 8; |
|
| 2401 | + if (defined('CURLOPT_CONNECTIONTIMEOUT')) { |
|
| 2402 | + $CURLOPT_CONNECTIONTIMEOUT = CURLOPT_CONNECTIONTIMEOUT; |
|
| 2403 | + } else { |
|
| 2404 | + $CURLOPT_CONNECTIONTIMEOUT = 78; |
|
| 2405 | + } |
|
| 2406 | + if (defined('CURLOPT_HTTPAUTH')) { |
|
| 2407 | + $CURLOPT_HTTPAUTH = CURLOPT_HTTPAUTH; |
|
| 2408 | + } else { |
|
| 2409 | + $CURLOPT_HTTPAUTH = 107; |
|
| 2410 | + } |
|
| 2411 | + if (defined('CURLOPT_PROXYAUTH')) { |
|
| 2412 | + $CURLOPT_PROXYAUTH = CURLOPT_PROXYAUTH; |
|
| 2413 | + } else { |
|
| 2414 | + $CURLOPT_PROXYAUTH = 111; |
|
| 2415 | + } |
|
| 2416 | + if (defined('CURLAUTH_BASIC')) { |
|
| 2417 | + $CURLAUTH_BASIC = CURLAUTH_BASIC; |
|
| 2418 | + } else { |
|
| 2419 | + $CURLAUTH_BASIC = 1; |
|
| 2420 | + } |
|
| 2421 | + if (defined('CURLAUTH_DIGEST')) { |
|
| 2422 | + $CURLAUTH_DIGEST = CURLAUTH_DIGEST; |
|
| 2423 | + } else { |
|
| 2424 | + $CURLAUTH_DIGEST = 2; |
|
| 2425 | + } |
|
| 2426 | + if (defined('CURLAUTH_NTLM')) { |
|
| 2427 | + $CURLAUTH_NTLM = CURLAUTH_NTLM; |
|
| 2428 | + } else { |
|
| 2429 | + $CURLAUTH_NTLM = 8; |
|
| 2430 | + } |
|
| 2423 | 2431 | |
| 2424 | 2432 | $this->debug('connect using cURL'); |
| 2425 | 2433 | // init CURL |
@@ -2762,7 +2770,9 @@ discard block |
||
| 2762 | 2770 | 'HTTP/1.0 200 Connection established'); |
| 2763 | 2771 | foreach ($skipHeaders as $hd) { |
| 2764 | 2772 | $prefix = substr($data, 0, strlen($hd)); |
| 2765 | - if ($prefix == $hd) return true; |
|
| 2773 | + if ($prefix == $hd) { |
|
| 2774 | + return true; |
|
| 2775 | + } |
|
| 2766 | 2776 | } |
| 2767 | 2777 | |
| 2768 | 2778 | return false; |
@@ -4656,8 +4666,9 @@ discard block |
||
| 4656 | 4666 | $this->proxypassword = $proxypassword; |
| 4657 | 4667 | $this->timeout = $timeout; |
| 4658 | 4668 | $this->response_timeout = $response_timeout; |
| 4659 | - if (is_array($curl_options)) |
|
| 4660 | - $this->curl_options = $curl_options; |
|
| 4669 | + if (is_array($curl_options)) { |
|
| 4670 | + $this->curl_options = $curl_options; |
|
| 4671 | + } |
|
| 4661 | 4672 | $this->use_curl = $use_curl; |
| 4662 | 4673 | $this->fetchWSDL($wsdl); |
| 4663 | 4674 | } |
@@ -7329,8 +7340,9 @@ discard block |
||
| 7329 | 7340 | } |
| 7330 | 7341 | if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) { |
| 7331 | 7342 | $this->loadWSDL(); |
| 7332 | - if ($this->getError()) |
|
| 7333 | - return false; |
|
| 7343 | + if ($this->getError()) { |
|
| 7344 | + return false; |
|
| 7345 | + } |
|
| 7334 | 7346 | } |
| 7335 | 7347 | // serialize parameters |
| 7336 | 7348 | if($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)){ |
@@ -7544,8 +7556,9 @@ discard block |
||
| 7544 | 7556 | function getOperationData($operation){ |
| 7545 | 7557 | if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) { |
| 7546 | 7558 | $this->loadWSDL(); |
| 7547 | - if ($this->getError()) |
|
| 7548 | - return false; |
|
| 7559 | + if ($this->getError()) { |
|
| 7560 | + return false; |
|
| 7561 | + } |
|
| 7549 | 7562 | } |
| 7550 | 7563 | if(isset($this->operations[$operation])){ |
| 7551 | 7564 | return $this->operations[$operation]; |
@@ -77,8 +77,9 @@ |
||
| 77 | 77 | $this->proxypassword = $proxypassword; |
| 78 | 78 | $this->timeout = $timeout; |
| 79 | 79 | $this->response_timeout = $response_timeout; |
| 80 | - if (is_array($curl_options)) |
|
| 81 | - $this->curl_options = $curl_options; |
|
| 80 | + if (is_array($curl_options)) { |
|
| 81 | + $this->curl_options = $curl_options; |
|
| 82 | + } |
|
| 82 | 83 | $this->use_curl = $use_curl; |
| 83 | 84 | $this->fetchWSDL($wsdl); |
| 84 | 85 | } |
@@ -172,8 +172,9 @@ discard block |
||
| 172 | 172 | } |
| 173 | 173 | if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) { |
| 174 | 174 | $this->loadWSDL(); |
| 175 | - if ($this->getError()) |
|
| 176 | - return false; |
|
| 175 | + if ($this->getError()) { |
|
| 176 | + return false; |
|
| 177 | + } |
|
| 177 | 178 | } |
| 178 | 179 | // serialize parameters |
| 179 | 180 | if($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)){ |
@@ -387,8 +388,9 @@ discard block |
||
| 387 | 388 | function getOperationData($operation){ |
| 388 | 389 | if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) { |
| 389 | 390 | $this->loadWSDL(); |
| 390 | - if ($this->getError()) |
|
| 391 | - return false; |
|
| 391 | + if ($this->getError()) { |
|
| 392 | + return false; |
|
| 393 | + } |
|
| 392 | 394 | } |
| 393 | 395 | if(isset($this->operations[$operation])){ |
| 394 | 396 | return $this->operations[$operation]; |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | $value = $this->default_account_config[$key]; |
| 208 | 208 | if(isset($config[$key])) { |
| 209 | 209 | $value = $config[$key]; |
| 210 | - }elseif(isset($default_config[$key])) { |
|
| 210 | + } elseif(isset($default_config[$key])) { |
|
| 211 | 211 | $value = $default_config[$key]; |
| 212 | 212 | } |
| 213 | 213 | $this->$key = $value; |
@@ -239,39 +239,39 @@ discard block |
||
| 239 | 239 | if(isset($config['masks']['message'])) { |
| 240 | 240 | if(class_exists($config['masks']['message'])) { |
| 241 | 241 | $this->default_message_mask = $config['masks']['message']; |
| 242 | - }else{ |
|
| 242 | + } else{ |
|
| 243 | 243 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']); |
| 244 | 244 | } |
| 245 | - }else{ |
|
| 245 | + } else{ |
|
| 246 | 246 | if(class_exists($default_config['message'])) { |
| 247 | 247 | $this->default_message_mask = $default_config['message']; |
| 248 | - }else{ |
|
| 248 | + } else{ |
|
| 249 | 249 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
| 250 | 250 | } |
| 251 | 251 | } |
| 252 | 252 | if(isset($config['masks']['attachment'])) { |
| 253 | 253 | if(class_exists($config['masks']['attachment'])) { |
| 254 | 254 | $this->default_attachment_mask = $config['masks']['attachment']; |
| 255 | - }else{ |
|
| 255 | + } else{ |
|
| 256 | 256 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']); |
| 257 | 257 | } |
| 258 | - }else{ |
|
| 258 | + } else{ |
|
| 259 | 259 | if(class_exists($default_config['attachment'])) { |
| 260 | 260 | $this->default_attachment_mask = $default_config['attachment']; |
| 261 | - }else{ |
|
| 261 | + } else{ |
|
| 262 | 262 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | - }else{ |
|
| 265 | + } else{ |
|
| 266 | 266 | if(class_exists($default_config['message'])) { |
| 267 | 267 | $this->default_message_mask = $default_config['message']; |
| 268 | - }else{ |
|
| 268 | + } else{ |
|
| 269 | 269 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | if(class_exists($default_config['attachment'])) { |
| 273 | 273 | $this->default_attachment_mask = $default_config['attachment']; |
| 274 | - }else{ |
|
| 274 | + } else{ |
|
| 275 | 275 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
| 276 | 276 | } |
| 277 | 277 | } |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | $this->connection = new ImapProtocol($this->validate_cert, $this->encryption); |
| 336 | 336 | $this->connection->setConnectionTimeout($this->timeout); |
| 337 | 337 | $this->connection->setProxy($this->proxy); |
| 338 | - }else{ |
|
| 338 | + } else{ |
|
| 339 | 339 | if (extension_loaded('imap') === false) { |
| 340 | 340 | throw new ConnectionFailedException("connection setup failed - no imap function", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol")); |
| 341 | 341 | } |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | return $folders; |
| 479 | - }else{ |
|
| 479 | + } else{ |
|
| 480 | 480 | throw new FolderFetchingException("failed to fetch any folders"); |
| 481 | 481 | } |
| 482 | 482 | } |
@@ -514,7 +514,9 @@ discard block |
||
| 514 | 514 | $this->checkConnection(); |
| 515 | 515 | $status = $this->connection->createFolder($folder); |
| 516 | 516 | |
| 517 | - if($expunge) $this->expunge(); |
|
| 517 | + if($expunge) { |
|
| 518 | + $this->expunge(); |
|
| 519 | + } |
|
| 518 | 520 | |
| 519 | 521 | $folder = $this->getFolder($folder); |
| 520 | 522 | if($status && $folder) { |
@@ -232,7 +232,9 @@ discard block |
||
| 232 | 232 | public function move($new_name, $expunge = true) { |
| 233 | 233 | $this->client->checkConnection(); |
| 234 | 234 | $status = $this->client->getConnection()->renameFolder($this->full_name, $new_name); |
| 235 | - if($expunge) $this->client->expunge(); |
|
| 235 | + if($expunge) { |
|
| 236 | + $this->client->expunge(); |
|
| 237 | + } |
|
| 236 | 238 | |
| 237 | 239 | $folder = $this->client->getFolder($new_name); |
| 238 | 240 | $event = $this->getEvent("folder", "moved"); |
@@ -310,7 +312,9 @@ discard block |
||
| 310 | 312 | */ |
| 311 | 313 | public function delete($expunge = true) { |
| 312 | 314 | $status = $this->client->getConnection()->deleteFolder($this->path); |
| 313 | - if($expunge) $this->client->expunge(); |
|
| 315 | + if($expunge) { |
|
| 316 | + $this->client->expunge(); |
|
| 317 | + } |
|
| 314 | 318 | |
| 315 | 319 | $event = $this->getEvent("folder", "deleted"); |
| 316 | 320 | $event::dispatch($this); |
@@ -384,7 +388,7 @@ discard block |
||
| 384 | 388 | |
| 385 | 389 | $connection->idle(); |
| 386 | 390 | } |
| 387 | - }catch (Exceptions\RuntimeException $e) { |
|
| 391 | + } catch (Exceptions\RuntimeException $e) { |
|
| 388 | 392 | if(strpos($e->getMessage(), "connection closed") === false) { |
| 389 | 393 | throw $e; |
| 390 | 394 | } |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | $name = $this->decodeFolderName($item->name); |
| 324 | 324 | $result[$name] = ['delimiter' => $item->delimiter, 'flags' => []]; |
| 325 | 325 | } |
| 326 | - }else{ |
|
| 326 | + } else{ |
|
| 327 | 327 | throw new RuntimeException(\imap_last_error()); |
| 328 | 328 | } |
| 329 | 329 | |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | |
| 348 | 348 | if ($mode == "+"){ |
| 349 | 349 | $status = \imap_setflag_full($this->stream, $from, $flag, $uid ? IMAP::FT_UID : IMAP::NIL); |
| 350 | - }else{ |
|
| 350 | + } else{ |
|
| 351 | 351 | $status = \imap_clearflag_full($this->stream, $from, $flag, $uid ? IMAP::FT_UID : IMAP::NIL); |
| 352 | 352 | } |
| 353 | 353 | |
@@ -72,7 +72,7 @@ |
||
| 72 | 72 | // so add them back in manually if we can |
| 73 | 73 | if (defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')) { |
| 74 | 74 | $cryptoMethod = STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT; |
| 75 | - }elseif (defined('STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT')) { |
|
| 75 | + } elseif (defined('STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT')) { |
|
| 76 | 76 | $cryptoMethod = STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT; |
| 77 | 77 | } |
| 78 | 78 | |
@@ -237,7 +237,9 @@ discard block |
||
| 237 | 237 | } else { |
| 238 | 238 | $tokens = $line; |
| 239 | 239 | } |
| 240 | - if ($this->debug) echo "<< ".$line."\n"; |
|
| 240 | + if ($this->debug) { |
|
| 241 | + echo "<< ".$line."\n"; |
|
| 242 | + } |
|
| 241 | 243 | |
| 242 | 244 | // if tag is wanted tag we might be at the end of a multiline response |
| 243 | 245 | return $tag == $wantedTag; |
@@ -303,7 +305,9 @@ discard block |
||
| 303 | 305 | $line .= ' ' . $token; |
| 304 | 306 | } |
| 305 | 307 | } |
| 306 | - if ($this->debug) echo ">> ".$line."\n"; |
|
| 308 | + if ($this->debug) { |
|
| 309 | + echo ">> ".$line."\n"; |
|
| 310 | + } |
|
| 307 | 311 | |
| 308 | 312 | if (fwrite($this->stream, $line . "\r\n") === false) { |
| 309 | 313 | throw new RuntimeException('failed to write - connection closed?'); |
@@ -453,7 +457,9 @@ discard block |
||
| 453 | 457 | public function getCapabilities() { |
| 454 | 458 | $response = $this->requestAndResponse('CAPABILITY'); |
| 455 | 459 | |
| 456 | - if (!$response) return []; |
|
| 460 | + if (!$response) { |
|
| 461 | + return []; |
|
| 462 | + } |
|
| 457 | 463 | |
| 458 | 464 | $capabilities = []; |
| 459 | 465 | foreach ($response as $line) { |
@@ -610,13 +616,14 @@ discard block |
||
| 610 | 616 | // if we want only one message we can ignore everything else and just return |
| 611 | 617 | if ($to === null && !is_array($from) && ($uid ? $tokens[2][$uidKey] == $from : $tokens[0] == $from)) { |
| 612 | 618 | // we still need to read all lines |
| 613 | - while (!$this->readLine($tokens, $tag)) |
|
| 614 | - |
|
| 619 | + while (!$this->readLine($tokens, $tag)) { |
|
| 620 | + |
|
| 615 | 621 | return $data; |
| 622 | + } |
|
| 616 | 623 | } |
| 617 | 624 | if ($uid) { |
| 618 | 625 | $result[$tokens[2][$uidKey]] = $data; |
| 619 | - }else{ |
|
| 626 | + } else{ |
|
| 620 | 627 | $result[$tokens[0]] = $data; |
| 621 | 628 | } |
| 622 | 629 | } |
@@ -86,7 +86,9 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | public function toDate(){ |
| 88 | 88 | $date = $this->first(); |
| 89 | - if ($date instanceof Carbon) return $date; |
|
| 89 | + if ($date instanceof Carbon) { |
|
| 90 | + return $date; |
|
| 91 | + } |
|
| 90 | 92 | |
| 91 | 93 | return Carbon::parse($date); |
| 92 | 94 | } |
@@ -146,7 +148,7 @@ discard block |
||
| 146 | 148 | public function add($value, $strict = false) { |
| 147 | 149 | if (is_array($value)) { |
| 148 | 150 | return $this->merge($value, $strict); |
| 149 | - }elseif ($value !== null) { |
|
| 151 | + } elseif ($value !== null) { |
|
| 150 | 152 | $this->attach($value, $strict); |
| 151 | 153 | } |
| 152 | 154 | |
@@ -195,7 +197,7 @@ discard block |
||
| 195 | 197 | if ($this->contains($value) === false) { |
| 196 | 198 | $this->values[] = $value; |
| 197 | 199 | } |
| 198 | - }else{ |
|
| 200 | + } else{ |
|
| 199 | 201 | $this->values[] = $value; |
| 200 | 202 | } |
| 201 | 203 | } |