@@ -111,7 +111,9 @@ discard block |
||
| 111 | 111 | if ($line === "") { |
| 112 | 112 | throw new RuntimeException('empty response'); |
| 113 | 113 | } |
| 114 | - if ($this->debug) echo "<< ".$line."\n"; |
|
| 114 | + if ($this->debug) { |
|
| 115 | + echo "<< ".$line."\n"; |
|
| 116 | + } |
|
| 115 | 117 | return $line . "\n"; |
| 116 | 118 | } |
| 117 | 119 | |
@@ -326,7 +328,9 @@ discard block |
||
| 326 | 328 | * @throws RuntimeException |
| 327 | 329 | */ |
| 328 | 330 | public function write(string $data) { |
| 329 | - if ($this->debug) echo ">> ".$data ."\n"; |
|
| 331 | + if ($this->debug) { |
|
| 332 | + echo ">> ".$data ."\n"; |
|
| 333 | + } |
|
| 330 | 334 | |
| 331 | 335 | if (fwrite($this->stream, $data . "\r\n") === false) { |
| 332 | 336 | throw new RuntimeException('failed to write - connection closed?'); |
@@ -478,7 +482,9 @@ discard block |
||
| 478 | 482 | public function getCapabilities(): array { |
| 479 | 483 | $response = $this->requestAndResponse('CAPABILITY'); |
| 480 | 484 | |
| 481 | - if (!$response) return []; |
|
| 485 | + if (!$response) { |
|
| 486 | + return []; |
|
| 487 | + } |
|
| 482 | 488 | |
| 483 | 489 | $capabilities = []; |
| 484 | 490 | foreach ($response as $line) { |
@@ -638,13 +644,14 @@ discard block |
||
| 638 | 644 | // if we want only one message we can ignore everything else and just return |
| 639 | 645 | if ($to === null && !is_array($from) && ($uid ? $tokens[2][$uidKey] == $from : $tokens[0] == $from)) { |
| 640 | 646 | // we still need to read all lines |
| 641 | - while (!$this->readLine($tokens, $tag)) |
|
| 642 | - |
|
| 647 | + while (!$this->readLine($tokens, $tag)) { |
|
| 648 | + |
|
| 643 | 649 | return $data; |
| 650 | + } |
|
| 644 | 651 | } |
| 645 | 652 | if ($uid) { |
| 646 | 653 | $result[$tokens[2][$uidKey]] = $data; |
| 647 | - }else{ |
|
| 654 | + } else{ |
|
| 648 | 655 | $result[$tokens[0]] = $data; |
| 649 | 656 | } |
| 650 | 657 | } |