Passed
Push — master ( 7250f5...d60172 )
by Robin
16:16 queued 13s
created
lib/private/Files/Storage/DAV.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 				if (is_string($params['secure'])) {
118 118
 					$this->secure = ($params['secure'] === 'true');
119 119
 				} else {
120
-					$this->secure = (bool)$params['secure'];
120
+					$this->secure = (bool) $params['secure'];
121 121
 				}
122 122
 			} else {
123 123
 				$this->secure = false;
@@ -127,8 +127,8 @@  discard block
 block discarded – undo
127 127
 				$this->certManager = \OC::$server->getCertificateManager();
128 128
 			}
129 129
 			$this->root = $params['root'] ?? '/';
130
-			$this->root = '/' . ltrim($this->root, '/');
131
-			$this->root = rtrim($this->root, '/') . '/';
130
+			$this->root = '/'.ltrim($this->root, '/');
131
+			$this->root = rtrim($this->root, '/').'/';
132 132
 		} else {
133 133
 			throw new \Exception('Invalid webdav storage configuration');
134 134
 		}
@@ -170,14 +170,14 @@  discard block
 block discarded – undo
170 170
 		}
171 171
 
172 172
 		$lastRequestStart = 0;
173
-		$this->client->on('beforeRequest', function (RequestInterface $request) use (&$lastRequestStart) {
174
-			$this->logger->debug("sending dav " . $request->getMethod() .  " request to external storage: " . $request->getAbsoluteUrl(), ['app' => 'dav']);
173
+		$this->client->on('beforeRequest', function(RequestInterface $request) use (&$lastRequestStart) {
174
+			$this->logger->debug("sending dav ".$request->getMethod()." request to external storage: ".$request->getAbsoluteUrl(), ['app' => 'dav']);
175 175
 			$lastRequestStart = microtime(true);
176 176
 			$this->eventLogger->start('fs:storage:dav:request', "Sending dav request to external storage");
177 177
 		});
178
-		$this->client->on('afterRequest', function (RequestInterface $request) use (&$lastRequestStart) {
178
+		$this->client->on('afterRequest', function(RequestInterface $request) use (&$lastRequestStart) {
179 179
 			$elapsed = microtime(true) - $lastRequestStart;
180
-			$this->logger->debug("dav " . $request->getMethod() .  " request to external storage: " . $request->getAbsoluteUrl() . " took " . round($elapsed * 1000, 1) . "ms", ['app' => 'dav']);
180
+			$this->logger->debug("dav ".$request->getMethod()." request to external storage: ".$request->getAbsoluteUrl()." took ".round($elapsed * 1000, 1)."ms", ['app' => 'dav']);
181 181
 			$this->eventLogger->end('fs:storage:dav:request');
182 182
 		});
183 183
 	}
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 
192 192
 	/** {@inheritdoc} */
193 193
 	public function getId() {
194
-		return 'webdav::' . $this->user . '@' . $this->host . '/' . $this->root;
194
+		return 'webdav::'.$this->user.'@'.$this->host.'/'.$this->root;
195 195
 	}
196 196
 
197 197
 	/** {@inheritdoc} */
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 		if ($this->secure) {
201 201
 			$baseUri .= 's';
202 202
 		}
203
-		$baseUri .= '://' . $this->host . $this->root;
203
+		$baseUri .= '://'.$this->host.$this->root;
204 204
 		return $baseUri;
205 205
 	}
206 206
 
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 		$path = $this->cleanPath($path);
222 222
 		// FIXME: some WebDAV impl return 403 when trying to DELETE
223 223
 		// a non-empty folder
224
-		$result = $this->simpleResponse('DELETE', $path . '/', null, 204);
225
-		$this->statCache->clear($path . '/');
224
+		$result = $this->simpleResponse('DELETE', $path.'/', null, 204);
225
+		$this->statCache->clear($path.'/');
226 226
 		$this->statCache->remove($path);
227 227
 		return $result;
228 228
 	}
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 				$this->statCache->set($path, $response);
299 299
 			} catch (ClientHttpException $e) {
300 300
 				if ($e->getHttpStatus() === 404 || $e->getHttpStatus() === 405) {
301
-					$this->statCache->clear($path . '/');
301
+					$this->statCache->clear($path.'/');
302 302
 					$this->statCache->set($path, false);
303 303
 					return false;
304 304
 				}
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 		$this->init();
356 356
 		$path = $this->cleanPath($path);
357 357
 		$result = $this->simpleResponse('DELETE', $path, null, 204);
358
-		$this->statCache->clear($path . '/');
358
+		$this->statCache->clear($path.'/');
359 359
 		$this->statCache->remove($path);
360 360
 		return $result;
361 361
 	}
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 				try {
371 371
 					$response = $this->httpClientService
372 372
 						->newClient()
373
-						->get($this->createBaseUri() . $this->encodePath($path), [
373
+						->get($this->createBaseUri().$this->encodePath($path), [
374 374
 							'auth' => [$this->user, $this->password],
375 375
 							'stream' => true
376 376
 						]);
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 					if ($response->getStatusCode() === Http::STATUS_LOCKED) {
388 388
 						throw new \OCP\Lock\LockedException($path);
389 389
 					} else {
390
-						\OC::$server->get(LoggerInterface::class)->error('Guzzle get returned status code ' . $response->getStatusCode(), ['app' => 'webdav client']);
390
+						\OC::$server->get(LoggerInterface::class)->error('Guzzle get returned status code '.$response->getStatusCode(), ['app' => 'webdav client']);
391 391
 					}
392 392
 				}
393 393
 
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 					$tmpFile = $tempManager->getTemporaryFile($ext);
428 428
 				}
429 429
 				$handle = fopen($tmpFile, $mode);
430
-				return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) {
430
+				return CallbackWrapper::wrap($handle, null, null, function() use ($path, $tmpFile) {
431 431
 					$this->writeBack($tmpFile, $path);
432 432
 				});
433 433
 		}
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 				return FileInfo::SPACE_UNKNOWN;
452 452
 			}
453 453
 			if (isset($response['{DAV:}quota-available-bytes'])) {
454
-				return (int)$response['{DAV:}quota-available-bytes'];
454
+				return (int) $response['{DAV:}quota-available-bytes'];
455 455
 			} else {
456 456
 				return FileInfo::SPACE_UNKNOWN;
457 457
 			}
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 
528 528
 		$this->httpClientService
529 529
 			->newClient()
530
-			->put($this->createBaseUri() . $this->encodePath($target), [
530
+			->put($this->createBaseUri().$this->encodePath($target), [
531 531
 				'body' => $source,
532 532
 				'auth' => [$this->user, $this->password]
533 533
 			]);
@@ -544,18 +544,18 @@  discard block
 block discarded – undo
544 544
 			// overwrite directory ?
545 545
 			if ($this->is_dir($target)) {
546 546
 				// needs trailing slash in destination
547
-				$target = rtrim($target, '/') . '/';
547
+				$target = rtrim($target, '/').'/';
548 548
 			}
549 549
 			$this->client->request(
550 550
 				'MOVE',
551 551
 				$this->encodePath($source),
552 552
 				null,
553 553
 				[
554
-					'Destination' => $this->createBaseUri() . $this->encodePath($target),
554
+					'Destination' => $this->createBaseUri().$this->encodePath($target),
555 555
 				]
556 556
 			);
557
-			$this->statCache->clear($source . '/');
558
-			$this->statCache->clear($target . '/');
557
+			$this->statCache->clear($source.'/');
558
+			$this->statCache->clear($target.'/');
559 559
 			$this->statCache->set($source, false);
560 560
 			$this->statCache->set($target, true);
561 561
 			$this->removeCachedFile($source);
@@ -576,17 +576,17 @@  discard block
 block discarded – undo
576 576
 			// overwrite directory ?
577 577
 			if ($this->is_dir($target)) {
578 578
 				// needs trailing slash in destination
579
-				$target = rtrim($target, '/') . '/';
579
+				$target = rtrim($target, '/').'/';
580 580
 			}
581 581
 			$this->client->request(
582 582
 				'COPY',
583 583
 				$this->encodePath($source),
584 584
 				null,
585 585
 				[
586
-					'Destination' => $this->createBaseUri() . $this->encodePath($target),
586
+					'Destination' => $this->createBaseUri().$this->encodePath($target),
587 587
 				]
588 588
 			);
589
-			$this->statCache->clear($target . '/');
589
+			$this->statCache->clear($target.'/');
590 590
 			$this->statCache->set($target, true);
591 591
 			$this->removeCachedFile($target);
592 592
 			return true;
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
 			}
606 606
 			return [
607 607
 				'mtime' => isset($response['{DAV:}getlastmodified']) ? strtotime($response['{DAV:}getlastmodified']) : null,
608
-				'size' => (int)($response['{DAV:}getcontentlength'] ?? 0),
608
+				'size' => (int) ($response['{DAV:}getcontentlength'] ?? 0),
609 609
 			];
610 610
 		} catch (\Exception $e) {
611 611
 			$this->convertException($e, $path);
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
 			return $response['statusCode'] == $expected;
688 688
 		} catch (ClientHttpException $e) {
689 689
 			if ($e->getHttpStatus() === 404 && $method === 'DELETE') {
690
-				$this->statCache->clear($path . '/');
690
+				$this->statCache->clear($path.'/');
691 691
 				$this->statCache->set($path, false);
692 692
 				return false;
693 693
 			}
@@ -708,22 +708,22 @@  discard block
 block discarded – undo
708 708
 
709 709
 	/** {@inheritdoc} */
710 710
 	public function isUpdatable($path) {
711
-		return (bool)($this->getPermissions($path) & Constants::PERMISSION_UPDATE);
711
+		return (bool) ($this->getPermissions($path) & Constants::PERMISSION_UPDATE);
712 712
 	}
713 713
 
714 714
 	/** {@inheritdoc} */
715 715
 	public function isCreatable($path) {
716
-		return (bool)($this->getPermissions($path) & Constants::PERMISSION_CREATE);
716
+		return (bool) ($this->getPermissions($path) & Constants::PERMISSION_CREATE);
717 717
 	}
718 718
 
719 719
 	/** {@inheritdoc} */
720 720
 	public function isSharable($path) {
721
-		return (bool)($this->getPermissions($path) & Constants::PERMISSION_SHARE);
721
+		return (bool) ($this->getPermissions($path) & Constants::PERMISSION_SHARE);
722 722
 	}
723 723
 
724 724
 	/** {@inheritdoc} */
725 725
 	public function isDeletable($path) {
726
-		return (bool)($this->getPermissions($path) & Constants::PERMISSION_DELETE);
726
+		return (bool) ($this->getPermissions($path) & Constants::PERMISSION_DELETE);
727 727
 	}
728 728
 
729 729
 	/** {@inheritdoc} */
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 				if (($cachedData === false) || (!empty($etag) && ($cachedData['etag'] !== $etag))) {
814 814
 					return true;
815 815
 				} elseif (isset($response['{http://open-collaboration-services.org/ns}share-permissions'])) {
816
-					$sharePermissions = (int)$response['{http://open-collaboration-services.org/ns}share-permissions'];
816
+					$sharePermissions = (int) $response['{http://open-collaboration-services.org/ns}share-permissions'];
817 817
 					return $sharePermissions !== $cachedData['permissions'];
818 818
 				} elseif (isset($response['{http://owncloud.org/ns}permissions'])) {
819 819
 					$permissions = $this->parsePermissions($response['{http://owncloud.org/ns}permissions']);
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
 			if ($e->getHttpStatus() === 405) {
833 833
 				if ($path === '') {
834 834
 					// if root is gone it means the storage is not available
835
-					throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage());
835
+					throw new StorageNotAvailableException(get_class($e).': '.$e->getMessage());
836 836
 				}
837 837
 				return false;
838 838
 			}
@@ -867,22 +867,22 @@  discard block
 block discarded – undo
867 867
 			}
868 868
 			if ($e->getHttpStatus() === Http::STATUS_UNAUTHORIZED) {
869 869
 				// either password was changed or was invalid all along
870
-				throw new StorageInvalidException(get_class($e) . ': ' . $e->getMessage());
870
+				throw new StorageInvalidException(get_class($e).': '.$e->getMessage());
871 871
 			} elseif ($e->getHttpStatus() === Http::STATUS_METHOD_NOT_ALLOWED) {
872 872
 				// ignore exception for MethodNotAllowed, false will be returned
873 873
 				return;
874 874
 			} elseif ($e->getHttpStatus() === Http::STATUS_FORBIDDEN) {
875 875
 				// The operation is forbidden. Fail somewhat gracefully
876
-				throw new ForbiddenException(get_class($e) . ':' . $e->getMessage(), false);
876
+				throw new ForbiddenException(get_class($e).':'.$e->getMessage(), false);
877 877
 			}
878
-			throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage());
878
+			throw new StorageNotAvailableException(get_class($e).': '.$e->getMessage());
879 879
 		} elseif ($e instanceof ClientException) {
880 880
 			// connection timeout or refused, server could be temporarily down
881
-			throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage());
881
+			throw new StorageNotAvailableException(get_class($e).': '.$e->getMessage());
882 882
 		} elseif ($e instanceof \InvalidArgumentException) {
883 883
 			// parse error because the server returned HTML instead of XML,
884 884
 			// possibly temporarily down
885
-			throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage());
885
+			throw new StorageNotAvailableException(get_class($e).': '.$e->getMessage());
886 886
 		} elseif (($e instanceof StorageNotAvailableException) || ($e instanceof StorageInvalidException)) {
887 887
 			// rethrow
888 888
 			throw $e;
Please login to merge, or discard this patch.