Passed
Push — master ( 183e2e...18acb1 )
by Morris
11:28 queued 10s
created
apps/dav/lib/CardDAV/CardDavBackend.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 			->from('addressbooks')
127 127
 			->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));
128 128
 
129
-		return (int)$query->execute()->fetchColumn();
129
+		return (int) $query->execute()->fetchColumn();
130 130
 	}
131 131
 
132 132
 	/**
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
 				'uri' => $row['uri'],
164 164
 				'principaluri' => $this->convertPrincipal($row['principaluri'], false),
165 165
 				'{DAV:}displayname' => $row['displayname'],
166
-				'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
166
+				'{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'],
167 167
 				'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
168
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
168
+				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
169 169
 			];
170 170
 
171 171
 			$this->addOwnerPrincipal($addressBooks[$row['id']]);
@@ -176,10 +176,10 @@  discard block
 block discarded – undo
176 176
 		$principals = $this->principalBackend->getGroupMembership($principalUriOriginal, true);
177 177
 		$principals = array_merge($principals, $this->principalBackend->getCircleMembership($principalUriOriginal));
178 178
 
179
-		$principals = array_map(function ($principal) {
179
+		$principals = array_map(function($principal) {
180 180
 			return urldecode($principal);
181 181
 		}, $principals);
182
-		$principals[]= $principalUri;
182
+		$principals[] = $principalUri;
183 183
 
184 184
 		$query = $this->db->getQueryBuilder();
185 185
 		$result = $query->select(['a.id', 'a.uri', 'a.displayname', 'a.principaluri', 'a.description', 'a.synctoken', 's.access'])
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 			->setParameter('principaluri', $principals, IQueryBuilder::PARAM_STR_ARRAY)
192 192
 			->execute();
193 193
 
194
-		$readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
194
+		$readOnlyPropertyName = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}read-only';
195 195
 		while ($row = $result->fetch()) {
196 196
 			if ($row['principaluri'] === $principalUri) {
197 197
 				continue;
@@ -211,18 +211,18 @@  discard block
 block discarded – undo
211 211
 			}
212 212
 
213 213
 			list(, $name) = \Sabre\Uri\split($row['principaluri']);
214
-			$uri = $row['uri'] . '_shared_by_' . $name;
215
-			$displayName = $row['displayname'] . ' (' . $this->getUserDisplayName($name) . ')';
214
+			$uri = $row['uri'].'_shared_by_'.$name;
215
+			$displayName = $row['displayname'].' ('.$this->getUserDisplayName($name).')';
216 216
 
217 217
 			$addressBooks[$row['id']] = [
218 218
 				'id'  => $row['id'],
219 219
 				'uri' => $uri,
220 220
 				'principaluri' => $principalUriOriginal,
221 221
 				'{DAV:}displayname' => $displayName,
222
-				'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
222
+				'{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'],
223 223
 				'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
224
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
225
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $row['principaluri'],
224
+				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
225
+				'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal' => $row['principaluri'],
226 226
 				$readOnlyPropertyName => $readOnly,
227 227
 			];
228 228
 
@@ -249,9 +249,9 @@  discard block
 block discarded – undo
249 249
 				'uri' => $row['uri'],
250 250
 				'principaluri' => $this->convertPrincipal($row['principaluri'], false),
251 251
 				'{DAV:}displayname' => $row['displayname'],
252
-				'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
252
+				'{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'],
253 253
 				'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
254
-				'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
254
+				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
255 255
 			];
256 256
 
257 257
 			$this->addOwnerPrincipal($addressBooks[$row['id']]);
@@ -296,9 +296,9 @@  discard block
 block discarded – undo
296 296
 			'uri' => $row['uri'],
297 297
 			'principaluri' => $row['principaluri'],
298 298
 			'{DAV:}displayname' => $row['displayname'],
299
-			'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
299
+			'{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'],
300 300
 			'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
301
-			'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
301
+			'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
302 302
 		];
303 303
 
304 304
 		$this->addOwnerPrincipal($addressBook);
@@ -330,9 +330,9 @@  discard block
 block discarded – undo
330 330
 			'uri' => $row['uri'],
331 331
 			'principaluri' => $row['principaluri'],
332 332
 			'{DAV:}displayname' => $row['displayname'],
333
-			'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
333
+			'{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'],
334 334
 			'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
335
-			'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
335
+			'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
336 336
 		];
337 337
 
338 338
 		$this->addOwnerPrincipal($addressBook);
@@ -359,20 +359,20 @@  discard block
 block discarded – undo
359 359
 	public function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch) {
360 360
 		$supportedProperties = [
361 361
 			'{DAV:}displayname',
362
-			'{' . Plugin::NS_CARDDAV . '}addressbook-description',
362
+			'{'.Plugin::NS_CARDDAV.'}addressbook-description',
363 363
 		];
364 364
 
365 365
 		/**
366 366
 		 * @suppress SqlInjectionChecker
367 367
 		 */
368
-		$propPatch->handle($supportedProperties, function ($mutations) use ($addressBookId) {
368
+		$propPatch->handle($supportedProperties, function($mutations) use ($addressBookId) {
369 369
 			$updates = [];
370 370
 			foreach ($mutations as $property=>$newValue) {
371 371
 				switch ($property) {
372 372
 					case '{DAV:}displayname':
373 373
 						$updates['displayname'] = $newValue;
374 374
 						break;
375
-					case '{' . Plugin::NS_CARDDAV . '}addressbook-description':
375
+					case '{'.Plugin::NS_CARDDAV.'}addressbook-description':
376 376
 						$updates['description'] = $newValue;
377 377
 						break;
378 378
 				}
@@ -415,11 +415,11 @@  discard block
 block discarded – undo
415 415
 				case '{DAV:}displayname':
416 416
 					$values['displayname'] = $newValue;
417 417
 					break;
418
-				case '{' . Plugin::NS_CARDDAV . '}addressbook-description':
418
+				case '{'.Plugin::NS_CARDDAV.'}addressbook-description':
419 419
 					$values['description'] = $newValue;
420 420
 					break;
421 421
 				default:
422
-					throw new BadRequest('Unknown property: ' . $property);
422
+					throw new BadRequest('Unknown property: '.$property);
423 423
 			}
424 424
 		}
425 425
 
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
 
504 504
 		$result = $query->execute();
505 505
 		while ($row = $result->fetch()) {
506
-			$row['etag'] = '"' . $row['etag'] . '"';
506
+			$row['etag'] = '"'.$row['etag'].'"';
507 507
 
508 508
 			$modified = false;
509 509
 			$row['carddata'] = $this->readBlob($row['carddata'], $modified);
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
 		if (!$row) {
544 544
 			return false;
545 545
 		}
546
-		$row['etag'] = '"' . $row['etag'] . '"';
546
+		$row['etag'] = '"'.$row['etag'].'"';
547 547
 
548 548
 		$modified = false;
549 549
 		$row['carddata'] = $this->readBlob($row['carddata'], $modified);
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
 			$result = $query->execute();
586 586
 
587 587
 			while ($row = $result->fetch()) {
588
-				$row['etag'] = '"' . $row['etag'] . '"';
588
+				$row['etag'] = '"'.$row['etag'].'"';
589 589
 
590 590
 				$modified = false;
591 591
 				$row['carddata'] = $this->readBlob($row['carddata'], $modified);
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 				'cardUri' => $cardUri,
668 668
 				'cardData' => $cardData]));
669 669
 
670
-		return '"' . $etag . '"';
670
+		return '"'.$etag.'"';
671 671
 	}
672 672
 
673 673
 	/**
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 		// check for recently stored etag and stop if it is the same
704 704
 		$etagCacheKey = "$addressBookId#$cardUri";
705 705
 		if (isset($this->etagCache[$etagCacheKey]) && $this->etagCache[$etagCacheKey] === $etag) {
706
-			return '"' . $etag . '"';
706
+			return '"'.$etag.'"';
707 707
 		}
708 708
 
709 709
 		$query->update($this->dbCardsTable)
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
 				'cardUri' => $cardUri,
728 728
 				'cardData' => $cardData]));
729 729
 
730
-		return '"' . $etag . '"';
730
+		return '"'.$etag.'"';
731 731
 	}
732 732
 
733 733
 	/**
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
 	public function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, $limit = null) {
826 826
 		// Current synctoken
827 827
 		$stmt = $this->db->prepare('SELECT `synctoken` FROM `*PREFIX*addressbooks` WHERE `id` = ?');
828
-		$stmt->execute([ $addressBookId ]);
828
+		$stmt->execute([$addressBookId]);
829 829
 		$currentToken = $stmt->fetchColumn(0);
830 830
 
831 831
 		if (is_null($currentToken)) {
@@ -841,8 +841,8 @@  discard block
 block discarded – undo
841 841
 
842 842
 		if ($syncToken) {
843 843
 			$query = "SELECT `uri`, `operation` FROM `*PREFIX*addressbookchanges` WHERE `synctoken` >= ? AND `synctoken` < ? AND `addressbookid` = ? ORDER BY `synctoken`";
844
-			if ($limit>0) {
845
-				$query .= " LIMIT " . (int)$limit;
844
+			if ($limit > 0) {
845
+				$query .= " LIMIT ".(int) $limit;
846 846
 			}
847 847
 
848 848
 			// Fetching all changes
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
 	 * @param bool $modified
910 910
 	 * @return string
911 911
 	 */
912
-	private function readBlob($cardData, &$modified=false) {
912
+	private function readBlob($cardData, &$modified = false) {
913 913
 		if (is_resource($cardData)) {
914 914
 			$cardData = stream_get_contents($cardData);
915 915
 		}
@@ -997,7 +997,7 @@  discard block
 block discarded – undo
997 997
 			if (!$escapePattern) {
998 998
 				$query2->andWhere($query2->expr()->ilike('cp.value', $query2->createNamedParameter($pattern)));
999 999
 			} else {
1000
-				$query2->andWhere($query2->expr()->ilike('cp.value', $query2->createNamedParameter('%' . $this->db->escapeLikeParameter($pattern) . '%')));
1000
+				$query2->andWhere($query2->expr()->ilike('cp.value', $query2->createNamedParameter('%'.$this->db->escapeLikeParameter($pattern).'%')));
1001 1001
 			}
1002 1002
 		}
1003 1003
 
@@ -1011,7 +1011,7 @@  discard block
 block discarded – undo
1011 1011
 		$result = $query2->execute();
1012 1012
 		$matches = $result->fetchAll();
1013 1013
 		$result->closeCursor();
1014
-		$matches = array_map(function ($match) {
1014
+		$matches = array_map(function($match) {
1015 1015
 			return (int) $match['cardid'];
1016 1016
 		}, $matches);
1017 1017
 
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
 
1026 1026
 		$result->closeCursor();
1027 1027
 
1028
-		return array_map(function ($array) {
1028
+		return array_map(function($array) {
1029 1029
 			$modified = false;
1030 1030
 			$array['carddata'] = $this->readBlob($array['carddata'], $modified);
1031 1031
 			if ($modified) {
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
 		$result->closeCursor();
1072 1072
 
1073 1073
 		if (!isset($uri['uri'])) {
1074
-			throw new \InvalidArgumentException('Card does not exists: ' . $id);
1074
+			throw new \InvalidArgumentException('Card does not exists: '.$id);
1075 1075
 		}
1076 1076
 
1077 1077
 		return $uri['uri'];
@@ -1096,7 +1096,7 @@  discard block
 block discarded – undo
1096 1096
 
1097 1097
 		if (is_array($contact)) {
1098 1098
 			$modified = false;
1099
-			$contact['etag'] = '"' . $contact['etag'] . '"';
1099
+			$contact['etag'] = '"'.$contact['etag'].'"';
1100 1100
 			$contact['carddata'] = $this->readBlob($contact['carddata'], $modified);
1101 1101
 			if ($modified) {
1102 1102
 				$contact['size'] = strlen($contact['carddata']);
@@ -1209,10 +1209,10 @@  discard block
 block discarded – undo
1209 1209
 		$result->closeCursor();
1210 1210
 
1211 1211
 		if (!isset($cardIds['id'])) {
1212
-			throw new \InvalidArgumentException('Card does not exists: ' . $uri);
1212
+			throw new \InvalidArgumentException('Card does not exists: '.$uri);
1213 1213
 		}
1214 1214
 
1215
-		return (int)$cardIds['id'];
1215
+		return (int) $cardIds['id'];
1216 1216
 	}
1217 1217
 
1218 1218
 	/**
@@ -1237,8 +1237,8 @@  discard block
 block discarded – undo
1237 1237
 	}
1238 1238
 
1239 1239
 	private function addOwnerPrincipal(&$addressbookInfo) {
1240
-		$ownerPrincipalKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal';
1241
-		$displaynameKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname';
1240
+		$ownerPrincipalKey = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal';
1241
+		$displaynameKey = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD.'}owner-displayname';
1242 1242
 		if (isset($addressbookInfo[$ownerPrincipalKey])) {
1243 1243
 			$uri = $addressbookInfo[$ownerPrincipalKey];
1244 1244
 		} else {
Please login to merge, or discard this patch.