Completed
Pull Request — master (#36)
by rugk
02:38
created
source/Threema/Console/Command/Base.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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) {
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * @return int
69 69
 	 */
70 70
 	public function getAllArgumentsCount() {
71
-		return $this->getRequiredArgumentCount() + (null !== $this->optionalArguments ? count($this->optionalArguments) : 0);
71
+		return $this->getRequiredArgumentCount()+(null !== $this->optionalArguments ? count($this->optionalArguments) : 0);
72 72
 	}
73 73
 
74 74
 	/**
@@ -76,15 +76,15 @@  discard block
 block discarded – undo
76 76
 	 * @return int
77 77
 	 * @throws \Threema\Core\Exception
78 78
 	 */
79
-	private function getIndexByPos($pos){
79
+	private function getIndexByPos($pos) {
80 80
 		$i = array_search($pos, $this->requiredArguments);
81
-		if(false === $i) {
81
+		if (false === $i) {
82 82
 			$i = array_search($pos, $this->optionalArguments);
83
-			if(false !== $i) {
83
+			if (false !== $i) {
84 84
 				$i += count($this->requiredArguments);
85 85
 			}
86 86
 		}
87
-		if(false === $i) {
87
+		if (false === $i) {
88 88
 			throw new Exception('argument '.$pos.' not found');
89 89
 		}
90 90
 
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
 		$i = $this->getIndexByPos($pos);
101 101
 		$required = $i < count($this->requiredArguments);
102 102
 
103
-		if(false === array_key_exists($i, $this->arguments)) {
104
-			if(true === $required) {
103
+		if (false === array_key_exists($i, $this->arguments)) {
104
+			if (true === $required) {
105 105
 				throw new Exception('no argument at position '.$i.' ('.$pos.')');
106 106
 			}
107 107
 			else {
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	public function getArgumentFile($pos) {
122 122
 		$i = $this->getIndexByPos($pos);
123 123
 
124
-		if(false === is_file($this->arguments[$i])) {
124
+		if (false === is_file($this->arguments[$i])) {
125 125
 			throw new Exception('argument '.$i.' is not a file');
126 126
 		}
127 127
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	 */
135 135
 	public function getArgumentPrivateKey($pos) {
136 136
 		$content = Common::getPrivateKey($this->getArgumentStringOrFileContent($pos));
137
-		if(null !== $content) {
137
+		if (null !== $content) {
138 138
 			return hex2bin($content);
139 139
 		}
140 140
 		return null;
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	 */
147 147
 	public function getArgumentPublicKey($pos) {
148 148
 		$content = Common::getPublicKey($this->getArgumentStringOrFileContent($pos));
149
-		if(null !== $content) {
149
+		if (null !== $content) {
150 150
 			return hex2bin($content);
151 151
 		}
152 152
 		return null;
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	 */
159 159
 	private function getArgumentStringOrFileContent($pos) {
160 160
 		$content = $this->getArgument($pos);
161
-		if(file_exists($content)) {
161
+		if (file_exists($content)) {
162 162
 			$content = trim(file_get_contents($content));
163 163
 		}
164 164
 		return $content;
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	 */
171 171
 	public function getArgumentThreemaId($pos) {
172 172
 		$content = $this->getArgument($pos);
173
-		if(null !== $content && strlen($content) == 8) {
173
+		if (null !== $content && strlen($content) == 8) {
174 174
 			return strtoupper($content);
175 175
 		}
176 176
 		return null;
@@ -180,12 +180,12 @@  discard block
 block discarded – undo
180 180
 	 * @return string
181 181
 	 */
182 182
 	protected function readStdIn() {
183
-		$f = fopen( 'php://stdin', 'r' );
183
+		$f = fopen('php://stdin', 'r');
184 184
 
185 185
 		$lines = array();
186
-		while( $line = trim(fgets($f)) ) {
186
+		while ($line = trim(fgets($f))) {
187 187
 
188
-			if(strlen($line) == 0 || $line == "\n") {
188
+			if (strlen($line) == 0 || $line == "\n") {
189 189
 				continue;
190 190
 			}
191 191
 
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 
205 205
 		$argCount = null !== $this->arguments ? count($this->arguments) : 0;
206 206
 
207
-		if($argCount < count($this->requiredArguments)) {
207
+		if ($argCount < count($this->requiredArguments)) {
208 208
 			throw new Exception('invalid count of arguments');
209 209
 		}
210 210
 		$this->doRun();
@@ -217,10 +217,10 @@  discard block
 block discarded – undo
217 217
 	final public function help($shellColors = true) {
218 218
 		$args = array_merge($this->requiredArguments, $this->optionalArguments);
219 219
 
220
-		if(count($args) > 0) {
220
+		if (count($args) > 0) {
221 221
 			$colorPrefix = '';
222 222
 			$colorPostfix = '';
223
-			if(true === $shellColors) {
223
+			if (true === $shellColors) {
224 224
 				$colorPrefix = "\033[0;36m\033[40m";
225 225
 				$colorPostfix = "\033[0m";
226 226
 			}
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -103,8 +103,7 @@
 block discarded – undo
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
 		}
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @author Threema GmbH
4
- * @copyright Copyright (c) 2015-2016 Threema GmbH
5
- */
3
+	 * @author Threema GmbH
4
+	 * @copyright Copyright (c) 2015-2016 Threema GmbH
5
+	 */
6 6
 
7 7
 
8 8
 namespace Threema\Core;
Please login to merge, or discard this patch.
source/Threema/Core/AssocArray.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,8 +36,8 @@
 block discarded – undo
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
 	 */
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 * @return mixed|null return the key value or the default value
29 29
 	 */
30 30
 	public function getValue($key, $defaultValue = null) {
31
-		if(false === array_key_exists($key, $this->data)) {
31
+		if (false === array_key_exists($key, $this->data)) {
32 32
 			return $defaultValue;
33 33
 		}
34 34
 
@@ -43,15 +43,15 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public static final function byJsonString($string, array $requiredKeys = null) {
45 45
 		$v = json_decode($string, true);
46
-		if(null === $v || false === $v) {
46
+		if (null === $v || false === $v) {
47 47
 			throw new Exception('invalid json string');
48 48
 		}
49 49
 
50 50
 		//validate first
51
-		if(null !== $requiredKeys) {
51
+		if (null !== $requiredKeys) {
52 52
 			//validate array first
53
-			foreach($requiredKeys as $requiredKey) {
54
-				if(false === array($v)) {
53
+			foreach ($requiredKeys as $requiredKey) {
54
+				if (false === array($v)) {
55 55
 					throw new Exception('required key '.$requiredKey.' failed');
56 56
 				}
57 57
 			}
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @author Threema GmbH
4
- * @copyright Copyright (c) 2015-2016 Threema GmbH
5
- */
3
+	 * @author Threema GmbH
4
+	 * @copyright Copyright (c) 2015-2016 Threema GmbH
5
+	 */
6 6
 
7 7
 
8 8
 namespace Threema\Core;
Please login to merge, or discard this patch.
source/Threema/MsgApi/Commands/DownloadFile.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
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);
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
 	 * @param object $res
49 49
 	 * @return UploadFileResult
50 50
 	 */
51
-	function parseResult($httpCode, $res){
51
+	function parseResult($httpCode, $res) {
52 52
 		return new UploadFileResult($httpCode, $res);
53 53
 	}
54 54
 }
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @author Threema GmbH
4
- * @copyright Copyright (c) 2015-2016 Threema GmbH
5
- */
3
+	 * @author Threema GmbH
4
+	 * @copyright Copyright (c) 2015-2016 Threema GmbH
5
+	 */
6 6
 
7 7
 
8 8
 namespace Threema\Core;
Please login to merge, or discard this patch.
source/Threema/MsgApi/Helpers/ReceiveMessageResult.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
87 87
 	}
88 88
 
89 89
 	/**
90
-	 * @return \string[]
90
+	 * @return string[]
91 91
 	 */
92 92
 	public function getFiles() {
93 93
 		return $this->files;
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @author Threema GmbH
4
- * @copyright Copyright (c) 2015-2016 Threema GmbH
5
- */
3
+	 * @author Threema GmbH
4
+	 * @copyright Copyright (c) 2015-2016 Threema GmbH
5
+	 */
6 6
 
7 7
 
8 8
 namespace Threema\Core;
Please login to merge, or discard this patch.
source/Threema/MsgApi/Messages/DeliveryReceipt.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	 * @return string
58 58
 	 */
59 59
 	public function getReceiptTypeName() {
60
-		if(true === array_key_exists($this->receiptType, self::$receiptTypesToNames)) {
60
+		if (true === array_key_exists($this->receiptType, self::$receiptTypesToNames)) {
61 61
 			return self::$receiptTypesToNames[$this->receiptType];
62 62
 		}
63 63
 		return null;
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	 * @return string
78 78
 	 */
79 79
 	function __toString() {
80
-		$str = "Delivery receipt (" . $this->getReceiptTypeName() . "): ";
80
+		$str = "Delivery receipt (".$this->getReceiptTypeName()."): ";
81 81
 		$hexMessageIds = array();
82 82
 		foreach ($this->ackedMessageIds as $messageId) {
83 83
 			$hexMessageIds[] = bin2hex($messageId);
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @author Threema GmbH
4
- * @copyright Copyright (c) 2015-2016 Threema GmbH
5
- */
3
+	 * @author Threema GmbH
4
+	 * @copyright Copyright (c) 2015-2016 Threema GmbH
5
+	 */
6 6
 
7 7
 
8 8
 namespace Threema\Core;
Please login to merge, or discard this patch.
samples/testFetchPublicKey.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,9 +22,9 @@
 block discarded – undo
22 22
 
23 23
 
24 24
 $result = $connector->fetchPublicKey('ECHOECHO');
25
-if($result->isSuccess()) {
26
-	echo 'public key '.$result->getPublicKey() . "\n";
25
+if ($result->isSuccess()) {
26
+	echo 'public key '.$result->getPublicKey()."\n";
27 27
 }
28 28
 else {
29
-	echo 'error '.$result->getErrorMessage() . "\n";
29
+	echo 'error '.$result->getErrorMessage()."\n";
30 30
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,7 +29,6 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
samples/testKeyLookup.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,9 +21,9 @@
 block discarded – undo
21 21
 $connector = new Connection($settings, $publicKeyStore);
22 22
 
23 23
 $result = $connector->keyLookupByPhoneNumber('123456789');
24
-if($result->isSuccess()) {
25
-	echo 'Threema ID found: '.$result->getId() . "\n";
24
+if ($result->isSuccess()) {
25
+	echo 'Threema ID found: '.$result->getId()."\n";
26 26
 }
27 27
 else {
28
-	echo 'Error: '.$result->getErrorMessage() . "\n";
28
+	echo 'Error: '.$result->getErrorMessage()."\n";
29 29
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,7 +29,6 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
samples/testSendE2EFile.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,12 +23,12 @@
 block discarded – undo
23 23
 $senderPrivateKey = "MY_PUBLIC_KEY_IN_BIN";
24 24
 $filePath = "/path/to/my/file.pdf";
25 25
 
26
-$e2eHelper = new \Threema\MsgApi\Helpers\E2EHelper($senderPrivateKey,$connector);
26
+$e2eHelper = new \Threema\MsgApi\Helpers\E2EHelper($senderPrivateKey, $connector);
27 27
 $result = $e2eHelper->sendFileMessage("TEST1234", $filePath);
28 28
 
29
-if(true === $result->isSuccess()) {
30
-	echo 'File Message ID: '.$result->getMessageId() . "\n";
29
+if (true === $result->isSuccess()) {
30
+	echo 'File Message ID: '.$result->getMessageId()."\n";
31 31
 }
32 32
 else {
33
-	echo 'Error: '.$result->getErrorMessage() . "\n";
33
+	echo 'Error: '.$result->getErrorMessage()."\n";
34 34
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,7 +29,6 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
samples/testSendE2EText.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -22,12 +22,12 @@
 block discarded – undo
22 22
 
23 23
 $senderPrivateKey = "MY_PUBLIC_KEY_IN_BIN";
24 24
 
25
-$e2eHelper = new \Threema\MsgApi\Helpers\E2EHelper($senderPrivateKey,$connector);
25
+$e2eHelper = new \Threema\MsgApi\Helpers\E2EHelper($senderPrivateKey, $connector);
26 26
 $result = $e2eHelper->sendTextMessage("TEST1234", "This is an end-to-end encrypted message");
27 27
 
28
-if(true === $result->isSuccess()) {
29
-	echo 'Message ID: '.$result->getMessageId() . "\n";
28
+if (true === $result->isSuccess()) {
29
+	echo 'Message ID: '.$result->getMessageId()."\n";
30 30
 }
31 31
 else {
32
-	echo 'Error: '.$result->getErrorMessage() . "\n";
32
+	echo 'Error: '.$result->getErrorMessage()."\n";
33 33
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,7 +29,6 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.