@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * @param string $subject |
| 49 | 49 | * @param string[] $requiredArguments |
| 50 | 50 | * @param string $description |
| 51 | - * @param array $optionalArguments |
|
| 51 | + * @param string[] $optionalArguments |
|
| 52 | 52 | */ |
| 53 | 53 | public function __construct($subject, array $requiredArguments, $description, array $optionalArguments = array()) { |
| 54 | 54 | $this->subject = $subject; |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * return a valid file path |
| 116 | 116 | * |
| 117 | 117 | * @param string $pos |
| 118 | - * @return null|string |
|
| 118 | + * @return string |
|
| 119 | 119 | * @throws \Threema\Core\Exception |
| 120 | 120 | */ |
| 121 | 121 | public function getArgumentFile($pos) { |
@@ -103,8 +103,7 @@ |
||
| 103 | 103 | if(false === array_key_exists($i, $this->arguments)) { |
| 104 | 104 | if(true === $required) { |
| 105 | 105 | throw new Exception('no argument at position '.$i.' ('.$pos.')'); |
| 106 | - } |
|
| 107 | - else { |
|
| 106 | + } else { |
|
| 108 | 107 | return null; |
| 109 | 108 | } |
| 110 | 109 | } |
@@ -36,8 +36,8 @@ |
||
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | - * @param $string |
|
| 40 | - * @param array|null $requiredKeys |
|
| 39 | + * @param string $string |
|
| 40 | + * @param string[] $requiredKeys |
|
| 41 | 41 | * @return AssocArray |
| 42 | 42 | * @throws Exception |
| 43 | 43 | */ |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | /** |
| 41 | 41 | * @param int $httpCode |
| 42 | 42 | * @param object $res |
| 43 | - * @return UploadFileResult |
|
| 43 | + * @return DownloadFileResult |
|
| 44 | 44 | */ |
| 45 | 45 | function parseResult($httpCode, $res){ |
| 46 | 46 | return new DownloadFileResult($httpCode, $res); |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | - * @return \string[] |
|
| 76 | + * @return string[] |
|
| 77 | 77 | */ |
| 78 | 78 | public function getErrors() { |
| 79 | 79 | return $this->errors; |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | - * @return \string[] |
|
| 90 | + * @return string[] |
|
| 91 | 91 | */ |
| 92 | 92 | public function getFiles() { |
| 93 | 93 | return $this->files; |
@@ -65,7 +65,7 @@ |
||
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | 67 | * Get the acknowledged message ids |
| 68 | - * @return array |
|
| 68 | + * @return string[] |
|
| 69 | 69 | */ |
| 70 | 70 | public function getAckedMessageIds() { |
| 71 | 71 | return $this->ackedMessageIds; |
@@ -142,6 +142,11 @@ discard block |
||
| 142 | 142 | return $this->makeBox($message, $nonce, $senderPrivateKey, $recipientPublicKey); |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | + /** |
|
| 146 | + * @param string $senderPrivateKey |
|
| 147 | + * @param string $recipientPublicKey |
|
| 148 | + * @param string $nonce |
|
| 149 | + */ |
|
| 145 | 150 | final public function encryptFileMessage(UploadFileResult $uploadFileResult, |
| 146 | 151 | EncryptResult $encryptResult, |
| 147 | 152 | UploadFileResult $thumbnailUploadFileResult = null, |
@@ -190,9 +195,9 @@ discard block |
||
| 190 | 195 | * make a secret box |
| 191 | 196 | * |
| 192 | 197 | * @param $data |
| 193 | - * @param $nonce |
|
| 198 | + * @param string $nonce |
|
| 194 | 199 | * @param $key |
| 195 | - * @return mixed |
|
| 200 | + * @return string |
|
| 196 | 201 | */ |
| 197 | 202 | abstract protected function makeSecretBox($data, $nonce, $key); |
| 198 | 203 | |
@@ -376,7 +381,7 @@ discard block |
||
| 376 | 381 | abstract public function validate(); |
| 377 | 382 | |
| 378 | 383 | /** |
| 379 | - * @param $data |
|
| 384 | + * @param string $data |
|
| 380 | 385 | * @return EncryptResult |
| 381 | 386 | */ |
| 382 | 387 | public final function encryptFile($data) { |
@@ -388,7 +393,7 @@ discard block |
||
| 388 | 393 | /** |
| 389 | 394 | * @param string $data as binary |
| 390 | 395 | * @param string $key as binary |
| 391 | - * @return null|string |
|
| 396 | + * @return string |
|
| 392 | 397 | */ |
| 393 | 398 | public final function decryptFile($data, $key) { |
| 394 | 399 | $result = $this->openSecretBox($data, self::FILE_NONCE, $key); |
@@ -405,6 +410,10 @@ discard block |
||
| 405 | 410 | return new EncryptResult($box, $key, self::FILE_THUMBNAIL_NONCE, strlen($box)); |
| 406 | 411 | } |
| 407 | 412 | |
| 413 | + /** |
|
| 414 | + * @param string $data |
|
| 415 | + * @param string $key |
|
| 416 | + */ |
|
| 408 | 417 | public final function decryptFileThumbnail($data, $key) { |
| 409 | 418 | $result = $this->openSecretBox($data, self::FILE_THUMBNAIL_NONCE, $key); |
| 410 | 419 | return false === $result ? null : $result; |
@@ -29,7 +29,6 @@ |
||
| 29 | 29 | $result = $connector->sendSimple($receiver, "This is a Test Message"); |
| 30 | 30 | if($result->isSuccess()) { |
| 31 | 31 | echo 'Message ID: '.$result->getMessageId() . "\n"; |
| 32 | -} |
|
| 33 | -else { |
|
| 32 | +} else { |
|
| 34 | 33 | echo 'Error: '.$result->getErrorMessage() . "\n"; |
| 35 | 34 | } |
@@ -138,14 +138,12 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | if(null === $found) { |
| 140 | 140 | $this->help(); |
| 141 | - } |
|
| 142 | - else { |
|
| 141 | + } else { |
|
| 143 | 142 | |
| 144 | 143 | |
| 145 | 144 | try { |
| 146 | 145 | $found->run($this->arguments); |
| 147 | - } |
|
| 148 | - catch(Exception $x) { |
|
| 146 | + } catch(Exception $x) { |
|
| 149 | 147 | Common::l(); |
| 150 | 148 | Common::e('ERROR: '.$x->getMessage()); |
| 151 | 149 | Common::e(get_class($x)); |
@@ -168,8 +166,7 @@ discard block |
||
| 168 | 166 | Common::l($data); |
| 169 | 167 | Common::l(str_repeat('-', strlen($data))); |
| 170 | 168 | Common::l(); |
| 171 | - } |
|
| 172 | - else { |
|
| 169 | + } else { |
|
| 173 | 170 | list($key, $command) = $data; |
| 174 | 171 | Common::ln($this->scriptName.' '."\033[1;33m".implode(' ', $key)."\033[0m".' '.$command->help()); |
| 175 | 172 | Common::l(); |
@@ -186,8 +183,7 @@ discard block |
||
| 186 | 183 | foreach($this->commands as $data) { |
| 187 | 184 | if(is_scalar($data)) { |
| 188 | 185 | $writer->__invoke($data, null, null, false); |
| 189 | - } |
|
| 190 | - else { |
|
| 186 | + } else { |
|
| 191 | 187 | list($key, $command) = $data; |
| 192 | 188 | $writer->__invoke($command->subject(false), $this->scriptName.' '.implode(' ', $key).' '.$command->help(false), $command->description(), true); |
| 193 | 189 | } |
@@ -247,8 +247,7 @@ |
||
| 247 | 247 | |
| 248 | 248 | $receiveResult->addFile('image', $filePath); |
| 249 | 249 | } |
| 250 | - } |
|
| 251 | - else if($message instanceof FileMessage) { |
|
| 250 | + } else if($message instanceof FileMessage) { |
|
| 252 | 251 | $result = $this->downloadFile($message, $message->getBlobId(), $downloadMessage); |
| 253 | 252 | |
| 254 | 253 | if(null !== $result && true === $result->isSuccess()) { |