@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | ->from('authtoken') |
| 118 | 118 | ->executeQuery() |
| 119 | 119 | ->fetchAssociative(); |
| 120 | - return (int)$result['count']; |
|
| 120 | + return (int) $result['count']; |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | public function testInvalidate(): void { |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | $result = $qb->executeQuery(); |
| 242 | 242 | $id = $result->fetchAssociative()['id']; |
| 243 | 243 | |
| 244 | - $token = $this->mapper->getTokenById((int)$id); |
|
| 244 | + $token = $this->mapper->getTokenById((int) $id); |
|
| 245 | 245 | $this->assertEquals('user1', $token->getUID()); |
| 246 | 246 | } |
| 247 | 247 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | $this->config->expects($this->any()) |
| 102 | 102 | ->method('getAppValue') |
| 103 | 103 | ->willReturnCallback( |
| 104 | - function ($appName, $key, $default) use ($shareeEnumeration) { |
|
| 104 | + function($appName, $key, $default) use ($shareeEnumeration) { |
|
| 105 | 105 | if ($appName === 'core' && $key === 'shareapi_allow_share_dialog_user_enumeration') { |
| 106 | 106 | return $shareeEnumeration ? 'yes' : 'no'; |
| 107 | 107 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | $this->contactsManager->expects($this->any()) |
| 121 | 121 | ->method('search') |
| 122 | - ->willReturnCallback(function ($search, $searchAttributes) use ($searchTerm, $contacts) { |
|
| 122 | + ->willReturnCallback(function($search, $searchAttributes) use ($searchTerm, $contacts) { |
|
| 123 | 123 | if ($search === $searchTerm) { |
| 124 | 124 | return $contacts; |
| 125 | 125 | } |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | true, |
| 152 | 152 | ], |
| 153 | 153 | // data set 3 |
| 154 | - [ // no valid email address |
|
| 154 | + [// no valid email address |
|
| 155 | 155 | 'test@remote', |
| 156 | 156 | [], |
| 157 | 157 | true, |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | $this->config->expects($this->any()) |
| 579 | 579 | ->method('getAppValue') |
| 580 | 580 | ->willReturnCallback( |
| 581 | - function ($appName, $key, $default) use ($shareeEnumeration) { |
|
| 581 | + function($appName, $key, $default) use ($shareeEnumeration) { |
|
| 582 | 582 | if ($appName === 'core' && $key === 'shareapi_allow_share_dialog_user_enumeration') { |
| 583 | 583 | return $shareeEnumeration ? 'yes' : 'no'; |
| 584 | 584 | } |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | |
| 597 | 597 | $this->contactsManager->expects($this->any()) |
| 598 | 598 | ->method('search') |
| 599 | - ->willReturnCallback(function ($search, $searchAttributes) use ($searchTerm, $contacts) { |
|
| 599 | + ->willReturnCallback(function($search, $searchAttributes) use ($searchTerm, $contacts) { |
|
| 600 | 600 | if ($search === $searchTerm) { |
| 601 | 601 | return $contacts; |
| 602 | 602 | } |
@@ -758,7 +758,7 @@ discard block |
||
| 758 | 758 | ] |
| 759 | 759 | ], |
| 760 | 760 | false, |
| 761 | - ['users' => [], 'exact' => ['users' => [['uuid' => 'uid1', 'name' => 'User', 'label' => 'User ([email protected])','value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test'], 'shareWithDisplayNameUnique' => '[email protected]']]]], |
|
| 761 | + ['users' => [], 'exact' => ['users' => [['uuid' => 'uid1', 'name' => 'User', 'label' => 'User ([email protected])', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test'], 'shareWithDisplayNameUnique' => '[email protected]']]]], |
|
| 762 | 762 | true, |
| 763 | 763 | false, |
| 764 | 764 | ], |
@@ -875,7 +875,7 @@ discard block |
||
| 875 | 875 | $this->config->expects($this->any()) |
| 876 | 876 | ->method('getAppValue') |
| 877 | 877 | ->willReturnCallback( |
| 878 | - function ($appName, $key, $default) { |
|
| 878 | + function($appName, $key, $default) { |
|
| 879 | 879 | if ($appName === 'core' && $key === 'shareapi_allow_share_dialog_user_enumeration') { |
| 880 | 880 | return 'yes'; |
| 881 | 881 | } elseif ($appName === 'core' && $key === 'shareapi_only_share_with_group_members') { |
@@ -896,7 +896,7 @@ discard block |
||
| 896 | 896 | |
| 897 | 897 | $this->contactsManager->expects($this->any()) |
| 898 | 898 | ->method('search') |
| 899 | - ->willReturnCallback(function ($search, $searchAttributes) use ($searchTerm, $contacts) { |
|
| 899 | + ->willReturnCallback(function($search, $searchAttributes) use ($searchTerm, $contacts) { |
|
| 900 | 900 | if ($search === $searchTerm) { |
| 901 | 901 | return $contacts; |
| 902 | 902 | } |
@@ -909,13 +909,13 @@ discard block |
||
| 909 | 909 | |
| 910 | 910 | $this->groupManager->expects($this->any()) |
| 911 | 911 | ->method('getUserGroupIds') |
| 912 | - ->willReturnCallback(function (IUser $user) use ($userToGroupMapping) { |
|
| 912 | + ->willReturnCallback(function(IUser $user) use ($userToGroupMapping) { |
|
| 913 | 913 | return $userToGroupMapping[$user->getUID()]; |
| 914 | 914 | }); |
| 915 | 915 | |
| 916 | 916 | $this->groupManager->expects($this->any()) |
| 917 | 917 | ->method('isInGroup') |
| 918 | - ->willReturnCallback(function ($userId, $group) use ($userToGroupMapping) { |
|
| 918 | + ->willReturnCallback(function($userId, $group) use ($userToGroupMapping) { |
|
| 919 | 919 | return in_array($group, $userToGroupMapping[$userId]); |
| 920 | 920 | }); |
| 921 | 921 | |
@@ -983,7 +983,7 @@ discard block |
||
| 983 | 983 | 'UID' => 'User', |
| 984 | 984 | ] |
| 985 | 985 | ], |
| 986 | - ['emails' => [], 'exact' => ['emails' => [['label' => '[email protected]', 'uuid' => '[email protected]', 'value' => ['shareType' => IShare::TYPE_EMAIL,'shareWith' => '[email protected]']]]]], |
|
| 986 | + ['emails' => [], 'exact' => ['emails' => [['label' => '[email protected]', 'uuid' => '[email protected]', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => '[email protected]']]]]], |
|
| 987 | 987 | false, |
| 988 | 988 | false, |
| 989 | 989 | [ |
@@ -1009,7 +1009,7 @@ discard block |
||
| 1009 | 1009 | $this->config->expects($this->any()) |
| 1010 | 1010 | ->method('getAppValue') |
| 1011 | 1011 | ->willReturnCallback( |
| 1012 | - function ($appName, $key, $default) { |
|
| 1012 | + function($appName, $key, $default) { |
|
| 1013 | 1013 | if ($appName === 'core' && $key === 'shareapi_allow_share_dialog_user_enumeration') { |
| 1014 | 1014 | return 'yes'; |
| 1015 | 1015 | } elseif ($appName === 'core' && $key === 'shareapi_only_share_with_group_members') { |
@@ -1030,7 +1030,7 @@ discard block |
||
| 1030 | 1030 | |
| 1031 | 1031 | $this->contactsManager->expects($this->any()) |
| 1032 | 1032 | ->method('search') |
| 1033 | - ->willReturnCallback(function ($search, $searchAttributes) use ($searchTerm, $contacts) { |
|
| 1033 | + ->willReturnCallback(function($search, $searchAttributes) use ($searchTerm, $contacts) { |
|
| 1034 | 1034 | if ($search === $searchTerm) { |
| 1035 | 1035 | return $contacts; |
| 1036 | 1036 | } |
@@ -1043,13 +1043,13 @@ discard block |
||
| 1043 | 1043 | |
| 1044 | 1044 | $this->groupManager->expects($this->any()) |
| 1045 | 1045 | ->method('getUserGroupIds') |
| 1046 | - ->willReturnCallback(function (IUser $user) use ($userToGroupMapping) { |
|
| 1046 | + ->willReturnCallback(function(IUser $user) use ($userToGroupMapping) { |
|
| 1047 | 1047 | return $userToGroupMapping[$user->getUID()]; |
| 1048 | 1048 | }); |
| 1049 | 1049 | |
| 1050 | 1050 | $this->groupManager->expects($this->any()) |
| 1051 | 1051 | ->method('isInGroup') |
| 1052 | - ->willReturnCallback(function ($userId, $group) use ($userToGroupMapping) { |
|
| 1052 | + ->willReturnCallback(function($userId, $group) use ($userToGroupMapping) { |
|
| 1053 | 1053 | return in_array($group, $userToGroupMapping[$userId]); |
| 1054 | 1054 | }); |
| 1055 | 1055 | |
@@ -1075,7 +1075,7 @@ discard block |
||
| 1075 | 1075 | 'UID' => 'User', |
| 1076 | 1076 | ] |
| 1077 | 1077 | ], |
| 1078 | - ['users' => [['label' => 'User ([email protected])', 'uuid' => 'User', 'name' => 'User', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test'],'shareWithDisplayNameUnique' => '[email protected]',]], 'exact' => ['users' => []]], |
|
| 1078 | + ['users' => [['label' => 'User ([email protected])', 'uuid' => 'User', 'name' => 'User', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test'], 'shareWithDisplayNameUnique' => '[email protected]', ]], 'exact' => ['users' => []]], |
|
| 1079 | 1079 | false, |
| 1080 | 1080 | false, |
| 1081 | 1081 | [ |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | private function keyForMount(MountPoint $mount): string { |
| 124 | - return $mount->getStorageRootId() . '::' . $mount->getMountPoint(); |
|
| 124 | + return $mount->getStorageRootId().'::'.$mount->getMountPoint(); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | public function testNewMounts(): void { |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | $this->eventDispatcher |
| 184 | 184 | ->expects($this->exactly(2)) |
| 185 | 185 | ->method('dispatchTyped') |
| 186 | - ->with($this->callback(function (UserMountAddedEvent|UserMountRemovedEvent $event) use (&$operation) { |
|
| 186 | + ->with($this->callback(function(UserMountAddedEvent | UserMountRemovedEvent $event) use (&$operation) { |
|
| 187 | 187 | return match(++$operation) { |
| 188 | 188 | 1 => $event instanceof UserMountAddedEvent && $event->mountPoint->getMountPoint() === '/asd/', |
| 189 | 189 | 2 => $event instanceof UserMountRemovedEvent && $event->mountPoint->getMountPoint() === '/asd/', |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | $this->eventDispatcher |
| 215 | 215 | ->expects($this->exactly(3)) |
| 216 | 216 | ->method('dispatchTyped') |
| 217 | - ->with($this->callback(function (UserMountAddedEvent|UserMountRemovedEvent $event) use (&$operation) { |
|
| 217 | + ->with($this->callback(function(UserMountAddedEvent | UserMountRemovedEvent $event) use (&$operation) { |
|
| 218 | 218 | return match(++$operation) { |
| 219 | 219 | 1 => $event instanceof UserMountAddedEvent && $event->mountPoint->getMountPoint() === '/bar/', |
| 220 | 220 | 2 => $event instanceof UserMountAddedEvent && $event->mountPoint->getMountPoint() === '/foo/', |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | $this->eventDispatcher |
| 251 | 251 | ->expects($this->exactly(2)) |
| 252 | 252 | ->method('dispatchTyped') |
| 253 | - ->with($this->callback(function (UserMountAddedEvent|UserMountUpdatedEvent $event) use (&$operation) { |
|
| 253 | + ->with($this->callback(function(UserMountAddedEvent | UserMountUpdatedEvent $event) use (&$operation) { |
|
| 254 | 254 | return match(++$operation) { |
| 255 | 255 | 1 => $event instanceof UserMountAddedEvent && $event->mountPoint->getMountPoint() === '/foo/', |
| 256 | 256 | 2 => $event instanceof UserMountUpdatedEvent && $event->oldMountPoint->getMountId() === null && $event->newMountPoint->getMountId() === 1, |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | private function sortMounts(&$mounts) { |
| 381 | - usort($mounts, function (ICachedMountInfo $a, ICachedMountInfo $b) { |
|
| 381 | + usort($mounts, function(ICachedMountInfo $a, ICachedMountInfo $b) { |
|
| 382 | 382 | return strcmp($a->getUser()->getUID(), $b->getUser()->getUID()); |
| 383 | 383 | }); |
| 384 | 384 | } |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | ->from('filecache') |
| 414 | 414 | ->where($query->expr()->eq('storage', $query->createNamedParameter($storageId))) |
| 415 | 415 | ->andWhere($query->expr()->eq('path_hash', $query->createNamedParameter(md5($internalPath)))); |
| 416 | - $id = (int)$query->executeQuery()->fetchOne(); |
|
| 416 | + $id = (int) $query->executeQuery()->fetchOne(); |
|
| 417 | 417 | } else { |
| 418 | 418 | throw $e; |
| 419 | 419 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | $res6->method('getBackend')->willReturn($backend3); |
| 144 | 144 | |
| 145 | 145 | $res6->method('getAllAvailableMetadataKeys')->willReturn(['meta99', 'meta123']); |
| 146 | - $res6->method('getMetadataForKey')->willReturnCallback(function ($key) { |
|
| 146 | + $res6->method('getMetadataForKey')->willReturnCallback(function($key) { |
|
| 147 | 147 | switch ($key) { |
| 148 | 148 | case 'meta99': |
| 149 | 149 | return 'value99-new'; |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | $res7->method('getEMail')->willReturn('[email protected]'); |
| 163 | 163 | $res7->method('getBackend')->willReturn($backend3); |
| 164 | 164 | $res7->method('getAllAvailableMetadataKeys')->willReturn(['meta1']); |
| 165 | - $res7->method('getMetadataForKey')->willReturnCallback(function ($key) { |
|
| 165 | + $res7->method('getMetadataForKey')->willReturnCallback(function($key) { |
|
| 166 | 166 | switch ($key) { |
| 167 | 167 | case 'meta1': |
| 168 | 168 | return 'value1'; |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | $res8->method('getEMail')->willReturn('[email protected]'); |
| 179 | 179 | $res8->method('getBackend')->willReturn($backend4); |
| 180 | 180 | $res8->method('getAllAvailableMetadataKeys')->willReturn(['meta2']); |
| 181 | - $res8->method('getMetadataForKey')->willReturnCallback(function ($key) { |
|
| 181 | + $res8->method('getMetadataForKey')->willReturnCallback(function($key) { |
|
| 182 | 182 | switch ($key) { |
| 183 | 183 | case 'meta2': |
| 184 | 184 | return 'value2'; |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | $ids = []; |
| 218 | 218 | $stmt = $query->executeQuery(); |
| 219 | 219 | while ($row = $stmt->fetchAssociative()) { |
| 220 | - $ids[$row['backend_id'] . '::' . $row['resource_id']] = $row['id']; |
|
| 220 | + $ids[$row['backend_id'].'::'.$row['resource_id']] = $row['id']; |
|
| 221 | 221 | unset($row['id']); |
| 222 | 222 | $rows[] = $row; |
| 223 | 223 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @return TemplateResponse |
| 38 | 38 | */ |
| 39 | 39 | public function getForm() { |
| 40 | - $ownerConfigFile = fileowner(\OC::$configDir . 'config.php'); |
|
| 40 | + $ownerConfigFile = fileowner(\OC::$configDir.'config.php'); |
|
| 41 | 41 | $cliBasedCronPossible = function_exists('posix_getpwuid') && $ownerConfigFile !== false; |
| 42 | 42 | $cliBasedCronUser = $cliBasedCronPossible ? (posix_getpwuid($ownerConfigFile)['name'] ?? '') : ''; |
| 43 | 43 | |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | $result = $query->executeQuery(); |
| 73 | 73 | if ($row = $result->fetchAssociative()) { |
| 74 | - $maxAge = (int)$row['last_checked']; |
|
| 74 | + $maxAge = (int) $row['last_checked']; |
|
| 75 | 75 | } else { |
| 76 | 76 | $maxAge = $this->timeFactory->getTime(); |
| 77 | 77 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | Filesystem::initMountPoints($uid); |
| 90 | 90 | if ($uid !== OC_User::getUser()) { |
| 91 | 91 | $info = Filesystem::getFileInfo($filename); |
| 92 | - $ownerView = new View('/' . $uid . '/files'); |
|
| 92 | + $ownerView = new View('/'.$uid.'/files'); |
|
| 93 | 93 | try { |
| 94 | 94 | $filename = $ownerView->getPath($info['fileid']); |
| 95 | 95 | } catch (NotFoundException $e) { |
@@ -114,8 +114,8 @@ discard block |
||
| 114 | 114 | $array = []; |
| 115 | 115 | foreach ($result->iterateAssociative() as $row) { |
| 116 | 116 | $array[$row['id']][$row['timestamp']] = [ |
| 117 | - 'location' => (string)$row['location'], |
|
| 118 | - 'deletedBy' => (string)$row['deleted_by'], |
|
| 117 | + 'location' => (string) $row['location'], |
|
| 118 | + 'deletedBy' => (string) $row['deleted_by'], |
|
| 119 | 119 | ]; |
| 120 | 120 | } |
| 121 | 121 | $result->closeCursor(); |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | |
| 152 | 152 | /** @param string $user */ |
| 153 | 153 | private static function setUpTrash($user): void { |
| 154 | - $view = new View('/' . $user); |
|
| 154 | + $view = new View('/'.$user); |
|
| 155 | 155 | if (!$view->is_dir('files_trashbin')) { |
| 156 | 156 | $view->mkdir('files_trashbin'); |
| 157 | 157 | } |
@@ -186,8 +186,8 @@ discard block |
||
| 186 | 186 | |
| 187 | 187 | $view = new View('/'); |
| 188 | 188 | |
| 189 | - $target = $user . '/files_trashbin/files/' . static::getTrashFilename($targetFilename, $timestamp); |
|
| 190 | - $source = $owner . '/files_trashbin/files/' . static::getTrashFilename($sourceFilename, $timestamp); |
|
| 189 | + $target = $user.'/files_trashbin/files/'.static::getTrashFilename($targetFilename, $timestamp); |
|
| 190 | + $source = $owner.'/files_trashbin/files/'.static::getTrashFilename($sourceFilename, $timestamp); |
|
| 191 | 191 | $free = $view->free_space($target); |
| 192 | 192 | $isUnknownOrUnlimitedFreeSpace = $free < 0; |
| 193 | 193 | $isEnoughFreeSpaceLeft = $view->filesize($source) < $free; |
@@ -232,14 +232,14 @@ discard block |
||
| 232 | 232 | $ownerPath = $file_path; |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - $ownerView = new View('/' . $owner); |
|
| 235 | + $ownerView = new View('/'.$owner); |
|
| 236 | 236 | |
| 237 | 237 | // file has been deleted in between |
| 238 | 238 | if (is_null($ownerPath) || $ownerPath === '') { |
| 239 | 239 | return true; |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - $sourceInfo = $ownerView->getFileInfo('/files/' . $ownerPath); |
|
| 242 | + $sourceInfo = $ownerView->getFileInfo('/files/'.$ownerPath); |
|
| 243 | 243 | |
| 244 | 244 | if ($sourceInfo === false) { |
| 245 | 245 | return true; |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | $lockingProvider = Server::get(ILockingProvider::class); |
| 263 | 263 | |
| 264 | 264 | // disable proxy to prevent recursive calls |
| 265 | - $trashPath = '/files_trashbin/files/' . static::getTrashFilename($filename, $timestamp); |
|
| 265 | + $trashPath = '/files_trashbin/files/'.static::getTrashFilename($filename, $timestamp); |
|
| 266 | 266 | $gotLock = false; |
| 267 | 267 | |
| 268 | 268 | do { |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | |
| 278 | 278 | $timestamp = $timestamp + 1; |
| 279 | 279 | |
| 280 | - $trashPath = '/files_trashbin/files/' . static::getTrashFilename($filename, $timestamp); |
|
| 280 | + $trashPath = '/files_trashbin/files/'.static::getTrashFilename($filename, $timestamp); |
|
| 281 | 281 | } |
| 282 | 282 | } while (!$gotLock); |
| 283 | 283 | |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | if ($trashStorage->file_exists($trashInternalPath)) { |
| 307 | 307 | $trashStorage->unlink($trashInternalPath); |
| 308 | 308 | } |
| 309 | - Server::get(LoggerInterface::class)->error('Couldn\'t move ' . $file_path . ' to the trash bin', ['app' => 'files_trashbin']); |
|
| 309 | + Server::get(LoggerInterface::class)->error('Couldn\'t move '.$file_path.' to the trash bin', ['app' => 'files_trashbin']); |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | if ($sourceStorage->file_exists($sourceInternalPath)) { // failed to delete the original file, abort |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | return $moveSuccessful; |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | - private static function getConfiguredTrashbinSize(string $user): int|float { |
|
| 363 | + private static function getConfiguredTrashbinSize(string $user): int | float { |
|
| 364 | 364 | $config = Server::get(IConfig::class); |
| 365 | 365 | $userTrashbinSize = $config->getUserValue($user, 'files_trashbin', 'trashbin_size', '-1'); |
| 366 | 366 | if (is_numeric($userTrashbinSize) && ($userTrashbinSize > -1)) { |
@@ -386,17 +386,17 @@ discard block |
||
| 386 | 386 | $user = OC_User::getUser(); |
| 387 | 387 | $rootView = new View('/'); |
| 388 | 388 | |
| 389 | - if ($rootView->is_dir($owner . '/files_versions/' . $ownerPath)) { |
|
| 389 | + if ($rootView->is_dir($owner.'/files_versions/'.$ownerPath)) { |
|
| 390 | 390 | if ($owner !== $user) { |
| 391 | - self::copy_recursive($owner . '/files_versions/' . $ownerPath, $owner . '/files_trashbin/versions/' . static::getTrashFilename(basename($ownerPath), $timestamp), $rootView); |
|
| 391 | + self::copy_recursive($owner.'/files_versions/'.$ownerPath, $owner.'/files_trashbin/versions/'.static::getTrashFilename(basename($ownerPath), $timestamp), $rootView); |
|
| 392 | 392 | } |
| 393 | - self::move($rootView, $owner . '/files_versions/' . $ownerPath, $user . '/files_trashbin/versions/' . static::getTrashFilename($filename, $timestamp)); |
|
| 393 | + self::move($rootView, $owner.'/files_versions/'.$ownerPath, $user.'/files_trashbin/versions/'.static::getTrashFilename($filename, $timestamp)); |
|
| 394 | 394 | } elseif ($versions = Storage::getVersions($owner, $ownerPath)) { |
| 395 | 395 | foreach ($versions as $v) { |
| 396 | 396 | if ($owner !== $user) { |
| 397 | - self::copy($rootView, $owner . '/files_versions' . $v['path'] . '.v' . $v['version'], $owner . '/files_trashbin/versions/' . static::getTrashFilename($v['name'] . '.v' . $v['version'], $timestamp)); |
|
| 397 | + self::copy($rootView, $owner.'/files_versions'.$v['path'].'.v'.$v['version'], $owner.'/files_trashbin/versions/'.static::getTrashFilename($v['name'].'.v'.$v['version'], $timestamp)); |
|
| 398 | 398 | } |
| 399 | - self::move($rootView, $owner . '/files_versions' . $v['path'] . '.v' . $v['version'], $user . '/files_trashbin/versions/' . static::getTrashFilename($filename . '.v' . $v['version'], $timestamp)); |
|
| 399 | + self::move($rootView, $owner.'/files_versions'.$v['path'].'.v'.$v['version'], $user.'/files_trashbin/versions/'.static::getTrashFilename($filename.'.v'.$v['version'], $timestamp)); |
|
| 400 | 400 | } |
| 401 | 401 | } |
| 402 | 402 | } |
@@ -461,18 +461,18 @@ discard block |
||
| 461 | 461 | if (!$user) { |
| 462 | 462 | throw new \Exception('Tried to restore a file while not logged in'); |
| 463 | 463 | } |
| 464 | - $view = new View('/' . $user); |
|
| 464 | + $view = new View('/'.$user); |
|
| 465 | 465 | |
| 466 | 466 | $location = ''; |
| 467 | 467 | if ($timestamp) { |
| 468 | 468 | $location = self::getLocation($user, $filename, $timestamp); |
| 469 | 469 | if ($location === false) { |
| 470 | - Server::get(LoggerInterface::class)->error('trash bin database inconsistent! ($user: ' . $user . ' $filename: ' . $filename . ', $timestamp: ' . $timestamp . ')', ['app' => 'files_trashbin']); |
|
| 470 | + Server::get(LoggerInterface::class)->error('trash bin database inconsistent! ($user: '.$user.' $filename: '.$filename.', $timestamp: '.$timestamp.')', ['app' => 'files_trashbin']); |
|
| 471 | 471 | } else { |
| 472 | 472 | // if location no longer exists, restore file in the root directory |
| 473 | 473 | if ($location !== '/' |
| 474 | - && (!$view->is_dir('files/' . $location) |
|
| 475 | - || !$view->isCreatable('files/' . $location)) |
|
| 474 | + && (!$view->is_dir('files/'.$location) |
|
| 475 | + || !$view->isCreatable('files/'.$location)) |
|
| 476 | 476 | ) { |
| 477 | 477 | $location = ''; |
| 478 | 478 | } |
@@ -482,8 +482,8 @@ discard block |
||
| 482 | 482 | // we need a extension in case a file/dir with the same name already exists |
| 483 | 483 | $uniqueFilename = self::getUniqueFilename($location, $filename, $view); |
| 484 | 484 | |
| 485 | - $source = Filesystem::normalizePath('files_trashbin/files/' . $file); |
|
| 486 | - $target = Filesystem::normalizePath('files/' . $location . '/' . $uniqueFilename); |
|
| 485 | + $source = Filesystem::normalizePath('files_trashbin/files/'.$file); |
|
| 486 | + $target = Filesystem::normalizePath('files/'.$location.'/'.$uniqueFilename); |
|
| 487 | 487 | if (!$view->file_exists($source)) { |
| 488 | 488 | return false; |
| 489 | 489 | } |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | $sourcePath = Filesystem::normalizePath($file); |
| 498 | - $targetPath = Filesystem::normalizePath('/' . $location . '/' . $uniqueFilename); |
|
| 498 | + $targetPath = Filesystem::normalizePath('/'.$location.'/'.$uniqueFilename); |
|
| 499 | 499 | |
| 500 | 500 | $sourceNode = self::getNodeForPath($user, $sourcePath); |
| 501 | 501 | $targetNode = self::getNodeForPath($user, $targetPath, 'files'); |
@@ -513,8 +513,8 @@ discard block |
||
| 513 | 513 | // handle the restore result |
| 514 | 514 | if ($restoreResult) { |
| 515 | 515 | $fakeRoot = $view->getRoot(); |
| 516 | - $view->chroot('/' . $user . '/files'); |
|
| 517 | - $view->touch('/' . $location . '/' . $uniqueFilename, $mtime); |
|
| 516 | + $view->chroot('/'.$user.'/files'); |
|
| 517 | + $view->touch('/'.$location.'/'.$uniqueFilename, $mtime); |
|
| 518 | 518 | $view->chroot($fakeRoot); |
| 519 | 519 | Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', ['filePath' => $targetPath, 'trashPath' => $sourcePath]); |
| 520 | 520 | |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | $user = OC_User::getUser(); |
| 558 | 558 | $rootView = new View('/'); |
| 559 | 559 | |
| 560 | - $target = Filesystem::normalizePath('/' . $location . '/' . $uniqueFilename); |
|
| 560 | + $target = Filesystem::normalizePath('/'.$location.'/'.$uniqueFilename); |
|
| 561 | 561 | |
| 562 | 562 | [$owner, $ownerPath] = self::getUidAndFilename($target); |
| 563 | 563 | |
@@ -572,14 +572,14 @@ discard block |
||
| 572 | 572 | $versionedFile = $file; |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | - if ($view->is_dir('/files_trashbin/versions/' . $file)) { |
|
| 576 | - $rootView->rename(Filesystem::normalizePath($user . '/files_trashbin/versions/' . $file), Filesystem::normalizePath($owner . '/files_versions/' . $ownerPath)); |
|
| 575 | + if ($view->is_dir('/files_trashbin/versions/'.$file)) { |
|
| 576 | + $rootView->rename(Filesystem::normalizePath($user.'/files_trashbin/versions/'.$file), Filesystem::normalizePath($owner.'/files_versions/'.$ownerPath)); |
|
| 577 | 577 | } elseif ($versions = self::getVersionsFromTrash($versionedFile, $timestamp, $user)) { |
| 578 | 578 | foreach ($versions as $v) { |
| 579 | 579 | if ($timestamp) { |
| 580 | - $rootView->rename($user . '/files_trashbin/versions/' . static::getTrashFilename($versionedFile . '.v' . $v, $timestamp), $owner . '/files_versions/' . $ownerPath . '.v' . $v); |
|
| 580 | + $rootView->rename($user.'/files_trashbin/versions/'.static::getTrashFilename($versionedFile.'.v'.$v, $timestamp), $owner.'/files_versions/'.$ownerPath.'.v'.$v); |
|
| 581 | 581 | } else { |
| 582 | - $rootView->rename($user . '/files_trashbin/versions/' . $versionedFile . '.v' . $v, $owner . '/files_versions/' . $ownerPath . '.v' . $v); |
|
| 582 | + $rootView->rename($user.'/files_trashbin/versions/'.$versionedFile.'.v'.$v, $owner.'/files_versions/'.$ownerPath.'.v'.$v); |
|
| 583 | 583 | } |
| 584 | 584 | } |
| 585 | 585 | } |
@@ -592,7 +592,7 @@ discard block |
||
| 592 | 592 | public static function deleteAll() { |
| 593 | 593 | $user = OC_User::getUser(); |
| 594 | 594 | $userRoot = \OC::$server->getUserFolder($user)->getParent(); |
| 595 | - $view = new View('/' . $user); |
|
| 595 | + $view = new View('/'.$user); |
|
| 596 | 596 | $fileInfos = $view->getDirectoryContent('files_trashbin/files'); |
| 597 | 597 | |
| 598 | 598 | try { |
@@ -667,7 +667,7 @@ discard block |
||
| 667 | 667 | */ |
| 668 | 668 | public static function delete($filename, $user, $timestamp = null) { |
| 669 | 669 | $userRoot = \OC::$server->getUserFolder($user)->getParent(); |
| 670 | - $view = new View('/' . $user); |
|
| 670 | + $view = new View('/'.$user); |
|
| 671 | 671 | $size = 0; |
| 672 | 672 | |
| 673 | 673 | if ($timestamp) { |
@@ -686,20 +686,20 @@ discard block |
||
| 686 | 686 | $size += self::deleteVersions($view, $file, $filename, $timestamp, $user); |
| 687 | 687 | |
| 688 | 688 | try { |
| 689 | - $node = $userRoot->get('/files_trashbin/files/' . $file); |
|
| 689 | + $node = $userRoot->get('/files_trashbin/files/'.$file); |
|
| 690 | 690 | } catch (NotFoundException $e) { |
| 691 | 691 | return $size; |
| 692 | 692 | } |
| 693 | 693 | |
| 694 | 694 | if ($node instanceof Folder) { |
| 695 | - $size += self::calculateSize(new View('/' . $user . '/files_trashbin/files/' . $file)); |
|
| 695 | + $size += self::calculateSize(new View('/'.$user.'/files_trashbin/files/'.$file)); |
|
| 696 | 696 | } elseif ($node instanceof File) { |
| 697 | - $size += $view->filesize('/files_trashbin/files/' . $file); |
|
| 697 | + $size += $view->filesize('/files_trashbin/files/'.$file); |
|
| 698 | 698 | } |
| 699 | 699 | |
| 700 | - self::emitTrashbinPreDelete('/files_trashbin/files/' . $file); |
|
| 700 | + self::emitTrashbinPreDelete('/files_trashbin/files/'.$file); |
|
| 701 | 701 | $node->delete(); |
| 702 | - self::emitTrashbinPostDelete('/files_trashbin/files/' . $file); |
|
| 702 | + self::emitTrashbinPostDelete('/files_trashbin/files/'.$file); |
|
| 703 | 703 | |
| 704 | 704 | return $size; |
| 705 | 705 | } |
@@ -709,20 +709,20 @@ discard block |
||
| 709 | 709 | * @param string $filename |
| 710 | 710 | * @param ?int $timestamp |
| 711 | 711 | */ |
| 712 | - private static function deleteVersions(View $view, $file, $filename, $timestamp, string $user): int|float { |
|
| 712 | + private static function deleteVersions(View $view, $file, $filename, $timestamp, string $user): int | float { |
|
| 713 | 713 | $size = 0; |
| 714 | 714 | if (Server::get(IAppManager::class)->isEnabledForUser('files_versions')) { |
| 715 | - if ($view->is_dir('files_trashbin/versions/' . $file)) { |
|
| 716 | - $size += self::calculateSize(new View('/' . $user . '/files_trashbin/versions/' . $file)); |
|
| 717 | - $view->unlink('files_trashbin/versions/' . $file); |
|
| 715 | + if ($view->is_dir('files_trashbin/versions/'.$file)) { |
|
| 716 | + $size += self::calculateSize(new View('/'.$user.'/files_trashbin/versions/'.$file)); |
|
| 717 | + $view->unlink('files_trashbin/versions/'.$file); |
|
| 718 | 718 | } elseif ($versions = self::getVersionsFromTrash($filename, $timestamp, $user)) { |
| 719 | 719 | foreach ($versions as $v) { |
| 720 | 720 | if ($timestamp) { |
| 721 | - $size += $view->filesize('/files_trashbin/versions/' . static::getTrashFilename($filename . '.v' . $v, $timestamp)); |
|
| 722 | - $view->unlink('/files_trashbin/versions/' . static::getTrashFilename($filename . '.v' . $v, $timestamp)); |
|
| 721 | + $size += $view->filesize('/files_trashbin/versions/'.static::getTrashFilename($filename.'.v'.$v, $timestamp)); |
|
| 722 | + $view->unlink('/files_trashbin/versions/'.static::getTrashFilename($filename.'.v'.$v, $timestamp)); |
|
| 723 | 723 | } else { |
| 724 | - $size += $view->filesize('/files_trashbin/versions/' . $filename . '.v' . $v); |
|
| 725 | - $view->unlink('/files_trashbin/versions/' . $filename . '.v' . $v); |
|
| 724 | + $size += $view->filesize('/files_trashbin/versions/'.$filename.'.v'.$v); |
|
| 725 | + $view->unlink('/files_trashbin/versions/'.$filename.'.v'.$v); |
|
| 726 | 726 | } |
| 727 | 727 | } |
| 728 | 728 | } |
@@ -739,13 +739,13 @@ discard block |
||
| 739 | 739 | */ |
| 740 | 740 | public static function file_exists($filename, $timestamp = null) { |
| 741 | 741 | $user = OC_User::getUser(); |
| 742 | - $view = new View('/' . $user); |
|
| 742 | + $view = new View('/'.$user); |
|
| 743 | 743 | |
| 744 | 744 | if ($timestamp) { |
| 745 | 745 | $filename = static::getTrashFilename($filename, $timestamp); |
| 746 | 746 | } |
| 747 | 747 | |
| 748 | - $target = Filesystem::normalizePath('files_trashbin/files/' . $filename); |
|
| 748 | + $target = Filesystem::normalizePath('files_trashbin/files/'.$filename); |
|
| 749 | 749 | return $view->file_exists($target); |
| 750 | 750 | } |
| 751 | 751 | |
@@ -759,7 +759,7 @@ discard block |
||
| 759 | 759 | $query = Server::get(IDBConnection::class)->getQueryBuilder(); |
| 760 | 760 | $query->delete('files_trash') |
| 761 | 761 | ->where($query->expr()->eq('user', $query->createNamedParameter($uid))); |
| 762 | - return (bool)$query->executeStatement(); |
|
| 762 | + return (bool) $query->executeStatement(); |
|
| 763 | 763 | } |
| 764 | 764 | |
| 765 | 765 | /** |
@@ -769,7 +769,7 @@ discard block |
||
| 769 | 769 | * @param string $user |
| 770 | 770 | * @return int|float available free space for trash bin |
| 771 | 771 | */ |
| 772 | - private static function calculateFreeSpace(int|float $trashbinSize, string $user): int|float { |
|
| 772 | + private static function calculateFreeSpace(int | float $trashbinSize, string $user): int | float { |
|
| 773 | 773 | $configuredTrashbinSize = static::getConfiguredTrashbinSize($user); |
| 774 | 774 | if ($configuredTrashbinSize > -1) { |
| 775 | 775 | return $configuredTrashbinSize - $trashbinSize; |
@@ -871,7 +871,7 @@ discard block |
||
| 871 | 871 | * @param int|float $availableSpace available disc space |
| 872 | 872 | * @return int|float size of deleted files |
| 873 | 873 | */ |
| 874 | - protected static function deleteFiles(array $files, string $user, int|float $availableSpace): int|float { |
|
| 874 | + protected static function deleteFiles(array $files, string $user, int | float $availableSpace): int | float { |
|
| 875 | 875 | $expiration = Server::get(Expiration::class); |
| 876 | 876 | $size = 0; |
| 877 | 877 | |
@@ -880,7 +880,7 @@ discard block |
||
| 880 | 880 | if ($availableSpace <= 0 && $expiration->isExpired($file['mtime'], true)) { |
| 881 | 881 | $tmp = self::delete($file['name'], $user, $file['mtime']); |
| 882 | 882 | Server::get(LoggerInterface::class)->info( |
| 883 | - 'remove "' . $file['name'] . '" (' . $tmp . 'B) to meet the limit of trash bin size (50% of available quota) for user "{user}"', |
|
| 883 | + 'remove "'.$file['name'].'" ('.$tmp.'B) to meet the limit of trash bin size (50% of available quota) for user "{user}"', |
|
| 884 | 884 | [ |
| 885 | 885 | 'app' => 'files_trashbin', |
| 886 | 886 | 'user' => $user, |
@@ -915,7 +915,7 @@ discard block |
||
| 915 | 915 | $size += self::delete($filename, $user, $timestamp); |
| 916 | 916 | $count++; |
| 917 | 917 | } catch (NotPermittedException $e) { |
| 918 | - Server::get(LoggerInterface::class)->warning('Removing "' . $filename . '" from trashbin failed for user "{user}"', |
|
| 918 | + Server::get(LoggerInterface::class)->warning('Removing "'.$filename.'" from trashbin failed for user "{user}"', |
|
| 919 | 919 | [ |
| 920 | 920 | 'exception' => $e, |
| 921 | 921 | 'app' => 'files_trashbin', |
@@ -924,7 +924,7 @@ discard block |
||
| 924 | 924 | ); |
| 925 | 925 | } |
| 926 | 926 | Server::get(LoggerInterface::class)->info( |
| 927 | - 'Remove "' . $filename . '" from trashbin for user "{user}" because it exceeds max retention obligation term.', |
|
| 927 | + 'Remove "'.$filename.'" from trashbin for user "{user}" because it exceeds max retention obligation term.', |
|
| 928 | 928 | [ |
| 929 | 929 | 'app' => 'files_trashbin', |
| 930 | 930 | 'user' => $user, |
@@ -947,22 +947,22 @@ discard block |
||
| 947 | 947 | * @return int|float |
| 948 | 948 | * @throws Exceptions\CopyRecursiveException |
| 949 | 949 | */ |
| 950 | - private static function copy_recursive($source, $destination, View $view): int|float { |
|
| 950 | + private static function copy_recursive($source, $destination, View $view): int | float { |
|
| 951 | 951 | $size = 0; |
| 952 | 952 | if ($view->is_dir($source)) { |
| 953 | 953 | $view->mkdir($destination); |
| 954 | 954 | $view->touch($destination, $view->filemtime($source)); |
| 955 | 955 | foreach ($view->getDirectoryContent($source) as $i) { |
| 956 | - $pathDir = $source . '/' . $i['name']; |
|
| 956 | + $pathDir = $source.'/'.$i['name']; |
|
| 957 | 957 | if ($view->is_dir($pathDir)) { |
| 958 | - $size += self::copy_recursive($pathDir, $destination . '/' . $i['name'], $view); |
|
| 958 | + $size += self::copy_recursive($pathDir, $destination.'/'.$i['name'], $view); |
|
| 959 | 959 | } else { |
| 960 | 960 | $size += $view->filesize($pathDir); |
| 961 | - $result = $view->copy($pathDir, $destination . '/' . $i['name']); |
|
| 961 | + $result = $view->copy($pathDir, $destination.'/'.$i['name']); |
|
| 962 | 962 | if (!$result) { |
| 963 | 963 | throw new CopyRecursiveException(); |
| 964 | 964 | } |
| 965 | - $view->touch($destination . '/' . $i['name'], $view->filemtime($pathDir)); |
|
| 965 | + $view->touch($destination.'/'.$i['name'], $view->filemtime($pathDir)); |
|
| 966 | 966 | } |
| 967 | 967 | } |
| 968 | 968 | } else { |
@@ -983,17 +983,17 @@ discard block |
||
| 983 | 983 | * @param int $timestamp timestamp when the file was deleted |
| 984 | 984 | */ |
| 985 | 985 | private static function getVersionsFromTrash($filename, $timestamp, string $user): array { |
| 986 | - $view = new View('/' . $user . '/files_trashbin/versions'); |
|
| 986 | + $view = new View('/'.$user.'/files_trashbin/versions'); |
|
| 987 | 987 | $versions = []; |
| 988 | 988 | |
| 989 | 989 | /** @var \OC\Files\Storage\Storage $storage */ |
| 990 | - [$storage,] = $view->resolvePath('/'); |
|
| 990 | + [$storage, ] = $view->resolvePath('/'); |
|
| 991 | 991 | |
| 992 | 992 | $pattern = Server::get(IDBConnection::class)->escapeLikeParameter(basename($filename)); |
| 993 | 993 | if ($timestamp) { |
| 994 | 994 | // fetch for old versions |
| 995 | - $escapedTimestamp = Server::get(IDBConnection::class)->escapeLikeParameter((string)$timestamp); |
|
| 996 | - $pattern .= '.v%.d' . $escapedTimestamp; |
|
| 995 | + $escapedTimestamp = Server::get(IDBConnection::class)->escapeLikeParameter((string) $timestamp); |
|
| 996 | + $pattern .= '.v%.d'.$escapedTimestamp; |
|
| 997 | 997 | $offset = -strlen($escapedTimestamp) - 2; |
| 998 | 998 | } else { |
| 999 | 999 | $pattern .= '.v%'; |
@@ -1005,7 +1005,7 @@ discard block |
||
| 1005 | 1005 | Server::get(IDBConnection::class)->getQueryBuilder(), |
| 1006 | 1006 | Server::get(IFilesMetadataManager::class), |
| 1007 | 1007 | ); |
| 1008 | - $normalizedParentPath = ltrim(Filesystem::normalizePath(dirname('files_trashbin/versions/' . $filename)), '/'); |
|
| 1008 | + $normalizedParentPath = ltrim(Filesystem::normalizePath(dirname('files_trashbin/versions/'.$filename)), '/'); |
|
| 1009 | 1009 | $parentId = $cache->getId($normalizedParentPath); |
| 1010 | 1010 | if ($parentId === -1) { |
| 1011 | 1011 | return []; |
@@ -1021,7 +1021,7 @@ discard block |
||
| 1021 | 1021 | $result->closeCursor(); |
| 1022 | 1022 | |
| 1023 | 1023 | /** @var CacheEntry[] $matches */ |
| 1024 | - $matches = array_map(function (array $data) { |
|
| 1024 | + $matches = array_map(function(array $data) { |
|
| 1025 | 1025 | return Cache::cacheEntryFromData($data, Server::get(IMimeTypeLoader::class)); |
| 1026 | 1026 | }, $entries); |
| 1027 | 1027 | |
@@ -1051,18 +1051,18 @@ discard block |
||
| 1051 | 1051 | $name = pathinfo($filename, PATHINFO_FILENAME); |
| 1052 | 1052 | $l = Util::getL10N('files_trashbin'); |
| 1053 | 1053 | |
| 1054 | - $location = '/' . trim($location, '/'); |
|
| 1054 | + $location = '/'.trim($location, '/'); |
|
| 1055 | 1055 | |
| 1056 | 1056 | // if extension is not empty we set a dot in front of it |
| 1057 | 1057 | if ($ext !== '') { |
| 1058 | - $ext = '.' . $ext; |
|
| 1058 | + $ext = '.'.$ext; |
|
| 1059 | 1059 | } |
| 1060 | 1060 | |
| 1061 | - if ($view->file_exists('files' . $location . '/' . $filename)) { |
|
| 1061 | + if ($view->file_exists('files'.$location.'/'.$filename)) { |
|
| 1062 | 1062 | $i = 2; |
| 1063 | - $uniqueName = $name . ' (' . $l->t('restored') . ')' . $ext; |
|
| 1064 | - while ($view->file_exists('files' . $location . '/' . $uniqueName)) { |
|
| 1065 | - $uniqueName = $name . ' (' . $l->t('restored') . ' ' . $i . ')' . $ext; |
|
| 1063 | + $uniqueName = $name.' ('.$l->t('restored').')'.$ext; |
|
| 1064 | + while ($view->file_exists('files'.$location.'/'.$uniqueName)) { |
|
| 1065 | + $uniqueName = $name.' ('.$l->t('restored').' '.$i.')'.$ext; |
|
| 1066 | 1066 | $i++; |
| 1067 | 1067 | } |
| 1068 | 1068 | |
@@ -1078,8 +1078,8 @@ discard block |
||
| 1078 | 1078 | * @param View $view file view on the root folder |
| 1079 | 1079 | * @return int|float size of the folder |
| 1080 | 1080 | */ |
| 1081 | - private static function calculateSize(View $view): int|float { |
|
| 1082 | - $root = Server::get(IConfig::class)->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . $view->getAbsolutePath(''); |
|
| 1081 | + private static function calculateSize(View $view): int | float { |
|
| 1082 | + $root = Server::get(IConfig::class)->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data').$view->getAbsolutePath(''); |
|
| 1083 | 1083 | if (!file_exists($root)) { |
| 1084 | 1084 | return 0; |
| 1085 | 1085 | } |
@@ -1109,8 +1109,8 @@ discard block |
||
| 1109 | 1109 | * @param string $user user who owns the trash bin |
| 1110 | 1110 | * @return int|float trash bin size |
| 1111 | 1111 | */ |
| 1112 | - private static function getTrashbinSize(string $user): int|float { |
|
| 1113 | - $view = new View('/' . $user); |
|
| 1112 | + private static function getTrashbinSize(string $user): int | float { |
|
| 1113 | + $view = new View('/'.$user); |
|
| 1114 | 1114 | $fileInfo = $view->getFileInfo('/files_trashbin'); |
| 1115 | 1115 | return isset($fileInfo['size']) ? $fileInfo['size'] : 0; |
| 1116 | 1116 | } |
@@ -1122,7 +1122,7 @@ discard block |
||
| 1122 | 1122 | * @return bool |
| 1123 | 1123 | */ |
| 1124 | 1124 | public static function isEmpty($user) { |
| 1125 | - $view = new View('/' . $user . '/files_trashbin'); |
|
| 1125 | + $view = new View('/'.$user.'/files_trashbin'); |
|
| 1126 | 1126 | if ($view->is_dir('/files') && $dh = $view->opendir('/files')) { |
| 1127 | 1127 | while (($file = readdir($dh)) !== false) { |
| 1128 | 1128 | if (!Filesystem::isIgnoredDir($file)) { |
@@ -1145,7 +1145,7 @@ discard block |
||
| 1145 | 1145 | * Return the filename used in the trash bin |
| 1146 | 1146 | */ |
| 1147 | 1147 | public static function getTrashFilename(string $filename, int $timestamp): string { |
| 1148 | - $trashFilename = $filename . '.d' . $timestamp; |
|
| 1148 | + $trashFilename = $filename.'.d'.$timestamp; |
|
| 1149 | 1149 | $length = strlen($trashFilename); |
| 1150 | 1150 | // oc_filecache `name` column has a limit of 250 chars |
| 1151 | 1151 | $maxLength = 250; |
@@ -1173,7 +1173,7 @@ discard block |
||
| 1173 | 1173 | } |
| 1174 | 1174 | |
| 1175 | 1175 | $view = Server::get(View::class); |
| 1176 | - $fullPath = '/' . $user . '/' . $baseDir . '/' . $path; |
|
| 1176 | + $fullPath = '/'.$user.'/'.$baseDir.'/'.$path; |
|
| 1177 | 1177 | |
| 1178 | 1178 | if (Filesystem::is_dir($path)) { |
| 1179 | 1179 | return new NonExistingFolder($rootFolder, $view, $fullPath); |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | $this->assertCount(4, $rows); |
| 92 | 92 | |
| 93 | - $this->reminderBackend->removeReminder((int)$rows[3]['id']); |
|
| 93 | + $this->reminderBackend->removeReminder((int) $rows[3]['id']); |
|
| 94 | 94 | |
| 95 | 95 | $query = self::$realDatabase->getQueryBuilder(); |
| 96 | 96 | $rows = $query->select('*') |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | 'principaluri' => 'principals/users/user001', |
| 149 | 149 | ]; |
| 150 | 150 | |
| 151 | - $this->assertEqualsCanonicalizing([$rows[0],$rows[1]], [$expected1,$expected2]); |
|
| 151 | + $this->assertEqualsCanonicalizing([$rows[0], $rows[1]], [$expected1, $expected2]); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | public function testGetAllScheduledRemindersForEvent(): void { |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | |
| 238 | 238 | $this->assertEquals($rows[3]['notification_date'], 123600); |
| 239 | 239 | |
| 240 | - $reminderId = (int)$rows[3]['id']; |
|
| 240 | + $reminderId = (int) $rows[3]['id']; |
|
| 241 | 241 | $newNotificationDate = 123700; |
| 242 | 242 | |
| 243 | 243 | $this->reminderBackend->updateReminder($reminderId, $newNotificationDate); |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | ->executeQuery() |
| 250 | 250 | ->fetchAssociative(); |
| 251 | 251 | |
| 252 | - $this->assertEquals((int)$row['notification_date'], 123700); |
|
| 252 | + $this->assertEquals((int) $row['notification_date'], 123700); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | $data = []; |
| 115 | 115 | while ($row = $result->fetchAssociative()) { |
| 116 | 116 | $value = $row['propertyvalue']; |
| 117 | - if ((int)$row['valuetype'] === CustomPropertiesBackend::PROPERTY_TYPE_HREF) { |
|
| 117 | + if ((int) $row['valuetype'] === CustomPropertiesBackend::PROPERTY_TYPE_HREF) { |
|
| 118 | 118 | $value = new Href($value); |
| 119 | 119 | } |
| 120 | 120 | $data[$row['propertyname']] = $value; |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | |
| 187 | 187 | $setProps = []; |
| 188 | 188 | $propFind->method('set') |
| 189 | - ->willReturnCallback(function ($name, $value, $status) use (&$setProps): void { |
|
| 189 | + ->willReturnCallback(function($name, $value, $status) use (&$setProps): void { |
|
| 190 | 190 | $setProps[$name] = $value; |
| 191 | 191 | }); |
| 192 | 192 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | |
| 197 | 197 | public function testPropFindPrincipalCall(): void { |
| 198 | 198 | $this->tree->method('getNodeForPath') |
| 199 | - ->willReturnCallback(function ($uri) { |
|
| 199 | + ->willReturnCallback(function($uri) { |
|
| 200 | 200 | $node = $this->createMock(Calendar::class); |
| 201 | 201 | $node->method('getOwner') |
| 202 | 202 | ->willReturn('principals/users/dummy_user_42'); |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | |
| 232 | 232 | $setProps = []; |
| 233 | 233 | $propFind->method('set') |
| 234 | - ->willReturnCallback(function ($name, $value, $status) use (&$setProps): void { |
|
| 234 | + ->willReturnCallback(function($name, $value, $status) use (&$setProps): void { |
|
| 235 | 235 | $setProps[$name] = $value; |
| 236 | 236 | }); |
| 237 | 237 | |
@@ -242,28 +242,28 @@ discard block |
||
| 242 | 242 | public static function propFindPrincipalScheduleDefaultCalendarProviderUrlProvider(): array { |
| 243 | 243 | // [ user, nodes, existingProps, requestedProps, returnedProps ] |
| 244 | 244 | return [ |
| 245 | - [ // Exists |
|
| 245 | + [// Exists |
|
| 246 | 246 | 'dummy_user_42', |
| 247 | 247 | ['calendars/dummy_user_42/foo/' => Calendar::class], |
| 248 | 248 | ['{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL' => new Href('calendars/dummy_user_42/foo/')], |
| 249 | 249 | ['{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL'], |
| 250 | 250 | ['{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL' => new Href('calendars/dummy_user_42/foo/')], |
| 251 | 251 | ], |
| 252 | - [ // Doesn't exist |
|
| 252 | + [// Doesn't exist |
|
| 253 | 253 | 'dummy_user_42', |
| 254 | 254 | ['calendars/dummy_user_42/foo/' => Calendar::class], |
| 255 | 255 | ['{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL' => new Href('calendars/dummy_user_42/bar/')], |
| 256 | 256 | ['{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL'], |
| 257 | 257 | [], |
| 258 | 258 | ], |
| 259 | - [ // No privilege |
|
| 259 | + [// No privilege |
|
| 260 | 260 | 'dummy_user_42', |
| 261 | 261 | ['calendars/user2/baz/' => Calendar::class], |
| 262 | 262 | ['{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL' => new Href('calendars/user2/baz/')], |
| 263 | 263 | ['{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL'], |
| 264 | 264 | [], |
| 265 | 265 | ], |
| 266 | - [ // Not a calendar |
|
| 266 | + [// Not a calendar |
|
| 267 | 267 | 'dummy_user_42', |
| 268 | 268 | ['foo/dummy_user_42/bar/' => IACL::class], |
| 269 | 269 | ['{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL' => new Href('foo/dummy_user_42/bar/')], |
@@ -303,14 +303,14 @@ discard block |
||
| 303 | 303 | )); |
| 304 | 304 | |
| 305 | 305 | $this->server->method('calculateUri') |
| 306 | - ->willReturnCallback(function ($uri) { |
|
| 306 | + ->willReturnCallback(function($uri) { |
|
| 307 | 307 | if (!str_starts_with($uri, self::BASE_URI)) { |
| 308 | 308 | return trim(substr($uri, strlen(self::BASE_URI)), '/'); |
| 309 | 309 | } |
| 310 | 310 | return null; |
| 311 | 311 | }); |
| 312 | 312 | $this->tree->method('getNodeForPath') |
| 313 | - ->willReturnCallback(function ($uri) use ($nodes) { |
|
| 313 | + ->willReturnCallback(function($uri) use ($nodes) { |
|
| 314 | 314 | if (str_starts_with($uri, 'principals/')) { |
| 315 | 315 | return $this->createMock(IPrincipal::class); |
| 316 | 316 | } |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | |
| 329 | 329 | $setProps = []; |
| 330 | 330 | $propFind->method('set') |
| 331 | - ->willReturnCallback(function ($name, $value, $status) use (&$setProps): void { |
|
| 331 | + ->willReturnCallback(function($name, $value, $status) use (&$setProps): void { |
|
| 332 | 332 | $setProps[$name] = $value; |
| 333 | 333 | }); |
| 334 | 334 | |
@@ -339,17 +339,17 @@ discard block |
||
| 339 | 339 | #[\PHPUnit\Framework\Attributes\DataProvider('propPatchProvider')] |
| 340 | 340 | public function testPropPatch(string $path, array $existing, array $props, array $result): void { |
| 341 | 341 | $this->server->method('calculateUri') |
| 342 | - ->willReturnCallback(function ($uri) { |
|
| 342 | + ->willReturnCallback(function($uri) { |
|
| 343 | 343 | if (str_starts_with($uri, self::BASE_URI)) { |
| 344 | 344 | return trim(substr($uri, strlen(self::BASE_URI)), '/'); |
| 345 | 345 | } |
| 346 | 346 | return null; |
| 347 | 347 | }); |
| 348 | 348 | $this->tree->method('getNodeForPath') |
| 349 | - ->willReturnCallback(function ($uri) { |
|
| 349 | + ->willReturnCallback(function($uri) { |
|
| 350 | 350 | $node = $this->createMock(Calendar::class); |
| 351 | 351 | $node->method('getOwner') |
| 352 | - ->willReturn('principals/users/' . $this->user->getUID()); |
|
| 352 | + ->willReturn('principals/users/'.$this->user->getUID()); |
|
| 353 | 353 | return $node; |
| 354 | 354 | }); |
| 355 | 355 | |
@@ -371,12 +371,12 @@ discard block |
||
| 371 | 371 | ['foo_bar_path_1337', ['{DAV:}displayname' => 'foo'], ['{DAV:}displayname' => null], []], |
| 372 | 372 | [$longPath, [], ['{DAV:}displayname' => 'anything'], ['{DAV:}displayname' => 'anything']], |
| 373 | 373 | ['principals/users/dummy_user_42', [], ['{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL' => new Href('foo/bar/')], ['{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL' => new Href('foo/bar/')]], |
| 374 | - ['principals/users/dummy_user_42', [], ['{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL' => new Href(self::BASE_URI . 'foo/bar/')], ['{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL' => new Href('foo/bar/')]], |
|
| 374 | + ['principals/users/dummy_user_42', [], ['{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL' => new Href(self::BASE_URI.'foo/bar/')], ['{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL' => new Href('foo/bar/')]], |
|
| 375 | 375 | ]; |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | public function testPropPatchWithUnsuitableCalendar(): void { |
| 379 | - $path = 'principals/users/' . $this->user->getUID(); |
|
| 379 | + $path = 'principals/users/'.$this->user->getUID(); |
|
| 380 | 380 | |
| 381 | 381 | $node = $this->createMock(Calendar::class); |
| 382 | 382 | $node->expects(self::once()) |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | ->willThrowException(new \Sabre\DAV\Exception('Invalid calendar')); |
| 390 | 390 | |
| 391 | 391 | $this->server->method('calculateUri') |
| 392 | - ->willReturnCallback(function ($uri) { |
|
| 392 | + ->willReturnCallback(function($uri) { |
|
| 393 | 393 | if (str_starts_with($uri, self::BASE_URI)) { |
| 394 | 394 | return trim(substr($uri, strlen(self::BASE_URI)), '/'); |
| 395 | 395 | } |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | } |
| 456 | 456 | |
| 457 | 457 | public function testDecodeValueFromDatabaseObjectLegacy(): void { |
| 458 | - $propertyValue = 'O:48:"Sabre\CalDAV\Xml\Property\ScheduleCalendarTransp":1:{s:8:"' . chr(0) . '*' . chr(0) . 'value";s:6:"opaque";}'; |
|
| 458 | + $propertyValue = 'O:48:"Sabre\CalDAV\Xml\Property\ScheduleCalendarTransp":1:{s:8:"'.chr(0).'*'.chr(0).'value";s:6:"opaque";}'; |
|
| 459 | 459 | $propertyType = 3; |
| 460 | 460 | $decodeValue = $this->invokePrivate($this->backend, 'decodeValueFromDatabase', [$propertyValue, $propertyType]); |
| 461 | 461 | $this->assertInstanceOf(\Sabre\CalDAV\Xml\Property\ScheduleCalendarTransp::class, $decodeValue); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | ->method('store') |
| 80 | 80 | ->with( |
| 81 | 81 | 'url', |
| 82 | - $this->callback(function ($generator) { |
|
| 82 | + $this->callback(function($generator) { |
|
| 83 | 83 | self::assertInstanceOf(\Generator::class, $generator); |
| 84 | 84 | $items = iterator_to_array($generator); |
| 85 | 85 | self::assertCount(3, $items); |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | private function expectSequentialCalls(MockObject $mock, string $method, array $expectedCalls): void { |
| 135 | 135 | $mock->expects(self::exactly(\count($expectedCalls))) |
| 136 | 136 | ->method($method) |
| 137 | - ->willReturnCallback(function (...$args) use (&$expectedCalls): void { |
|
| 137 | + ->willReturnCallback(function(...$args) use (&$expectedCalls): void { |
|
| 138 | 138 | $expected = array_shift($expectedCalls); |
| 139 | 139 | self::assertNotNull($expected); |
| 140 | 140 | self::assertSame($expected, $args); |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | $this->cache->expects(self::once()) |
| 238 | 238 | ->method('get') |
| 239 | 239 | ->with('url', 'token', 2, 4) |
| 240 | - ->willReturn((function (): \Generator { |
|
| 240 | + ->willReturn((function(): \Generator { |
|
| 241 | 241 | yield $this->getResponseXmlForFile('/file1', 'File 1'); |
| 242 | 242 | yield $this->getResponseXmlForFile('/file2', 'File 2'); |
| 243 | 243 | })()); |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | |
| 262 | 262 | $response->expects(self::once()) |
| 263 | 263 | ->method('setBody') |
| 264 | - ->with($this->callback(function (string $body) { |
|
| 264 | + ->with($this->callback(function(string $body) { |
|
| 265 | 265 | // header of the XML |
| 266 | 266 | self::assertStringContainsString(<<<XML |
| 267 | 267 | <?xml version="1.0"?> |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | $this->server->httpRequest = $this->request; |
| 326 | 326 | $this->server->httpResponse = $this->response; |
| 327 | 327 | $this->server->xml = new Service(); |
| 328 | - $this->server->xml->namespaceMap = [ 'DAV:' => 'd' ]; |
|
| 328 | + $this->server->xml->namespaceMap = ['DAV:' => 'd']; |
|
| 329 | 329 | |
| 330 | 330 | $this->server->method('getHTTPPrefer') |
| 331 | 331 | ->willReturn(['return' => null]); |