Passed
Push — master ( 237c70...dcf686 )
by Morris
14:09
created
lib/private/Files/Cache/Cache.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -164,21 +164,21 @@  discard block
 block discarded – undo
164 164
 	 */
165 165
 	public static function cacheEntryFromData($data, IMimeTypeLoader $mimetypeLoader) {
166 166
 		//fix types
167
-		$data['fileid'] = (int)$data['fileid'];
168
-		$data['parent'] = (int)$data['parent'];
167
+		$data['fileid'] = (int) $data['fileid'];
168
+		$data['parent'] = (int) $data['parent'];
169 169
 		$data['size'] = 0 + $data['size'];
170
-		$data['mtime'] = (int)$data['mtime'];
171
-		$data['storage_mtime'] = (int)$data['storage_mtime'];
172
-		$data['encryptedVersion'] = (int)$data['encrypted'];
173
-		$data['encrypted'] = (bool)$data['encrypted'];
170
+		$data['mtime'] = (int) $data['mtime'];
171
+		$data['storage_mtime'] = (int) $data['storage_mtime'];
172
+		$data['encryptedVersion'] = (int) $data['encrypted'];
173
+		$data['encrypted'] = (bool) $data['encrypted'];
174 174
 		$data['storage_id'] = $data['storage'];
175
-		$data['storage'] = (int)$data['storage'];
175
+		$data['storage'] = (int) $data['storage'];
176 176
 		$data['mimetype'] = $mimetypeLoader->getMimetypeById($data['mimetype']);
177 177
 		$data['mimepart'] = $mimetypeLoader->getMimetypeById($data['mimepart']);
178 178
 		if ($data['storage_mtime'] == 0) {
179 179
 			$data['storage_mtime'] = $data['mtime'];
180 180
 		}
181
-		$data['permissions'] = (int)$data['permissions'];
181
+		$data['permissions'] = (int) $data['permissions'];
182 182
 		return new CacheEntry($data);
183 183
 	}
184 184
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 					FROM `*PREFIX*filecache` WHERE `parent` = ? ORDER BY `name` ASC';
207 207
 			$result = $this->connection->executeQuery($sql, [$fileId]);
208 208
 			$files = $result->fetchAll();
209
-			return array_map(function (array $data) {
209
+			return array_map(function(array $data) {
210 210
 				return self::cacheEntryFromData($data, $this->mimetypeLoader);
211 211
 			}, $files);
212 212
 		}
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 		$queryParts[] = '`storage`';
268 268
 		$params[] = $this->getNumericStorageId();
269 269
 
270
-		$queryParts = array_map(function ($item) {
270
+		$queryParts = array_map(function($item) {
271 271
 			return trim($item, "`");
272 272
 		}, $queryParts);
273 273
 		$values = array_combine($queryParts, $params);
@@ -281,9 +281,9 @@  discard block
 block discarded – undo
281 281
 			}
282 282
 
283 283
 			if ($builder->execute()) {
284
-				return (int)$this->connection->lastInsertId('*PREFIX*filecache');
284
+				return (int) $this->connection->lastInsertId('*PREFIX*filecache');
285 285
 			}
286
-		} catch(UniqueConstraintViolationException $e) {
286
+		} catch (UniqueConstraintViolationException $e) {
287 287
 			// entry exists already
288 288
 		}
289 289
 
@@ -322,10 +322,10 @@  discard block
 block discarded – undo
322 322
 
323 323
 		// don't update if the data we try to set is the same as the one in the record
324 324
 		// some databases (Postgres) don't like superfluous updates
325
-		$sql = 'UPDATE `*PREFIX*filecache` SET ' . implode(' = ?, ', $queryParts) . '=? ' .
326
-			'WHERE (' .
327
-			implode(' <> ? OR ', $queryParts) . ' <> ? OR ' .
328
-			implode(' IS NULL OR ', $queryParts) . ' IS NULL' .
325
+		$sql = 'UPDATE `*PREFIX*filecache` SET '.implode(' = ?, ', $queryParts).'=? '.
326
+			'WHERE ('.
327
+			implode(' <> ? OR ', $queryParts).' <> ? OR '.
328
+			implode(' IS NULL OR ', $queryParts).' IS NULL'.
329 329
 			') AND `fileid` = ? ';
330 330
 		$this->connection->executeQuery($sql, $params);
331 331
 
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 					}
377 377
 				}
378 378
 				$params[] = $value;
379
-				$queryParts[] = '`' . $name . '`';
379
+				$queryParts[] = '`'.$name.'`';
380 380
 			}
381 381
 		}
382 382
 		return array($queryParts, $params);
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 			return -1;
419 419
 		} else {
420 420
 			$parent = $this->getParentPath($file);
421
-			return (int)$this->getId($parent);
421
+			return (int) $this->getId($parent);
422 422
 		}
423 423
 	}
424 424
 
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 	 */
465 465
 	private function getSubFolders($entry) {
466 466
 		$children = $this->getFolderContentsById($entry['fileid']);
467
-		return array_filter($children, function ($child) {
467
+		return array_filter($children, function($child) {
468 468
 			return $child['mimetype'] === 'httpd/unix-directory';
469 469
 		});
470 470
 	}
@@ -528,10 +528,10 @@  discard block
 block discarded – undo
528 528
 			list($targetStorageId, $targetPath) = $this->getMoveInfo($targetPath);
529 529
 
530 530
 			if (is_null($sourceStorageId) || $sourceStorageId === false) {
531
-				throw new \Exception('Invalid source storage id: ' . $sourceStorageId);
531
+				throw new \Exception('Invalid source storage id: '.$sourceStorageId);
532 532
 			}
533 533
 			if (is_null($targetStorageId) || $targetStorageId === false) {
534
-				throw new \Exception('Invalid target storage id: ' . $targetStorageId);
534
+				throw new \Exception('Invalid target storage id: '.$targetStorageId);
535 535
 			}
536 536
 
537 537
 			$this->connection->beginTransaction();
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
 					->set('path_hash', $fun->md5($newPathFunction))
551 551
 					->set('path', $newPathFunction)
552 552
 					->where($query->expr()->eq('storage', $query->createNamedParameter($sourceStorageId, IQueryBuilder::PARAM_INT)))
553
-					->andWhere($query->expr()->like('path', $query->createNamedParameter($this->connection->escapeLikeParameter($sourcePath) . '/%')));
553
+					->andWhere($query->expr()->like('path', $query->createNamedParameter($this->connection->escapeLikeParameter($sourcePath).'/%')));
554 554
 
555 555
 				try {
556 556
 					$query->execute();
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
 		$sql = 'SELECT `size` FROM `*PREFIX*filecache` WHERE `storage` = ? AND `path_hash` = ?';
600 600
 		$result = $this->connection->executeQuery($sql, array($this->getNumericStorageId(), $pathHash));
601 601
 		if ($row = $result->fetch()) {
602
-			if ((int)$row['size'] === -1) {
602
+			if ((int) $row['size'] === -1) {
603 603
 				return self::SHALLOW;
604 604
 			} else {
605 605
 				return self::COMPLETE;
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
 	private function searchResultToCacheEntries(Statement $result) {
649 649
 		$files = $result->fetchAll();
650 650
 
651
-		return array_map(function (array $data) {
651
+		return array_map(function(array $data) {
652 652
 			return self::cacheEntryFromData($data, $this->mimetypeLoader);
653 653
 		}, $files);
654 654
 	}
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 			$where = '`mimepart` = ?';
668 668
 		}
669 669
 		$sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `storage_mtime`, `mtime`, `encrypted`, `etag`, `permissions`, `checksum`
670
-				FROM `*PREFIX*filecache` WHERE ' . $where . ' AND `storage` = ?';
670
+				FROM `*PREFIX*filecache` WHERE ' . $where.' AND `storage` = ?';
671 671
 		$mimetype = $this->mimetypeLoader->getId($mimetype);
672 672
 		$result = $this->connection->executeQuery($sql, array($mimetype, $this->getNumericStorageId()));
673 673
 
@@ -718,20 +718,20 @@  discard block
 block discarded – undo
718 718
 	 * @return ICacheEntry[] file data
719 719
 	 */
720 720
 	public function searchByTag($tag, $userId) {
721
-		$sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, ' .
722
-			'`mimetype`, `mimepart`, `size`, `mtime`, `storage_mtime`, ' .
723
-			'`encrypted`, `etag`, `permissions`, `checksum` ' .
724
-			'FROM `*PREFIX*filecache` `file`, ' .
725
-			'`*PREFIX*vcategory_to_object` `tagmap`, ' .
726
-			'`*PREFIX*vcategory` `tag` ' .
721
+		$sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, '.
722
+			'`mimetype`, `mimepart`, `size`, `mtime`, `storage_mtime`, '.
723
+			'`encrypted`, `etag`, `permissions`, `checksum` '.
724
+			'FROM `*PREFIX*filecache` `file`, '.
725
+			'`*PREFIX*vcategory_to_object` `tagmap`, '.
726
+			'`*PREFIX*vcategory` `tag` '.
727 727
 			// JOIN filecache to vcategory_to_object
728
-			'WHERE `file`.`fileid` = `tagmap`.`objid` ' .
728
+			'WHERE `file`.`fileid` = `tagmap`.`objid` '.
729 729
 			// JOIN vcategory_to_object to vcategory
730
-			'AND `tagmap`.`type` = `tag`.`type` ' .
731
-			'AND `tagmap`.`categoryid` = `tag`.`id` ' .
730
+			'AND `tagmap`.`type` = `tag`.`type` '.
731
+			'AND `tagmap`.`categoryid` = `tag`.`id` '.
732 732
 			// conditions
733
-			'AND `file`.`storage` = ? ' .
734
-			'AND `tag`.`type` = \'files\' ' .
733
+			'AND `file`.`storage` = ? '.
734
+			'AND `tag`.`type` = \'files\' '.
735 735
 			'AND `tag`.`uid` = ? ';
736 736
 		if (is_int($tag)) {
737 737
 			$sql .= 'AND `tag`.`id` = ? ';
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
 
750 750
 		$files = $result->fetchAll();
751 751
 
752
-		return array_map(function (array $data) {
752
+		return array_map(function(array $data) {
753 753
 			return self::cacheEntryFromData($data, $this->mimetypeLoader);
754 754
 		}, $files);
755 755
 	}
@@ -785,8 +785,8 @@  discard block
 block discarded – undo
785 785
 		}
786 786
 		if (isset($entry['mimetype']) && $entry['mimetype'] === 'httpd/unix-directory') {
787 787
 			$id = $entry['fileid'];
788
-			$sql = 'SELECT SUM(`size`) AS f1, MIN(`size`) AS f2 ' .
789
-				'FROM `*PREFIX*filecache` ' .
788
+			$sql = 'SELECT SUM(`size`) AS f1, MIN(`size`) AS f2 '.
789
+				'FROM `*PREFIX*filecache` '.
790 790
 				'WHERE `parent` = ? AND `storage` = ?';
791 791
 			$result = $this->connection->executeQuery($sql, array($id, $this->getNumericStorageId()));
792 792
 			if ($row = $result->fetch()) {
Please login to merge, or discard this patch.