Passed
Push — master ( 644e6d...d4b99c )
by Christoph
22:40 queued 10s
created
apps/dav/lib/CardDAV/CardDavBackend.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 				'uri' => $row['uri'],
180 180
 				'principaluri' => $this->convertPrincipal($row['principaluri'], false),
181 181
 				'{DAV:}displayname' => $row['displayname'],
182
-				'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
182
+				'{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'],
183 183
 				'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
184 184
 				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ?: '0',
185 185
 			];
@@ -204,13 +204,13 @@  discard block
 block discarded – undo
204 204
 			->setParameter('principaluri', $principals, IQueryBuilder::PARAM_STR_ARRAY)
205 205
 			->execute();
206 206
 
207
-		$readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
207
+		$readOnlyPropertyName = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}read-only';
208 208
 		while ($row = $result->fetch()) {
209 209
 			if ($row['principaluri'] === $principalUri) {
210 210
 				continue;
211 211
 			}
212 212
 
213
-			$readOnly = (int)$row['access'] === Backend::ACCESS_READ;
213
+			$readOnly = (int) $row['access'] === Backend::ACCESS_READ;
214 214
 			if (isset($addressBooks[$row['id']])) {
215 215
 				if ($readOnly) {
216 216
 					// New share can not have more permissions then the old one.
@@ -224,18 +224,18 @@  discard block
 block discarded – undo
224 224
 			}
225 225
 
226 226
 			list(, $name) = \Sabre\Uri\split($row['principaluri']);
227
-			$uri = $row['uri'] . '_shared_by_' . $name;
228
-			$displayName = $row['displayname'] . ' (' . $this->getUserDisplayName($name) . ')';
227
+			$uri = $row['uri'].'_shared_by_'.$name;
228
+			$displayName = $row['displayname'].' ('.$this->getUserDisplayName($name).')';
229 229
 
230 230
 			$addressBooks[$row['id']] = [
231 231
 				'id' => $row['id'],
232 232
 				'uri' => $uri,
233 233
 				'principaluri' => $principalUriOriginal,
234 234
 				'{DAV:}displayname' => $displayName,
235
-				'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
235
+				'{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'],
236 236
 				'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
237 237
 				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ?: '0',
238
-				'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $row['principaluri'],
238
+				'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal' => $row['principaluri'],
239 239
 				$readOnlyPropertyName => $readOnly,
240 240
 			];
241 241
 
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 				'uri' => $row['uri'],
263 263
 				'principaluri' => $this->convertPrincipal($row['principaluri'], false),
264 264
 				'{DAV:}displayname' => $row['displayname'],
265
-				'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
265
+				'{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'],
266 266
 				'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
267 267
 				'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ?: '0',
268 268
 			];
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 			'uri' => $row['uri'],
310 310
 			'principaluri' => $row['principaluri'],
311 311
 			'{DAV:}displayname' => $row['displayname'],
312
-			'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
312
+			'{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'],
313 313
 			'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
314 314
 			'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ?: '0',
315 315
 		];
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 			'uri' => $row['uri'],
344 344
 			'principaluri' => $row['principaluri'],
345 345
 			'{DAV:}displayname' => $row['displayname'],
346
-			'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
346
+			'{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'],
347 347
 			'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
348 348
 			'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ?: '0',
349 349
 		];
@@ -372,17 +372,17 @@  discard block
 block discarded – undo
372 372
 	public function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch) {
373 373
 		$supportedProperties = [
374 374
 			'{DAV:}displayname',
375
-			'{' . Plugin::NS_CARDDAV . '}addressbook-description',
375
+			'{'.Plugin::NS_CARDDAV.'}addressbook-description',
376 376
 		];
377 377
 
378
-		$propPatch->handle($supportedProperties, function ($mutations) use ($addressBookId) {
378
+		$propPatch->handle($supportedProperties, function($mutations) use ($addressBookId) {
379 379
 			$updates = [];
380 380
 			foreach ($mutations as $property => $newValue) {
381 381
 				switch ($property) {
382 382
 					case '{DAV:}displayname':
383 383
 						$updates['displayname'] = $newValue;
384 384
 						break;
385
-					case '{' . Plugin::NS_CARDDAV . '}addressbook-description':
385
+					case '{'.Plugin::NS_CARDDAV.'}addressbook-description':
386 386
 						$updates['description'] = $newValue;
387 387
 						break;
388 388
 				}
@@ -398,9 +398,9 @@  discard block
 block discarded – undo
398 398
 
399 399
 			$this->addChange($addressBookId, "", 2);
400 400
 
401
-			$addressBookRow = $this->getAddressBookById((int)$addressBookId);
401
+			$addressBookRow = $this->getAddressBookById((int) $addressBookId);
402 402
 			$shares = $this->getShares($addressBookId);
403
-			$this->dispatcher->dispatchTyped(new AddressBookUpdatedEvent((int)$addressBookId, $addressBookRow, $shares, $mutations));
403
+			$this->dispatcher->dispatchTyped(new AddressBookUpdatedEvent((int) $addressBookId, $addressBookRow, $shares, $mutations));
404 404
 
405 405
 			return true;
406 406
 		});
@@ -429,11 +429,11 @@  discard block
 block discarded – undo
429 429
 				case '{DAV:}displayname':
430 430
 					$values['displayname'] = $newValue;
431 431
 					break;
432
-				case '{' . Plugin::NS_CARDDAV . '}addressbook-description':
432
+				case '{'.Plugin::NS_CARDDAV.'}addressbook-description':
433 433
 					$values['description'] = $newValue;
434 434
 					break;
435 435
 				default:
436
-					throw new BadRequest('Unknown property: ' . $property);
436
+					throw new BadRequest('Unknown property: '.$property);
437 437
 			}
438 438
 		}
439 439
 
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
 
458 458
 		$addressBookId = $query->getLastInsertId();
459 459
 		$addressBookRow = $this->getAddressBookById($addressBookId);
460
-		$this->dispatcher->dispatchTyped(new AddressBookCreatedEvent((int)$addressBookId, $addressBookRow));
460
+		$this->dispatcher->dispatchTyped(new AddressBookCreatedEvent((int) $addressBookId, $addressBookRow));
461 461
 
462 462
 		return $addressBookId;
463 463
 	}
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
 
529 529
 		$result = $query->execute();
530 530
 		while ($row = $result->fetch()) {
531
-			$row['etag'] = '"' . $row['etag'] . '"';
531
+			$row['etag'] = '"'.$row['etag'].'"';
532 532
 
533 533
 			$modified = false;
534 534
 			$row['carddata'] = $this->readBlob($row['carddata'], $modified);
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 		if (!$row) {
569 569
 			return false;
570 570
 		}
571
-		$row['etag'] = '"' . $row['etag'] . '"';
571
+		$row['etag'] = '"'.$row['etag'].'"';
572 572
 
573 573
 		$modified = false;
574 574
 		$row['carddata'] = $this->readBlob($row['carddata'], $modified);
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
 			$result = $query->execute();
611 611
 
612 612
 			while ($row = $result->fetch()) {
613
-				$row['etag'] = '"' . $row['etag'] . '"';
613
+				$row['etag'] = '"'.$row['etag'].'"';
614 614
 
615 615
 				$modified = false;
616 616
 				$row['carddata'] = $this->readBlob($row['carddata'], $modified);
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
 			->andWhere($q->expr()->eq('uid', $q->createNamedParameter($uid)))
662 662
 			->setMaxResults(1);
663 663
 		$result = $q->execute();
664
-		$count = (bool)$result->fetchOne();
664
+		$count = (bool) $result->fetchOne();
665 665
 		$result->closeCursor();
666 666
 		if ($count) {
667 667
 			throw new \Sabre\DAV\Exception\BadRequest('VCard object with uid already exists in this addressbook collection.');
@@ -689,14 +689,14 @@  discard block
 block discarded – undo
689 689
 		$addressBookData = $this->getAddressBookById($addressBookId);
690 690
 		$shares = $this->getShares($addressBookId);
691 691
 		$objectRow = $this->getCard($addressBookId, $cardUri);
692
-		$this->dispatcher->dispatchTyped(new CardCreatedEvent((int)$addressBookId, $addressBookData, $shares, $objectRow));
692
+		$this->dispatcher->dispatchTyped(new CardCreatedEvent((int) $addressBookId, $addressBookData, $shares, $objectRow));
693 693
 		$this->legacyDispatcher->dispatch('\OCA\DAV\CardDAV\CardDavBackend::createCard',
694 694
 			new GenericEvent(null, [
695 695
 				'addressBookId' => $addressBookId,
696 696
 				'cardUri' => $cardUri,
697 697
 				'cardData' => $cardData]));
698 698
 
699
-		return '"' . $etag . '"';
699
+		return '"'.$etag.'"';
700 700
 	}
701 701
 
702 702
 	/**
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 		// check for recently stored etag and stop if it is the same
733 733
 		$etagCacheKey = "$addressBookId#$cardUri";
734 734
 		if (isset($this->etagCache[$etagCacheKey]) && $this->etagCache[$etagCacheKey] === $etag) {
735
-			return '"' . $etag . '"';
735
+			return '"'.$etag.'"';
736 736
 		}
737 737
 
738 738
 		$query->update($this->dbCardsTable)
@@ -753,14 +753,14 @@  discard block
 block discarded – undo
753 753
 		$addressBookData = $this->getAddressBookById($addressBookId);
754 754
 		$shares = $this->getShares($addressBookId);
755 755
 		$objectRow = $this->getCard($addressBookId, $cardUri);
756
-		$this->dispatcher->dispatchTyped(new CardUpdatedEvent((int)$addressBookId, $addressBookData, $shares, $objectRow));
756
+		$this->dispatcher->dispatchTyped(new CardUpdatedEvent((int) $addressBookId, $addressBookData, $shares, $objectRow));
757 757
 		$this->legacyDispatcher->dispatch('\OCA\DAV\CardDAV\CardDavBackend::updateCard',
758 758
 			new GenericEvent(null, [
759 759
 				'addressBookId' => $addressBookId,
760 760
 				'cardUri' => $cardUri,
761 761
 				'cardData' => $cardData]));
762 762
 
763
-		return '"' . $etag . '"';
763
+		return '"'.$etag.'"';
764 764
 	}
765 765
 
766 766
 	/**
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
 
791 791
 		if ($ret === 1) {
792 792
 			if ($cardId !== null) {
793
-				$this->dispatcher->dispatchTyped(new CardDeletedEvent((int)$addressBookId, $addressBookData, $shares, $objectRow));
793
+				$this->dispatcher->dispatchTyped(new CardDeletedEvent((int) $addressBookId, $addressBookData, $shares, $objectRow));
794 794
 				$this->legacyDispatcher->dispatch('\OCA\DAV\CardDAV\CardDavBackend::deleteCard',
795 795
 					new GenericEvent(null, [
796 796
 						'addressBookId' => $addressBookId,
@@ -1043,7 +1043,7 @@  discard block
 block discarded – undo
1043 1043
 									   string $pattern,
1044 1044
 									   array $searchProperties,
1045 1045
 									   array $options = []): array {
1046
-		$addressBookIds = array_map(static function ($row):int {
1046
+		$addressBookIds = array_map(static function($row):int {
1047 1047
 			return (int) $row['id'];
1048 1048
 		}, $this->getAddressBooksForUser($principalUri));
1049 1049
 
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
 			if (!$escapePattern) {
1107 1107
 				$query2->andWhere($query2->expr()->ilike('cp.value', $query2->createNamedParameter($pattern)));
1108 1108
 			} else {
1109
-				$query2->andWhere($query2->expr()->ilike('cp.value', $query2->createNamedParameter('%' . $this->db->escapeLikeParameter($pattern) . '%')));
1109
+				$query2->andWhere($query2->expr()->ilike('cp.value', $query2->createNamedParameter('%'.$this->db->escapeLikeParameter($pattern).'%')));
1110 1110
 			}
1111 1111
 		}
1112 1112
 
@@ -1120,8 +1120,8 @@  discard block
 block discarded – undo
1120 1120
 		$result = $query2->execute();
1121 1121
 		$matches = $result->fetchAll();
1122 1122
 		$result->closeCursor();
1123
-		$matches = array_map(function ($match) {
1124
-			return (int)$match['cardid'];
1123
+		$matches = array_map(function($match) {
1124
+			return (int) $match['cardid'];
1125 1125
 		}, $matches);
1126 1126
 
1127 1127
 		$query = $this->db->getQueryBuilder();
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
 
1135 1135
 		$result->closeCursor();
1136 1136
 
1137
-		return array_map(function ($array) {
1137
+		return array_map(function($array) {
1138 1138
 			$array['addressbookid'] = (int) $array['addressbookid'];
1139 1139
 			$modified = false;
1140 1140
 			$array['carddata'] = $this->readBlob($array['carddata'], $modified);
@@ -1181,7 +1181,7 @@  discard block
 block discarded – undo
1181 1181
 		$result->closeCursor();
1182 1182
 
1183 1183
 		if (!isset($uri['uri'])) {
1184
-			throw new \InvalidArgumentException('Card does not exists: ' . $id);
1184
+			throw new \InvalidArgumentException('Card does not exists: '.$id);
1185 1185
 		}
1186 1186
 
1187 1187
 		return $uri['uri'];
@@ -1206,7 +1206,7 @@  discard block
 block discarded – undo
1206 1206
 
1207 1207
 		if (is_array($contact)) {
1208 1208
 			$modified = false;
1209
-			$contact['etag'] = '"' . $contact['etag'] . '"';
1209
+			$contact['etag'] = '"'.$contact['etag'].'"';
1210 1210
 			$contact['carddata'] = $this->readBlob($contact['carddata'], $modified);
1211 1211
 			if ($modified) {
1212 1212
 				$contact['size'] = strlen($contact['carddata']);
@@ -1319,10 +1319,10 @@  discard block
 block discarded – undo
1319 1319
 		$result->closeCursor();
1320 1320
 
1321 1321
 		if (!isset($cardIds['id'])) {
1322
-			throw new \InvalidArgumentException('Card does not exists: ' . $uri);
1322
+			throw new \InvalidArgumentException('Card does not exists: '.$uri);
1323 1323
 		}
1324 1324
 
1325
-		return (int)$cardIds['id'];
1325
+		return (int) $cardIds['id'];
1326 1326
 	}
1327 1327
 
1328 1328
 	/**
@@ -1348,8 +1348,8 @@  discard block
 block discarded – undo
1348 1348
 	}
1349 1349
 
1350 1350
 	private function addOwnerPrincipal(&$addressbookInfo) {
1351
-		$ownerPrincipalKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal';
1352
-		$displaynameKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname';
1351
+		$ownerPrincipalKey = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal';
1352
+		$displaynameKey = '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD.'}owner-displayname';
1353 1353
 		if (isset($addressbookInfo[$ownerPrincipalKey])) {
1354 1354
 			$uri = $addressbookInfo[$ownerPrincipalKey];
1355 1355
 		} else {
Please login to merge, or discard this patch.