Passed
Push — master ( 90401e...63cb31 )
by Roeland
20:41 queued 20s
created
lib/private/Files/Cache/QuerySearchHelper.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 */
75 75
 	public function shouldJoinTags(ISearchOperator $operator) {
76 76
 		if ($operator instanceof ISearchBinaryOperator) {
77
-			return array_reduce($operator->getArguments(), function ($shouldJoin, ISearchOperator $operator) {
77
+			return array_reduce($operator->getArguments(), function($shouldJoin, ISearchOperator $operator) {
78 78
 				return $shouldJoin || $this->shouldJoinTags($operator);
79 79
 			}, false);
80 80
 		} else if ($operator instanceof ISearchComparison) {
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 * @param ISearchOperator $operator
89 89
 	 */
90 90
 	public function searchOperatorArrayToDBExprArray(IQueryBuilder $builder, array $operators) {
91
-		return array_filter(array_map(function ($operator) use ($builder) {
91
+		return array_filter(array_map(function($operator) use ($builder) {
92 92
 			return $this->searchOperatorToDBExpr($builder, $operator);
93 93
 		}, $operators));
94 94
 	}
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
 				case ISearchBinaryOperator::OPERATOR_OR:
114 114
 					return call_user_func_array([$expr, 'orX'], $this->searchOperatorArrayToDBExprArray($builder, $operator->getArguments()));
115 115
 				default:
116
-					throw new \InvalidArgumentException('Invalid operator type: ' . $operator->getType());
116
+					throw new \InvalidArgumentException('Invalid operator type: '.$operator->getType());
117 117
 			}
118 118
 		} else if ($operator instanceof ISearchComparison) {
119 119
 			return $this->searchComparisonToDBExpr($builder, $operator, self::$searchOperatorMap);
120 120
 		} else {
121
-			throw new \InvalidArgumentException('Invalid operator type: ' . get_class($operator));
121
+			throw new \InvalidArgumentException('Invalid operator type: '.get_class($operator));
122 122
 		}
123 123
 	}
124 124
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 			$queryOperator = $operatorMap[$type];
131 131
 			return $builder->expr()->$queryOperator($field, $this->getParameterForValue($builder, $value));
132 132
 		} else {
133
-			throw new \InvalidArgumentException('Invalid operator type: ' . $comparison->getType());
133
+			throw new \InvalidArgumentException('Invalid operator type: '.$comparison->getType());
134 134
 		}
135 135
 	}
136 136
 
@@ -140,18 +140,18 @@  discard block
 block discarded – undo
140 140
 		$type = $operator->getType();
141 141
 		if ($field === 'mimetype') {
142 142
 			if ($operator->getType() === ISearchComparison::COMPARE_EQUAL) {
143
-				$value = (int)$this->mimetypeLoader->getId($value);
143
+				$value = (int) $this->mimetypeLoader->getId($value);
144 144
 			} else if ($operator->getType() === ISearchComparison::COMPARE_LIKE) {
145 145
 				// transform "mimetype='foo/%'" to "mimepart='foo'"
146 146
 				if (preg_match('|(.+)/%|', $value, $matches)) {
147 147
 					$field = 'mimepart';
148
-					$value = (int)$this->mimetypeLoader->getId($matches[1]);
148
+					$value = (int) $this->mimetypeLoader->getId($matches[1]);
149 149
 					$type = ISearchComparison::COMPARE_EQUAL;
150 150
 				} else if (strpos($value, '%') !== false) {
151
-					throw new \InvalidArgumentException('Unsupported query value for mimetype: ' . $value . ', only values in the format "mime/type" or "mime/%" are supported');
151
+					throw new \InvalidArgumentException('Unsupported query value for mimetype: '.$value.', only values in the format "mime/type" or "mime/%" are supported');
152 152
 				} else {
153 153
 					$field = 'mimetype';
154
-					$value = (int)$this->mimetypeLoader->getId($value);
154
+					$value = (int) $this->mimetypeLoader->getId($value);
155 155
 					$type = ISearchComparison::COMPARE_EQUAL;
156 156
 				}
157 157
 			}
@@ -185,14 +185,14 @@  discard block
 block discarded – undo
185 185
 		];
186 186
 
187 187
 		if (!isset($types[$operator->getField()])) {
188
-			throw new \InvalidArgumentException('Unsupported comparison field ' . $operator->getField());
188
+			throw new \InvalidArgumentException('Unsupported comparison field '.$operator->getField());
189 189
 		}
190 190
 		$type = $types[$operator->getField()];
191 191
 		if (gettype($operator->getValue()) !== $type) {
192
-			throw new \InvalidArgumentException('Invalid type for field ' . $operator->getField());
192
+			throw new \InvalidArgumentException('Invalid type for field '.$operator->getField());
193 193
 		}
194 194
 		if (!in_array($operator->getType(), $comparisons[$operator->getField()])) {
195
-			throw new \InvalidArgumentException('Unsupported comparison for field  ' . $operator->getField() . ': ' . $operator->getType());
195
+			throw new \InvalidArgumentException('Unsupported comparison for field  '.$operator->getField().': '.$operator->getType());
196 196
 		}
197 197
 	}
198 198
 
Please login to merge, or discard this patch.
lib/private/Files/Node/Folder.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		if (!$this->isValidPath($path)) {
57 57
 			throw new NotPermittedException('Invalid path');
58 58
 		}
59
-		return $this->path . $this->normalizePath($path);
59
+		return $this->path.$this->normalizePath($path);
60 60
 	}
61 61
 
62 62
 	/**
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		}
70 70
 		if ($path === $this->path) {
71 71
 			return '/';
72
-		} else if (strpos($path, $this->path . '/') !== 0) {
72
+		} else if (strpos($path, $this->path.'/') !== 0) {
73 73
 			return null;
74 74
 		} else {
75 75
 			$path = substr($path, strlen($this->path));
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	 * @return bool
85 85
 	 */
86 86
 	public function isSubNode($node) {
87
-		return strpos($node->getPath(), $this->path . '/') === 0;
87
+		return strpos($node->getPath(), $this->path.'/') === 0;
88 88
 	}
89 89
 
90 90
 	/**
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	public function getDirectoryListing() {
97 97
 		$folderContent = $this->view->getDirectoryContent($this->path);
98 98
 
99
-		return array_map(function (FileInfo $info) {
99
+		return array_map(function(FileInfo $info) {
100 100
 			if ($info->getMimetype() === 'httpd/unix-directory') {
101 101
 				return new Folder($this->root, $this->view, $info->getPath(), $info);
102 102
 			} else {
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 			$fullPath = $this->getFullPath($path);
158 158
 			$nonExisting = new NonExistingFolder($this->root, $this->view, $fullPath);
159 159
 			$this->sendHooks(['preWrite', 'preCreate'], [$nonExisting]);
160
-			if(!$this->view->mkdir($fullPath)) {
160
+			if (!$this->view->mkdir($fullPath)) {
161 161
 				throw new NotPermittedException('Could not create folder');
162 162
 			}
163 163
 			$node = new Folder($this->root, $this->view, $fullPath);
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 	 */
197 197
 	public function search($query) {
198 198
 		if (is_string($query)) {
199
-			return $this->searchCommon('search', array('%' . $query . '%'));
199
+			return $this->searchCommon('search', array('%'.$query.'%'));
200 200
 		} else {
201 201
 			return $this->searchCommon('searchQuery', array($query));
202 202
 		}
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 	 * @return \OC\Files\Node\Node[]
230 230
 	 */
231 231
 	private function searchCommon($method, $args) {
232
-		$limitToHome = ($method === 'searchQuery')? $args[0]->limitToHome(): false;
232
+		$limitToHome = ($method === 'searchQuery') ? $args[0]->limitToHome() : false;
233 233
 		if ($limitToHome && count(explode('/', $this->path)) !== 3) {
234 234
 			throw new \InvalidArgumentException('searching by owner is only allows on the users home folder');
235 235
 		}
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 		$internalPath = $mount->getInternalPath($this->path);
242 242
 		$internalPath = rtrim($internalPath, '/');
243 243
 		if ($internalPath !== '') {
244
-			$internalPath = $internalPath . '/';
244
+			$internalPath = $internalPath.'/';
245 245
 		}
246 246
 		$internalRootLength = strlen($internalPath);
247 247
 
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 				$result['internalPath'] = $result['path'];
254 254
 				$result['path'] = substr($result['path'], $internalRootLength);
255 255
 				$result['storage'] = $storage;
256
-				$files[] = new \OC\Files\FileInfo($this->path . '/' . $result['path'], $storage, $result['internalPath'], $result, $mount);
256
+				$files[] = new \OC\Files\FileInfo($this->path.'/'.$result['path'], $storage, $result['internalPath'], $result, $mount);
257 257
 			}
258 258
 		}
259 259
 
@@ -268,16 +268,16 @@  discard block
 block discarded – undo
268 268
 					$results = call_user_func_array([$cache, $method], $args);
269 269
 					foreach ($results as $result) {
270 270
 						$result['internalPath'] = $result['path'];
271
-						$result['path'] = $relativeMountPoint . $result['path'];
271
+						$result['path'] = $relativeMountPoint.$result['path'];
272 272
 						$result['storage'] = $storage;
273
-						$files[] = new \OC\Files\FileInfo($this->path . '/' . $result['path'], $storage,
273
+						$files[] = new \OC\Files\FileInfo($this->path.'/'.$result['path'], $storage,
274 274
 							$result['internalPath'], $result, $mount);
275 275
 					}
276 276
 				}
277 277
 			}
278 278
 		}
279 279
 
280
-		return array_map(function (FileInfo $file) {
280
+		return array_map(function(FileInfo $file) {
281 281
 			return $this->createNode($file->getPath(), $file);
282 282
 		}, $files);
283 283
 	}
@@ -293,16 +293,16 @@  discard block
 block discarded – undo
293 293
 		} else {
294 294
 			$user = null;
295 295
 		}
296
-		$mountsContainingFile = $mountCache->getMountsForFileId((int)$id, $user);
296
+		$mountsContainingFile = $mountCache->getMountsForFileId((int) $id, $user);
297 297
 		$mounts = $this->root->getMountsIn($this->path);
298 298
 		$mounts[] = $this->root->getMount($this->path);
299 299
 		/** @var IMountPoint[] $folderMounts */
300
-		$folderMounts = array_combine(array_map(function (IMountPoint $mountPoint) {
300
+		$folderMounts = array_combine(array_map(function(IMountPoint $mountPoint) {
301 301
 			return $mountPoint->getMountPoint();
302 302
 		}, $mounts), $mounts);
303 303
 
304 304
 		/** @var ICachedMountInfo[] $mountsContainingFile */
305
-		$mountsContainingFile = array_values(array_filter($mountsContainingFile, function (ICachedMountInfo $cachedMountInfo) use ($folderMounts) {
305
+		$mountsContainingFile = array_values(array_filter($mountsContainingFile, function(ICachedMountInfo $cachedMountInfo) use ($folderMounts) {
306 306
 			return isset($folderMounts[$cachedMountInfo->getMountPoint()]);
307 307
 		}));
308 308
 
@@ -313,18 +313,18 @@  discard block
 block discarded – undo
313 313
 			return [];
314 314
 		}
315 315
 
316
-		$nodes = array_map(function (ICachedMountInfo $cachedMountInfo) use ($folderMounts, $id) {
316
+		$nodes = array_map(function(ICachedMountInfo $cachedMountInfo) use ($folderMounts, $id) {
317 317
 			$mount = $folderMounts[$cachedMountInfo->getMountPoint()];
318
-			$cacheEntry = $mount->getStorage()->getCache()->get((int)$id);
318
+			$cacheEntry = $mount->getStorage()->getCache()->get((int) $id);
319 319
 			if (!$cacheEntry) {
320 320
 				return null;
321 321
 			}
322 322
 
323 323
 			// cache jails will hide the "true" internal path
324
-			$internalPath = ltrim($cachedMountInfo->getRootInternalPath() . '/' . $cacheEntry->getPath(), '/');
324
+			$internalPath = ltrim($cachedMountInfo->getRootInternalPath().'/'.$cacheEntry->getPath(), '/');
325 325
 			$pathRelativeToMount = substr($internalPath, strlen($cachedMountInfo->getRootInternalPath()));
326 326
 			$pathRelativeToMount = ltrim($pathRelativeToMount, '/');
327
-			$absolutePath = rtrim($cachedMountInfo->getMountPoint() . $pathRelativeToMount, '/');
327
+			$absolutePath = rtrim($cachedMountInfo->getMountPoint().$pathRelativeToMount, '/');
328 328
 			return $this->root->createNode($absolutePath, new \OC\Files\FileInfo(
329 329
 				$absolutePath, $mount->getStorage(), $cacheEntry->getPath(), $cacheEntry, $mount,
330 330
 				\OC::$server->getUserManager()->get($mount->getStorage()->getOwner($pathRelativeToMount))
@@ -333,14 +333,14 @@  discard block
 block discarded – undo
333 333
 
334 334
 		$nodes = array_filter($nodes);
335 335
 
336
-		return array_filter($nodes, function (Node $node) {
336
+		return array_filter($nodes, function(Node $node) {
337 337
 			return $this->getRelativePath($node->getPath());
338 338
 		});
339 339
 	}
340 340
 
341 341
 	protected function getAppDataDirectoryName(): string {
342 342
 		$instanceId = \OC::$server->getConfig()->getSystemValueString('instanceid');
343
-		return 'appdata_' . $instanceId;
343
+		return 'appdata_'.$instanceId;
344 344
 	}
345 345
 
346 346
 	/**
@@ -362,8 +362,8 @@  discard block
 block discarded – undo
362 362
 			return [];
363 363
 		}
364 364
 
365
-		$absolutePath = '/' . ltrim($cacheEntry->getPath(), '/');
366
-		$currentPath = rtrim($this->path, '/') . '/';
365
+		$absolutePath = '/'.ltrim($cacheEntry->getPath(), '/');
366
+		$currentPath = rtrim($this->path, '/').'/';
367 367
 
368 368
 		if (strpos($absolutePath, $currentPath) !== 0) {
369 369
 			return [];
@@ -418,10 +418,10 @@  discard block
 block discarded – undo
418 418
 		$mounts = $this->root->getMountsIn($this->path);
419 419
 		$mounts[] = $this->getMountPoint();
420 420
 
421
-		$mounts = array_filter($mounts, function (IMountPoint $mount) {
421
+		$mounts = array_filter($mounts, function(IMountPoint $mount) {
422 422
 			return $mount->getStorage();
423 423
 		});
424
-		$storageIds = array_map(function (IMountPoint $mount) {
424
+		$storageIds = array_map(function(IMountPoint $mount) {
425 425
 			return $mount->getStorage()->getCache()->getNumericStorageId();
426 426
 		}, $mounts);
427 427
 		/** @var IMountPoint[] $mountMap */
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 	}
477 477
 
478 478
 	private function recentParse($result, $mountMap, $mimetypeLoader) {
479
-		$files = array_filter(array_map(function (array $entry) use ($mountMap, $mimetypeLoader) {
479
+		$files = array_filter(array_map(function(array $entry) use ($mountMap, $mimetypeLoader) {
480 480
 			$mount = $mountMap[$entry['storage']];
481 481
 			$entry['internalPath'] = $entry['path'];
482 482
 			$entry['mimetype'] = $mimetypeLoader->getMimetypeById($entry['mimetype']);
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 			return $this->root->createNode($fileInfo->getPath(), $fileInfo);
490 490
 		}, $result));
491 491
 
492
-		return array_values(array_filter($files, function (Node $node) {
492
+		return array_values(array_filter($files, function(Node $node) {
493 493
 			$cacheEntry = $node->getMountPoint()->getStorage()->getCache()->get($node->getId());
494 494
 			if (!$cacheEntry) {
495 495
 				return false;
@@ -511,13 +511,13 @@  discard block
 block discarded – undo
511 511
 			$rootLength = strlen($jailRoot) + 1;
512 512
 			if ($path === $jailRoot) {
513 513
 				return $mount->getMountPoint();
514
-			} else if (substr($path, 0, $rootLength) === $jailRoot . '/') {
515
-				return $mount->getMountPoint() . substr($path, $rootLength);
514
+			} else if (substr($path, 0, $rootLength) === $jailRoot.'/') {
515
+				return $mount->getMountPoint().substr($path, $rootLength);
516 516
 			} else {
517 517
 				return null;
518 518
 			}
519 519
 		} else {
520
-			return $mount->getMountPoint() . $path;
520
+			return $mount->getMountPoint().$path;
521 521
 		}
522 522
 	}
523 523
 }
Please login to merge, or discard this patch.
apps/dav/lib/Files/FileSearchBackend.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 		$results = $folder->search($query);
159 159
 
160 160
 		/** @var SearchResult[] $nodes */
161
-		$nodes = array_map(function (Node $node) {
161
+		$nodes = array_map(function(Node $node) {
162 162
 			if ($node instanceof Folder) {
163 163
 				$davNode = new \OCA\DAV\Connector\Sabre\Directory($this->view, $node, $this->tree, $this->shareManager);
164 164
 			} else {
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 
172 172
 		if (!$query->limitToHome()) {
173 173
 			// Sort again, since the result from multiple storages is appended and not sorted
174
-			usort($nodes, function (SearchResult $a, SearchResult $b) use ($search) {
174
+			usort($nodes, function(SearchResult $a, SearchResult $b) use ($search) {
175 175
 				return $this->sort($a, $b, $search->orderBy);
176 176
 			});
177 177
 		}
@@ -261,8 +261,8 @@  discard block
 block discarded – undo
261 261
 	 * @return string
262 262
 	 */
263 263
 	private function getHrefForNode(Node $node) {
264
-		$base = '/files/' . $this->user->getUID();
265
-		return $base . $this->view->getRelativePath($node->getPath());
264
+		$base = '/files/'.$this->user->getUID();
265
+		return $base.$this->view->getRelativePath($node->getPath());
266 266
 	}
267 267
 
268 268
 	/**
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 
287 287
 		return new SearchQuery(
288 288
 			$this->transformSearchOperation($query->where),
289
-			(int)$limit->maxResults,
289
+			(int) $limit->maxResults,
290 290
 			0,
291 291
 			$orders,
292 292
 			$this->user,
@@ -321,19 +321,19 @@  discard block
 block discarded – undo
321 321
 			case Operator::OPERATION_LESS_THAN:
322 322
 			case Operator::OPERATION_IS_LIKE:
323 323
 				if (count($operator->arguments) !== 2) {
324
-					throw new \InvalidArgumentException('Invalid number of arguments for ' . $trimmedType . ' operation');
324
+					throw new \InvalidArgumentException('Invalid number of arguments for '.$trimmedType.' operation');
325 325
 				}
326 326
 				if (!($operator->arguments[0] instanceof SearchPropertyDefinition)) {
327
-					throw new \InvalidArgumentException('Invalid argument 1 for ' . $trimmedType . ' operation, expected property');
327
+					throw new \InvalidArgumentException('Invalid argument 1 for '.$trimmedType.' operation, expected property');
328 328
 				}
329 329
 				if (!($operator->arguments[1] instanceof Literal)) {
330
-					throw new \InvalidArgumentException('Invalid argument 2 for ' . $trimmedType . ' operation, expected literal');
330
+					throw new \InvalidArgumentException('Invalid argument 2 for '.$trimmedType.' operation, expected literal');
331 331
 				}
332 332
 				return new SearchComparison($trimmedType, $this->mapPropertyNameToColumn($operator->arguments[0]), $this->castValue($operator->arguments[0], $operator->arguments[1]->value));
333 333
 			case Operator::OPERATION_IS_COLLECTION:
334 334
 				return new SearchComparison('eq', 'mimetype', ICacheEntry::DIRECTORY_MIMETYPE);
335 335
 			default:
336
-				throw new \InvalidArgumentException('Unsupported operation ' . $trimmedType . ' (' . $operator->type . ')');
336
+				throw new \InvalidArgumentException('Unsupported operation '.$trimmedType.' ('.$operator->type.')');
337 337
 		}
338 338
 	}
339 339
 
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 			case FilesPlugin::INTERNAL_FILEID_PROPERTYNAME:
359 359
 				return 'fileid';
360 360
 			default:
361
-				throw new \InvalidArgumentException('Unsupported property for search or order: ' . $property->name);
361
+				throw new \InvalidArgumentException('Unsupported property for search or order: '.$property->name);
362 362
 		}
363 363
 	}
364 364
 
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 							} else {
416 416
 								throw new \InvalidArgumentException("searching by '$propertyName' is only allowed with a literal value");
417 417
 							}
418
-						} else{
418
+						} else {
419 419
 							throw new \InvalidArgumentException("searching by '$propertyName' is not allowed inside a '{DAV:}or' or '{DAV:}not'");
420 420
 						}
421 421
 					} else {
Please login to merge, or discard this patch.