From fa12da2491e072adb075d761923bbb6755400572 Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Sat, 7 Sep 2024 09:21:56 +0200 Subject: [PATCH] fix: Run cs:fix Signed-off-by: Marcel Klehr --- lib/Activity/ActivityPublisher.php | 10 +++++----- lib/BackgroundJobs/BackupJob.php | 2 +- lib/Command/ClearPreviews.php | 2 +- lib/Controller/AdminController.php | 2 +- lib/Controller/BookmarkController.php | 16 ++++++++-------- lib/Controller/FoldersController.php | 6 +++--- lib/Controller/InternalBookmarkController.php | 12 ++++++------ lib/Controller/InternalTagsController.php | 4 ++-- lib/Controller/TagsController.php | 12 ++++++------ lib/Controller/WebViewController.php | 4 ++-- lib/Db/Bookmark.php | 8 +++----- lib/Db/BookmarkMapper.php | 2 +- lib/Db/BookmarkWithTagsAndParent.php | 2 +- lib/Db/TreeMapper.php | 14 +++++++------- lib/ExportResponse.php | 8 ++++---- lib/Flow/Bookmark.php | 2 +- lib/Service/Authorizer.php | 2 +- lib/Service/BookmarkService.php | 8 ++++---- lib/Service/BookmarksParser.php | 6 +++--- lib/Service/CrawlService.php | 4 ++-- lib/Service/FileCache.php | 2 +- .../ScreenshotMachineBookmarkPreviewer.php | 2 +- lib/Service/SettingsService.php | 2 +- lib/Service/TreeCacheManager.php | 6 +++--- lib/Service/UrlNormalizer.php | 2 +- lib/Service/UserSettingsService.php | 6 +++--- tests/BookmarkControllerTest.php | 4 ++-- tests/BookmarkMapperTest.php | 6 +++--- tests/FolderControllerTest.php | 2 +- tests/HtmlImportExportTest.php | 2 +- 30 files changed, 79 insertions(+), 81 deletions(-) diff --git a/lib/Activity/ActivityPublisher.php b/lib/Activity/ActivityPublisher.php index c4a344261c..b0a408d7e3 100644 --- a/lib/Activity/ActivityPublisher.php +++ b/lib/Activity/ActivityPublisher.php @@ -106,7 +106,7 @@ public function publishShare(ChangeEvent $event): void { $activity->setTimestamp(time()); /** - * @var $sharedFolder SharedFolder + * @var SharedFolder $sharedFolder */ try { $sharedFolder = $this->sharedFolderMapper->find($event->getId()); @@ -141,7 +141,7 @@ public function publishFolder(ChangeEvent $event): void { $activity->setTimestamp(time()); /** - * @var $folder Folder + * @var Folder $folder */ try { $folder = $this->folderMapper->find($event->getId()); @@ -163,7 +163,7 @@ public function publishFolder(ChangeEvent $event): void { } /** - * @var $shares SharedFolder[] + * @var SharedFolder[] $shares */ $shares = $this->sharedFolderMapper->findByOwner($this->authorizer->getUserId()); $shares = array_merge($shares, $this->sharedFolderMapper->findByUser($this->authorizer->getUserId())); @@ -193,7 +193,7 @@ public function publishBookmark(ChangeEvent $event): void { $activity->setTimestamp(time()); /** - * @var $bookmark Bookmark + * @var Bookmark $bookmark */ try { $bookmark = $this->bookmarkMapper->find($event->getId()); @@ -213,7 +213,7 @@ public function publishBookmark(ChangeEvent $event): void { } /** - * @var $shares SharedFolder[] + * @var SharedFolder[] $shares */ $shares = $this->sharedFolderMapper->findByOwner($this->authorizer->getUserId()); $shares = array_merge($shares, $this->sharedFolderMapper->findByUser($this->authorizer->getUserId())); diff --git a/lib/BackgroundJobs/BackupJob.php b/lib/BackgroundJobs/BackupJob.php index 1f2fff0fce..49920c077f 100644 --- a/lib/BackgroundJobs/BackupJob.php +++ b/lib/BackgroundJobs/BackupJob.php @@ -45,7 +45,7 @@ public function __construct( } protected function run($argument) { - $userIds = $this->config->getUsersForUserValue('bookmarks', 'backup.enabled', (string) true); // if users have set this in older versions + $userIds = $this->config->getUsersForUserValue('bookmarks', 'backup.enabled', (string)true); // if users have set this in older versions $userIds = array_merge($userIds, $this->config->getUsersForUserValue('bookmarks', 'backup.enabled', 'true')); $userIds = array_unique($userIds); if (empty($userIds)) { diff --git a/lib/Command/ClearPreviews.php b/lib/Command/ClearPreviews.php index c7e1a085bf..2cde814c0e 100644 --- a/lib/Command/ClearPreviews.php +++ b/lib/Command/ClearPreviews.php @@ -36,7 +36,7 @@ protected function configure() { /** * Execute the command * - * @param InputInterface $input + * @param InputInterface $input * @param OutputInterface $output * * @return int diff --git a/lib/Controller/AdminController.php b/lib/Controller/AdminController.php index e4a1906b03..bab6b569c5 100644 --- a/lib/Controller/AdminController.php +++ b/lib/Controller/AdminController.php @@ -54,7 +54,7 @@ public function __construct( */ public function setSetting(string $setting, float|bool|int|string $value): JSONResponse { try { - $this->settingsService->setSetting($setting, (string) $value); + $this->settingsService->setSetting($setting, (string)$value); return new JSONResponse([], Http::STATUS_OK); } catch (\Exception $e) { return new JSONResponse([], Http::STATUS_BAD_REQUEST); diff --git a/lib/Controller/BookmarkController.php b/lib/Controller/BookmarkController.php index 4b3b4b4bad..86e861e785 100644 --- a/lib/Controller/BookmarkController.php +++ b/lib/Controller/BookmarkController.php @@ -193,11 +193,11 @@ private function _getRootFolderId(): ?int { if ($this->authorizer->getToken() !== null) { try { /** - * @var $publicFolder PublicFolder + * @var PublicFolder $publicFolder */ $publicFolder = $this->publicFolderMapper->find($this->authorizer->getToken()); $this->rootFolderId = $publicFolder->getFolderId(); - } catch (DoesNotExistException | MultipleObjectsReturnedException $e) { + } catch (DoesNotExistException|MultipleObjectsReturnedException $e) { $this->logger->error($e->getMessage()."\n".$e->getMessage()); } } @@ -242,7 +242,7 @@ public function getSingleBookmark($id): JSONResponse { } try { /** - * @var $bm Bookmark + * @var Bookmark $bm */ $bm = $this->bookmarkMapper->find($id); } catch (DoesNotExistException $e) { @@ -379,7 +379,7 @@ public function getBookmarks( // If we have this user's permission to see the contents of their folder, simply set the userID // to theirs $userId = $folderEntity->getUserId(); - } catch (DoesNotExistException | MultipleObjectsReturnedException $e) { + } catch (DoesNotExistException|MultipleObjectsReturnedException $e) { return new DataResponse(['status' => 'error', 'data' => ['Not found']], Http::STATUS_BAD_REQUEST); } $params->setFolder($this->toInternalFolderId($folder)); @@ -395,7 +395,7 @@ public function getBookmarks( } else { try { $result = $this->bookmarkMapper->findAllInPublicFolder($this->authorizer->getToken(), $params); - } catch (DoesNotExistException | MultipleObjectsReturnedException $e) { + } catch (DoesNotExistException|MultipleObjectsReturnedException $e) { return new DataResponse(['status' => 'error', 'data' => ['Not found']], Http::STATUS_BAD_REQUEST); } } @@ -527,7 +527,7 @@ public function deleteBookmark($id): JSONResponse { try { $this->bookmarkMapper->find($id); - } catch (DoesNotExistException | MultipleObjectsReturnedException) { + } catch (DoesNotExistException|MultipleObjectsReturnedException) { return new JSONResponse(['status' => 'success']); } @@ -606,7 +606,7 @@ public function getBookmarkImage($id) { return new NotFoundResponse(); } return $this->doImageResponse($image); - } catch (DoesNotExistException | MultipleObjectsReturnedException | Exception $e) { + } catch (DoesNotExistException|MultipleObjectsReturnedException|Exception $e) { return new NotFoundResponse(); } } @@ -633,7 +633,7 @@ public function getBookmarkFavicon($id) { return new NotFoundResponse(); } return $this->doImageResponse($image); - } catch (DoesNotExistException | MultipleObjectsReturnedException | Exception $e) { + } catch (DoesNotExistException|MultipleObjectsReturnedException|Exception $e) { return new NotFoundResponse(); } } diff --git a/lib/Controller/FoldersController.php b/lib/Controller/FoldersController.php index 28c6f432d0..6365041c78 100644 --- a/lib/Controller/FoldersController.php +++ b/lib/Controller/FoldersController.php @@ -85,11 +85,11 @@ private function _getRootFolderId(): ?int { if ($this->authorizer->getToken() !== null) { try { /** - * @var $publicFolder PublicFolder + * @var PublicFolder $publicFolder */ $publicFolder = $this->publicFolderMapper->find($this->authorizer->getToken()); $this->rootFolderId = $publicFolder->getFolderId(); - } catch (DoesNotExistException | MultipleObjectsReturnedException $e) { + } catch (DoesNotExistException|MultipleObjectsReturnedException $e) { $this->logger->error($e->getMessage()."\n".$e->getMessage()); } } @@ -869,7 +869,7 @@ public function deleteShare(int $shareId): DataResponse { try { $this->folders->deleteShare($shareId); - } catch (UnsupportedOperation | DoesNotExistException | MultipleObjectsReturnedException | Exception $e) { + } catch (UnsupportedOperation|DoesNotExistException|MultipleObjectsReturnedException|Exception $e) { return new Http\DataResponse(['status' => 'error', 'data' => ['Internal error']], Http::STATUS_INTERNAL_SERVER_ERROR); } return new Http\DataResponse(['status' => 'success']); diff --git a/lib/Controller/InternalBookmarkController.php b/lib/Controller/InternalBookmarkController.php index 8d55c09fcb..27a171ef32 100644 --- a/lib/Controller/InternalBookmarkController.php +++ b/lib/Controller/InternalBookmarkController.php @@ -66,8 +66,8 @@ public function __construct( public function getBookmarks( $page = 0, $tags = [], - $conjunction = "or", - $sortby = "", + $conjunction = 'or', + $sortby = '', $search = [], $limit = 10, $untagged = false, @@ -103,7 +103,7 @@ public function getSingleBookmark($id): JSONResponse { * * @NoAdminRequired */ - public function newBookmark($url = "", $title = null, $description = null, $tags = null, $folders = [], $target = null): JSONResponse { + public function newBookmark($url = '', $title = null, $description = null, $tags = null, $folders = [], $target = null): JSONResponse { return $this->publicController->newBookmark($url, $title, $description, $tags, $folders, $target); } @@ -119,7 +119,7 @@ public function newBookmark($url = "", $title = null, $description = null, $tags * * @NoAdminRequired */ - public function editBookmark($id = null, $url = null, $title = null, $description = "", $tags = [], $folders = null, $target = null): JSONResponse { + public function editBookmark($id = null, $url = null, $title = null, $description = '', $tags = [], $folders = null, $target = null): JSONResponse { return $this->publicController->editBookmark($id, $url, $title, $description, $tags, $folders, $target); } @@ -141,7 +141,7 @@ public function deleteBookmark($id = -1): JSONResponse { public function deleteAllBookmarks(): DataResponse { try { $this->bookmarks->deleteAll($this->userId); - } catch (UnsupportedOperation | DoesNotExistException | MultipleObjectsReturnedException $e) { + } catch (UnsupportedOperation|DoesNotExistException|MultipleObjectsReturnedException $e) { return new DataResponse(['status' => 'error', 'data' => ['Internal server error']], Http::STATUS_INTERNAL_SERVER_ERROR); } return new DataResponse(['status' => 'success']); @@ -153,7 +153,7 @@ public function deleteAllBookmarks(): DataResponse { * @return JSONResponse * @NoAdminRequired */ - public function clickBookmark($url = ""): JSONResponse { + public function clickBookmark($url = ''): JSONResponse { return $this->publicController->clickBookmark($url); } diff --git a/lib/Controller/InternalTagsController.php b/lib/Controller/InternalTagsController.php index 77c1880fb5..215243b130 100644 --- a/lib/Controller/InternalTagsController.php +++ b/lib/Controller/InternalTagsController.php @@ -24,7 +24,7 @@ public function __construct($appName, $request, TagsController $publicController * * @NoAdminRequired */ - public function deleteTag($old_name = ""): JSONResponse { + public function deleteTag($old_name = ''): JSONResponse { return $this->publicController->deleteTag($old_name); } @@ -36,7 +36,7 @@ public function deleteTag($old_name = ""): JSONResponse { * * @NoAdminRequired */ - public function renameTag($old_name = "", $new_name = "", $name = ''): JSONResponse { + public function renameTag($old_name = '', $new_name = '', $name = ''): JSONResponse { return $this->publicController->renameTag($old_name, $new_name, $name); } diff --git a/lib/Controller/TagsController.php b/lib/Controller/TagsController.php index e188c582db..c10aa51101 100644 --- a/lib/Controller/TagsController.php +++ b/lib/Controller/TagsController.php @@ -34,8 +34,8 @@ public function __construct($appName, $request, $userId, DB\TagMapper $tagMapper * @NoCSRFRequired * */ - public function deleteTag($old_name = ""): JSONResponse { - if ($old_name === "") { + public function deleteTag($old_name = ''): JSONResponse { + if ($old_name === '') { return new JSONResponse([], Http::STATUS_BAD_REQUEST); } @@ -53,12 +53,12 @@ public function deleteTag($old_name = ""): JSONResponse { * @NoCSRFRequired * */ - public function renameTag($old_name = "", $new_name = "", $name = ''): JSONResponse { + public function renameTag($old_name = '', $new_name = '', $name = ''): JSONResponse { if ($new_name === '') { $new_name = $name; } - if ($old_name === "" || $new_name === "") { + if ($old_name === '' || $new_name === '') { return new JSONResponse(['status' => 'error', 'data' => ['Must provide old_name and a new name']], Http::STATUS_BAD_REQUEST); } @@ -74,8 +74,8 @@ public function renameTag($old_name = "", $new_name = "", $name = ''): JSONRespo * */ public function fullTags($count = false): JSONResponse { - header("Cache-Control: no-cache, must-revalidate"); - header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); + header('Cache-Control: no-cache, must-revalidate'); + header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); if ($count === true) { $tags = $this->tagMapper->findAllWithCount($this->userId); diff --git a/lib/Controller/WebViewController.php b/lib/Controller/WebViewController.php index b8dadc904d..5904c9fb2c 100644 --- a/lib/Controller/WebViewController.php +++ b/lib/Controller/WebViewController.php @@ -114,11 +114,11 @@ public function link(string $token) { $userName = 'Unknown'; try { /** - * @var $publicFolder PublicFolder + * @var PublicFolder $publicFolder */ $publicFolder = $this->publicFolderMapper->find($token); /** - * @var $folder Folder + * @var Folder $folder */ $folder = $this->folderMapper->find($publicFolder->getFolderId()); $title = $folder->getTitle(); diff --git a/lib/Db/Bookmark.php b/lib/Db/Bookmark.php index fe24db1224..3eeee6482b 100644 --- a/lib/Db/Bookmark.php +++ b/lib/Db/Bookmark.php @@ -29,8 +29,6 @@ * @method setAvailable(boolean $available) * @method int getArchivedFile() * @method setArchivedFile(int $fileId) - * @method string getTextContent() - * @method string getHtmlContent() * @method string getUserId() * @method setUserId(string $userId) */ @@ -133,7 +131,7 @@ public function setTextContent(?string $content): void { public function getTextContent(): string { // Remove non-utf-8 characters from string: https://stackoverflow.com/questions/1401317/remove-non-utf8-characters-from-string - return (string) mb_convert_encoding($this->textContent, 'UTF-8', 'UTF-8'); + return (string)mb_convert_encoding($this->textContent, 'UTF-8', 'UTF-8'); } public function setHtmlContent(?string $content): void { @@ -146,10 +144,10 @@ public function setHtmlContent(?string $content): void { public function getHtmlContent(): string { // Remove non-utf-8 characters from string: https://stackoverflow.com/questions/1401317/remove-non-utf8-characters-from-string - return (string) mb_convert_encoding($this->htmlContent, 'UTF-8', 'UTF-8'); + return (string)mb_convert_encoding($this->htmlContent, 'UTF-8', 'UTF-8'); } public function isWebLink() { - return (bool) preg_match('/^https?:/i', $this->getUrl()); + return (bool)preg_match('/^https?:/i', $this->getUrl()); } } diff --git a/lib/Db/BookmarkMapper.php b/lib/Db/BookmarkMapper.php index 50f7f94874..3e4437e94c 100644 --- a/lib/Db/BookmarkMapper.php +++ b/lib/Db/BookmarkMapper.php @@ -453,7 +453,7 @@ private function _filterDuplicated(IQueryBuilder $qb, QueryParameters $params) { if ($params->getDuplicated()) { $subQuery = $this->db->getQueryBuilder(); $subQuery->select('trdup.parent_folder') - ->from('*PREFIX*bookmarks_tree', 'trdup') + ->from('*PREFIX*bookmarks_tree', 'trdup') ->where($subQuery->expr()->eq('b.id', 'trdup.id')) ->andWhere($subQuery->expr()->neq('trdup.parent_folder', 'tree.parent_folder')) ->andWhere($subQuery->expr()->eq('trdup.type', $qb->createPositionalParameter(TreeMapper::TYPE_BOOKMARK))); diff --git a/lib/Db/BookmarkWithTagsAndParent.php b/lib/Db/BookmarkWithTagsAndParent.php index 84fab5d2e5..4566090c2d 100644 --- a/lib/Db/BookmarkWithTagsAndParent.php +++ b/lib/Db/BookmarkWithTagsAndParent.php @@ -34,7 +34,7 @@ public function toArray(): array { $array[$field] = []; } else { $array[$field] = array_values(array_unique(array_map(static function ($id) { - return (int) $id; + return (int)$id; }, explode(',', $this->{$field})))); } continue; diff --git a/lib/Db/TreeMapper.php b/lib/Db/TreeMapper.php index ceac7c5a5d..7d3db5643b 100644 --- a/lib/Db/TreeMapper.php +++ b/lib/Db/TreeMapper.php @@ -221,11 +221,11 @@ protected function getGetChildrenOrderQuery(): IQueryBuilder { protected function getFindChildrenQuery(string $type): IQueryBuilder { $qb = $this->selectFromType($type); $qb - ->join('i', 'bookmarks_tree', 't', $qb->expr()->eq('t.id', 'i.id')) - ->where($qb->expr()->eq('t.parent_folder', $qb->createParameter('parent_folder'))) - ->andWhere($qb->expr()->eq('t.type', $qb->createNamedParameter($type))) - ->andWhere($qb->expr()->isNull('t.soft_deleted_at')) - ->orderBy('t.index', 'ASC'); + ->join('i', 'bookmarks_tree', 't', $qb->expr()->eq('t.id', 'i.id')) + ->where($qb->expr()->eq('t.parent_folder', $qb->createParameter('parent_folder'))) + ->andWhere($qb->expr()->eq('t.type', $qb->createNamedParameter($type))) + ->andWhere($qb->expr()->isNull('t.soft_deleted_at')) + ->orderBy('t.index', 'ASC'); return $qb; } @@ -1137,7 +1137,7 @@ public function changeFolderOwner(Folder $folder, $userId): void { * @param int $folderId * @param Share $share * @return boolean - *@throws MultipleObjectsReturnedException + * @throws MultipleObjectsReturnedException */ public function isFolderSharedWithUser(int $folderId, string $userId): bool { try { @@ -1216,7 +1216,7 @@ public function deleteOldTrashbinItems(int $limit, float|int $maxAge): void { $this->logger->error('Could not query for old trash bin items', ['exception' => $e]); return; } - while($row = $result->fetch()) { + while ($row = $result->fetch()) { try { $this->deleteEntry($row['type'], $row['id'], $row['parent_folder']); } catch (DoesNotExistException $e) { diff --git a/lib/ExportResponse.php b/lib/ExportResponse.php index 0dc0737817..6564ad1f02 100644 --- a/lib/ExportResponse.php +++ b/lib/ExportResponse.php @@ -33,10 +33,10 @@ public function __construct($returnstring) { $dateTime = OC::$server->getDateTimeFormatter(); $export_name = '"' . $productName . ' Bookmarks (' . $userName . ') (' . $dateTime->formatDate(time()) . ').html"'; - $this->addHeader("Cache-Control", "private"); - $this->addHeader("Content-Type", " application/stream"); - $this->addHeader("Content-Length", strlen($returnstring)); - $this->addHeader("Content-Disposition", "attachment; filename=" . $export_name); + $this->addHeader('Cache-Control', 'private'); + $this->addHeader('Content-Type', ' application/stream'); + $this->addHeader('Content-Length', strlen($returnstring)); + $this->addHeader('Content-Disposition', 'attachment; filename=' . $export_name); $this->returnstring = $returnstring; } diff --git a/lib/Flow/Bookmark.php b/lib/Flow/Bookmark.php index d077b6be84..be315f9ced 100644 --- a/lib/Flow/Bookmark.php +++ b/lib/Flow/Bookmark.php @@ -104,7 +104,7 @@ public function prepareRuleMatcher(IRuleMatcher $ruleMatcher, string $eventName, } try { $this->bookmark = $this->bookmarkMapper->find($event->getId()); - } catch (DoesNotExistException | MultipleObjectsReturnedException $e) { + } catch (DoesNotExistException|MultipleObjectsReturnedException $e) { return; } $ruleMatcher->setEntitySubject($this, $this->bookmark); diff --git a/lib/Service/Authorizer.php b/lib/Service/Authorizer.php index ef68d36f9b..406cce3d5b 100644 --- a/lib/Service/Authorizer.php +++ b/lib/Service/Authorizer.php @@ -197,7 +197,7 @@ protected function getMaskFromFlags($canWrite, $canShare): int { * @return boolean */ public static function hasPermission(int $perm, int $perms): bool { - return (boolean)($perms & $perm); + return (bool)($perms & $perm); } /** diff --git a/lib/Service/BookmarkService.php b/lib/Service/BookmarkService.php index 00541ad4e7..d811b05566 100644 --- a/lib/Service/BookmarkService.php +++ b/lib/Service/BookmarkService.php @@ -137,7 +137,7 @@ public function create(string $userId, string $url = '', ?string $title = null, $bookmark = null; $ownFolders = array_filter($folders, function ($folderId) use ($userId) { /** - * @var $folder Folder + * @var Folder $folder */ $folder = $this->folderMapper->find($folderId); return $folder->getUserId() === $userId; @@ -145,7 +145,7 @@ public function create(string $userId, string $url = '', ?string $title = null, $foreignFolders = array_diff($folders, $ownFolders); foreach ($foreignFolders as $folderId) { /** - * @var $folder Folder + * @var Folder $folder */ $folder = $this->folderMapper->find($folderId); $bookmark = $this->_addBookmark($folder->getUserId(), $url, $title, $description, $tags, [$folder->getId()]); @@ -275,7 +275,7 @@ private function _addBookmark($userId, $url, ?string $title = null, ?string $des */ public function update(string $userId, int $id, ?string $url = null, ?string $title = null, ?string $description = null, ?array $tags = null, ?array $folders = null): ?Bookmark { /** - * @var $bookmark Bookmark + * @var Bookmark $bookmark */ $bookmark = $this->bookmarkMapper->find($id); @@ -333,7 +333,7 @@ public function update(string $userId, int $id, ?string $url = null, ?string $ti } /** - * @var $currentOwnFolders Folder[] + * @var Folder[] $currentOwnFolders */ $currentOwnFolders = $this->treeMapper->findParentsOf(TreeMapper::TYPE_BOOKMARK, $bookmark->getId()); // Updating user may not be the owner of the bookmark diff --git a/lib/Service/BookmarksParser.php b/lib/Service/BookmarksParser.php index e9b14ed537..afbef6eafb 100644 --- a/lib/Service/BookmarksParser.php +++ b/lib/Service/BookmarksParser.php @@ -107,7 +107,7 @@ public static function isValid($doctype): bool { * @param bool $includeFolderTags If we should include folter tags * @param bool $useDateTimeObjects If we should return \DateTime objects * - * @return mixed A PHP value + * @return mixed A PHP value * * @throws HtmlParseError */ @@ -271,9 +271,9 @@ private function getAttributes(DOMNode $node): array { if ((int)$attributes['add_date'] > self::THOUSAND_YEARS) { // Google exports dates in miliseconds. This way we only lose the first year of UNIX Epoch. // This is invalid once we hit 2970. So, quite a long time. - $added->setTimestamp((int) ($attributes['add_date'] / 1000)); + $added->setTimestamp((int)($attributes['add_date'] / 1000)); } else { - $added->setTimestamp((int) $attributes['add_date']); + $added->setTimestamp((int)$attributes['add_date']); } $attributes['add_date'] = $added; } diff --git a/lib/Service/CrawlService.php b/lib/Service/CrawlService.php index bff108aa55..30473b9c65 100644 --- a/lib/Service/CrawlService.php +++ b/lib/Service/CrawlService.php @@ -77,7 +77,7 @@ public function crawl(Bookmark $bookmark): void { if ($available) { $this->userSettingsService->setUserId($bookmark->getUserId()); - if (((boolean) $this->userSettingsService->get('archive.enabled')) === true) { + if (((bool)$this->userSettingsService->get('archive.enabled')) === true) { $this->archiveFile($bookmark, $resp); $this->archiveContent($bookmark, $resp); } @@ -148,7 +148,7 @@ private function archiveFile(Bookmark $bookmark, Response $resp): void { $file->putContent($resp->getBody()); $bookmark->setArchivedFile($file->getId()); $this->bookmarkMapper->update($bookmark); - } catch (NotPermittedException | NoUserException | GenericFileException | LockedException | UrlParseError | InvalidPathException | NotFoundException $e) { + } catch (NotPermittedException|NoUserException|GenericFileException|LockedException|UrlParseError|InvalidPathException|NotFoundException $e) { $this->logger->debug(get_class($e) . ' ' . $e->getMessage() . "\r\n" . $e->getTraceAsString()); } } diff --git a/lib/Service/FileCache.php b/lib/Service/FileCache.php index 36110b2481..80825229f2 100644 --- a/lib/Service/FileCache.php +++ b/lib/Service/FileCache.php @@ -131,7 +131,7 @@ public function hasKey($key) { * @throws NotPermittedException */ public function remove($key) { - return (boolean) $this->getStorage()->getFile($key)->delete(); + return (bool)$this->getStorage()->getFile($key)->delete(); } /** diff --git a/lib/Service/Previewers/ScreenshotMachineBookmarkPreviewer.php b/lib/Service/Previewers/ScreenshotMachineBookmarkPreviewer.php index 815ff37dc1..0b6cadc7a3 100644 --- a/lib/Service/Previewers/ScreenshotMachineBookmarkPreviewer.php +++ b/lib/Service/Previewers/ScreenshotMachineBookmarkPreviewer.php @@ -78,7 +78,7 @@ public function fetchImage($url): ?Image { try { // get it $response = $this->client->get( - "https://api.screenshotmachine.com/?key=". $this->apiKey . "&dimension=" . $this->width . "x" . $this->height . "&device=desktop&delay=2000&format=jpg&url=" . $url, + 'https://api.screenshotmachine.com/?key='. $this->apiKey . '&dimension=' . $this->width . 'x' . $this->height . '&device=desktop&delay=2000&format=jpg&url=' . $url, [ 'timeout' => self::HTTP_TIMEOUT, ] diff --git a/lib/Service/SettingsService.php b/lib/Service/SettingsService.php index 73acbd7080..37dc467584 100644 --- a/lib/Service/SettingsService.php +++ b/lib/Service/SettingsService.php @@ -12,7 +12,7 @@ use OCP\AppFramework\Services\IAppConfig; class SettingsService { - /** @var array */ + /** @var array */ public const DEFAULTS = [ 'previews.screenly.url' => '', 'previews.screenly.token' => '', diff --git a/lib/Service/TreeCacheManager.php b/lib/Service/TreeCacheManager.php index afafe8378b..16c06eda8b 100644 --- a/lib/Service/TreeCacheManager.php +++ b/lib/Service/TreeCacheManager.php @@ -145,7 +145,7 @@ public function invalidateFolder(int $folderId, array $previousFolders = []): vo try { $parentFolder = $this->getTreeMapper()->findParentOf(TreeMapper::TYPE_FOLDER, $folderId); $this->invalidateFolder($parentFolder->getId(), $previousFolders); - } catch (DoesNotExistException | MultipleObjectsReturnedException $e) { + } catch (DoesNotExistException|MultipleObjectsReturnedException $e) { return; } @@ -155,7 +155,7 @@ public function invalidateFolder(int $folderId, array $previousFolders = []): vo try { $parentFolder = $this->getTreeMapper()->findParentOf(TreeMapper::TYPE_SHARE, $sharedFolder->getId()); $this->invalidateFolder($parentFolder->getId(), $previousFolders); - } catch (DoesNotExistException | MultipleObjectsReturnedException $e) { + } catch (DoesNotExistException|MultipleObjectsReturnedException $e) { continue; } } @@ -288,7 +288,7 @@ public function setInvalidationEnabled(bool $enabled): void { } public function invalidateAll() { - foreach($this->caches as $cache) { + foreach ($this->caches as $cache) { $cache->clear(); } } diff --git a/lib/Service/UrlNormalizer.php b/lib/Service/UrlNormalizer.php index 578759603e..36c7e6302d 100644 --- a/lib/Service/UrlNormalizer.php +++ b/lib/Service/UrlNormalizer.php @@ -12,7 +12,7 @@ use Rowbot\URL\URL; class UrlNormalizer { - /** @var array */ + /** @var array */ private $cache = []; public function __construct() { diff --git a/lib/Service/UserSettingsService.php b/lib/Service/UserSettingsService.php index 03d953df43..17451aa6f7 100644 --- a/lib/Service/UserSettingsService.php +++ b/lib/Service/UserSettingsService.php @@ -45,7 +45,7 @@ public function get(string $key): string { return $this->config->getAppValue('bookmarks', 'performance.maxBookmarksperAccount', '0'); } if ($key === 'archive.enabled') { - $default = (string) true; + $default = (string)true; } if ($key === 'privacy.enableScraping') { return $this->config->getAppValue($this->appName, 'privacy.enableScraping', 'false'); @@ -54,7 +54,7 @@ public function get(string $key): string { $default = $this->l->t('Bookmarks'); } if ($key === 'backup.enabled') { - $default = (string) false; + $default = (string)false; } if ($key === 'backup.filePath') { $default = $this->l->t('Bookmarks Backups'); @@ -96,7 +96,7 @@ public function set(string $key, string $value): void { */ public function toArray(): array { $array = []; - foreach(self::KEYS as $key) { + foreach (self::KEYS as $key) { $array[$key] = $this->get($key); } $array['limit'] = $this->get('limit'); diff --git a/tests/BookmarkControllerTest.php b/tests/BookmarkControllerTest.php index 59f277b4e5..90fdeaf7f7 100644 --- a/tests/BookmarkControllerTest.php +++ b/tests/BookmarkControllerTest.php @@ -300,7 +300,7 @@ public function testRead(): void { $output = $this->controller->getSingleBookmark($this->bookmark2Id); $data = $output->getData(); $this->assertEquals('success', $data['status'], var_export($data, true)); - $this->assertEquals("https://9gag.com/", $data['item']['url']); + $this->assertEquals('https://9gag.com/', $data['item']['url']); } /** @@ -685,7 +685,7 @@ public function testEditBookmarkShared(): void { $bookmark = $this->bookmarkMapper->find($id); $this->assertEquals('https://www.heise.de/', $bookmark->getUrl()); // normalized URL - $this->assertEquals("", $bookmark->getTitle()); + $this->assertEquals('', $bookmark->getTitle()); } /** diff --git a/tests/BookmarkMapperTest.php b/tests/BookmarkMapperTest.php index e8068b53a8..bfb85b274a 100644 --- a/tests/BookmarkMapperTest.php +++ b/tests/BookmarkMapperTest.php @@ -79,8 +79,8 @@ public function testInsertAndFind(Entity $bookmark) { $bookmark = $this->bookmarkMapper->insert($bookmark); $foundEntity = $this->bookmarkMapper->find($bookmark->getId()); $this->assertSame($bookmark->getUrl(), $foundEntity->getUrl()); - $this->assertSame((string) $bookmark->getTitle(), (string) $foundEntity->getTitle()); - $this->assertSame((string) $bookmark->getDescription(), (string) $foundEntity->getDescription()); + $this->assertSame((string)$bookmark->getTitle(), (string)$foundEntity->getTitle()); + $this->assertSame((string)$bookmark->getDescription(), (string)$foundEntity->getDescription()); } /** @@ -102,7 +102,7 @@ public function testUpdate(Entity $bookmark) { $entity->setTitle('foobar'); $this->bookmarkMapper->update($entity); $foundEntity = $this->bookmarkMapper->find($entity->getId()); - $this->assertSame((string) $entity->getTitle(), (string) $foundEntity->getTitle()); + $this->assertSame((string)$entity->getTitle(), (string)$foundEntity->getTitle()); } /** diff --git a/tests/FolderControllerTest.php b/tests/FolderControllerTest.php index 18549e206f..19d428bf90 100644 --- a/tests/FolderControllerTest.php +++ b/tests/FolderControllerTest.php @@ -270,7 +270,7 @@ public function testHash(bool $useCache): void { $this->cacheFactory->method('createDistributed') ->willReturnCallback(fn () => OC::$server->get(ICacheFactory::class) - ->createDistributed(time() . '' . random_int(0, 1000000)) + ->createDistributed(time() . '' . random_int(0, 1000000)) ); } diff --git a/tests/HtmlImportExportTest.php b/tests/HtmlImportExportTest.php index 4fa6de0004..0ee4e10b09 100644 --- a/tests/HtmlImportExportTest.php +++ b/tests/HtmlImportExportTest.php @@ -103,7 +103,7 @@ public function testImportFile(string $file): void { $this->assertCount(1, $this->treeMapper->findChildren(Db\TreeMapper::TYPE_BOOKMARK, $result['imported'][4]['id'])); /** - * @var $firstBookmark Db\Bookmark + * @var Db\Bookmark $firstBookmark */ $firstBookmark = $this->bookmarkMapper->find($result['imported'][0]['children'][0]['id']); $this->assertSame('Title 0', $firstBookmark->getTitle());