diff --git a/composer.json b/composer.json index 06b2c861..389f4584 100644 --- a/composer.json +++ b/composer.json @@ -28,10 +28,16 @@ "optimize-autoloader": true, "classmap-authoritative": true }, + "autoload": { + "psr-4": { + "OCA\\Bookmarks\\": "lib/" + } + }, "scripts": { "lint": "find . -name \\*.php -not -path './vendor/*' -print0 | xargs -0 -n1 php -l", "cs:check": "php-cs-fixer fix --dry-run --diff", "cs:fix": "php-cs-fixer fix", - "psalm": "psalm --output-format=github --no-progress --show-info=true" + "psalm": "psalm --output-format=github --no-progress --no-cache", + "psalm-ui": "psalm --no-cache" } } diff --git a/lib/Controller/BookmarkController.php b/lib/Controller/BookmarkController.php index 8d9c89c0..a1b10ccd 100644 --- a/lib/Controller/BookmarkController.php +++ b/lib/Controller/BookmarkController.php @@ -236,7 +236,7 @@ class BookmarkController extends ApiController { /** * @param int $page - * @param null $tags + * @param string[] $tags * @param string $conjunction * @param string $sortby * @param array $search diff --git a/lib/Db/Bookmark.php b/lib/Db/Bookmark.php index b34a04e5..f9c78d75 100644 --- a/lib/Db/Bookmark.php +++ b/lib/Db/Bookmark.php @@ -13,25 +13,24 @@ use OCP\AppFramework\Db\Entity; * Class Bookmark * * @package OCA\Bookmarks\Db - * @method getUrl + * @method string getUrl() * @method setUrl(string $url) - * @method getTitle - * @method setTitle(string $title) - * @method getDescription + * @method string getTitle() + * @method string getDescription() * @method setDescription(string $description) - * @method getLastmodified + * @method int getLastmodified() * @method setLastmodified(int $lastmodified) - * @method getAdded + * @method int getAdded() * @method setAdded(int $added) - * @method getClickcount + * @method int getClickcount * @method setClickcount(int $count) - * @method getLastPreview + * @method int getLastPreview() * @method setLastPreview(int $lastpreview) - * @method getAvailable + * @method bool getAvailable() * @method setAvailable(boolean $available) - * @method getArchivedFile + * @method int getArchivedFile() * @method setArchivedFile(int $fileId) - * @method getUserId + * @method string getUserId() * @method setUserId(string $userId) */ class Bookmark extends Entity { @@ -94,6 +93,6 @@ class Bookmark extends Entity { if (mb_strlen($title) > 255) { $title = mb_substr($title, 0, 254) . '…'; } - parent::setTitle($title); + $this->setter('title', [$title]); } } diff --git a/lib/Db/BookmarkMapper.php b/lib/Db/BookmarkMapper.php index 7e79d91b..6b8b7f9c 100644 --- a/lib/Db/BookmarkMapper.php +++ b/lib/Db/BookmarkMapper.php @@ -197,15 +197,9 @@ class BookmarkMapper extends QBMapper { $qb ->from('bookmarks', 'b') - ->leftJoin('b', 'bookmarks_tree', 'tr', $qb->expr()->andX( - $qb->expr()->eq('tr.id', 'b.id'), - $qb->expr()->eq('tr.type', $qb->createPositionalParameter(TreeMapper::TYPE_BOOKMARK)) - )) + ->leftJoin('b', 'bookmarks_tree', 'tr', 'tr.id = b.id AND tr.type = '.$qb->createPositionalParameter(TreeMapper::TYPE_BOOKMARK)) ->leftJoin('tr', 'bookmarks_shared_folders', 'sf', $qb->expr()->eq('tr.parent_folder', 'sf.folder_id')) - ->leftJoin('tr', 'bookmarks_tree', 'tr2', $qb->expr()->andX( - $qb->expr()->eq('tr2.id', 'tr.parent_folder'), - $qb->expr()->eq('tr2.type', $qb->createPositionalParameter(TreeMapper::TYPE_FOLDER)) - )) + ->leftJoin('tr', 'bookmarks_tree', 'tr2', 'tr2.id = tr.parent_folder AND tr2.type = '. $qb->createPositionalParameter(TreeMapper::TYPE_FOLDER)) ->leftJoin('tr2', 'bookmarks_shared_folders', 'sf2', $qb->expr()->eq('tr2.parent_folder', 'sf.folder_id')) ->where( $qb->expr()->orX( @@ -394,10 +388,7 @@ class BookmarkMapper extends QBMapper { $qb ->from('bookmarks', 'b') - ->leftJoin('b', 'bookmarks_tree', 'tr', $qb->expr()->andX( - $qb->expr()->eq('b.id', 'tr.id'), - $qb->expr()->eq('tr.type', $qb->createPositionalParameter(TreeMapper::TYPE_BOOKMARK)) - )) + ->leftJoin('b', 'bookmarks_tree', 'tr', 'b.id = tr.id AND tr.type = '.$qb->createPositionalParameter(TreeMapper::TYPE_BOOKMARK)) ->leftJoin('tr', 'bookmarks_shared_folders', 'sf', $qb->expr()->eq('tr.parent_folder', 'sf.folder_id')) ->where($qb->expr()->orX( $qb->expr()->eq('b.user_id', $qb->createPositionalParameter($userId)), @@ -418,10 +409,7 @@ class BookmarkMapper extends QBMapper { $qb ->from('bookmarks', 'b') - ->leftJoin('b', 'bookmarks_tree', 'tr', $qb->expr()->andX( - $qb->expr()->eq('b.id', 'tr.id'), - $qb->expr()->eq('tr.type', $qb->createPositionalParameter(TreeMapper::TYPE_BOOKMARK)) - )) + ->leftJoin('b', 'bookmarks_tree', 'tr', 'b.id = tr.id AND tr.type = '.$qb->createPositionalParameter(TreeMapper::TYPE_BOOKMARK)) ->leftJoin('tr', 'bookmarks_shared_folders', 'sf', $qb->expr()->eq('tr.parent_folder', 'sf.folder_id')) ->where($qb->expr()->orX( $qb->expr()->eq('b.user_id', $qb->createPositionalParameter($userId)), @@ -463,14 +451,8 @@ class BookmarkMapper extends QBMapper { $qb ->from('bookmarks', 'b') - ->leftJoin('b', 'bookmarks_tree', 'tr', $qb->expr()->andX( - $qb->expr()->eq('tr.id', 'b.id'), - $qb->expr()->eq('tr.type', $qb->createPositionalParameter(TreeMapper::TYPE_BOOKMARK)) - )) - ->leftJoin('tr', 'bookmarks_tree', 'tr2', $qb->expr()->andX( - $qb->expr()->eq('tr2.id', 'tr.parent_folder'), - $qb->expr()->eq('tr2.type', $qb->createPositionalParameter(TreeMapper::TYPE_FOLDER)) - )) + ->leftJoin('b', 'bookmarks_tree', 'tr', 'tr.id = b.id AND tr.type = '.$qb->createPositionalParameter(TreeMapper::TYPE_BOOKMARK)) + ->leftJoin('tr', 'bookmarks_tree', 'tr2', 'tr2.id = tr.parent_folder AND tr2.type = '.$qb->createPositionalParameter(TreeMapper::TYPE_FOLDER)) ->where( $qb->expr()->orX( $qb->expr()->eq('tr.parent_folder', $qb->createPositionalParameter($publicFolder->getFolderId(), IQueryBuilder::PARAM_INT)), @@ -635,10 +617,7 @@ class BookmarkMapper extends QBMapper { * @param IQueryBuilder $qb */ private function _selectFolders(IQueryBuilder $qb): void { - $qb->leftJoin('b', 'bookmarks_tree', 'tree', $qb->expr()->andX( - $qb->expr()->eq('b.id', 'tree.id'), - $qb->expr()->eq('tree.type', $qb->createPositionalParameter(TreeMapper::TYPE_BOOKMARK)) - )); + $qb->leftJoin('b', 'bookmarks_tree', 'tree', 'b.id =tree.id AND tree.type = '.$qb->createPositionalParameter(TreeMapper::TYPE_BOOKMARK)); if ($this->getDbType() === 'pgsql') { $folders = $qb->createFunction('array_to_string(array_agg(' . $qb->getColumnName('tree.parent_folder') . "), ',')"); } else { diff --git a/lib/Db/Folder.php b/lib/Db/Folder.php index 25e36b5c..a39055bf 100644 --- a/lib/Db/Folder.php +++ b/lib/Db/Folder.php @@ -13,9 +13,9 @@ use OCP\AppFramework\Db\Entity; * Class Folder * * @package OCA\Bookmarks\Db - * @method getTitle() + * @method string getTitle() * @method setTitle(string $title) - * @method getUserId + * @method string getUserId() * @method setUserId(string $userId) */ class Folder extends Entity { @@ -27,10 +27,6 @@ class Folder extends Entity { * @var string */ protected $userId; - /** - * @var int - */ - protected $index; public static $columns = ['id', 'title', 'user_id']; diff --git a/lib/Db/PublicFolder.php b/lib/Db/PublicFolder.php index 27662d61..c7d7f536 100644 --- a/lib/Db/PublicFolder.php +++ b/lib/Db/PublicFolder.php @@ -14,14 +14,19 @@ use OCP\AppFramework\Db\Entity; * * @package OCA\Bookmarks\Db * - * @method getFolderId() + * @method string getId() + * @method int getFolderId() * @method setFolderId(int $folderId) - * @method getDescription + * @method string getDescription() * @method setDescription(string $description) - * @method getCreatedAt + * @method int getCreatedAt() * @method setCreatedAt(int $createdAt) */ class PublicFolder extends Entity { + /** + * @var string + */ + public $id; protected $folderId; protected $description; protected $createdAt; diff --git a/lib/Db/Share.php b/lib/Db/Share.php index f889b56a..522bd0f1 100644 --- a/lib/Db/Share.php +++ b/lib/Db/Share.php @@ -14,19 +14,19 @@ use OCP\AppFramework\Db\Entity; * * @package OCA\Bookmarks\Db * - * @method getFolderId + * @method int getFolderId() * @method setFolderId(int $folderId) - * @method getOwner + * @method string getOwner() * @method setOwner(string $owner) - * @method getParticipant + * @method string getParticipant * @method setParticipant(string $participant) - * @method getType + * @method string getType() * @method setType(string $type) - * @method getCanWrite + * @method bool getCanWrite() * @method setCanWrite(bool $canWrite) - * @method getCanShare + * @method bool getCanShare() * @method setCanShare(bool $canShare) - * @method getCreatedAt + * @method int getCreatedAt() * @method setCreatedAt(int $createdAt) */ class Share extends Entity { diff --git a/lib/Db/SharedFolder.php b/lib/Db/SharedFolder.php index 32c41e74..18519486 100644 --- a/lib/Db/SharedFolder.php +++ b/lib/Db/SharedFolder.php @@ -14,12 +14,12 @@ use OCP\AppFramework\Db\Entity; * * @package OCA\Bookmarks\Db * - * @method getShareId + * @method int getShareId() * @method setFolderId(int $shareId) - * @method getFolderId() - * @method getUserId + * @method int getFolderId() + * @method string getUserId() * @method setUserId(string $userId) - * @method getTitle + * @method string getTitle() * @method setTitle(string $title) */ class SharedFolder extends Entity { diff --git a/lib/Db/TagMapper.php b/lib/Db/TagMapper.php index 3c0ca6f1..cbb40d06 100644 --- a/lib/Db/TagMapper.php +++ b/lib/Db/TagMapper.php @@ -44,10 +44,7 @@ class TagMapper { ->selectAlias($qb->createFunction('COUNT(DISTINCT ' . $qb->getColumnName('t.bookmark_id') . ')'), 'count') ->from('bookmarks_tags', 't') ->innerJoin('t', 'bookmarks', 'b', $qb->expr()->eq('b.id', 't.bookmark_id')) - ->leftJoin('b', 'bookmarks_tree', 'tr', $qb->expr()->andX( - $qb->expr()->eq('b.id', 'tr.id'), - $qb->expr()->eq('tr.type', $qb->createPositionalParameter(TreeMapper::TYPE_BOOKMARK)) - )) + ->leftJoin('b', 'bookmarks_tree', 'tr', 'b.id = tr.id AND tr.type = '.$qb->createPositionalParameter(TreeMapper::TYPE_BOOKMARK)) ->leftJoin('tr', 'bookmarks_shared_folders', 'sf', $qb->expr()->eq('tr.parent_folder', 'sf.folder_id')) ->where($qb->expr()->eq('b.user_id', $qb->createPositionalParameter($userId))) ->orWhere($qb->expr()->andX( @@ -70,10 +67,7 @@ class TagMapper { ->select('t.tag') ->from('bookmarks_tags', 't') ->innerJoin('t', 'bookmarks', 'b', $qb->expr()->eq('b.id', 't.bookmark_id')) - ->leftJoin('b', 'bookmarks_tree', 'tr', $qb->expr()->andX( - $qb->expr()->eq('b.id', 'tr.id'), - $qb->expr()->eq('tr.type', $qb->createPositionalParameter(TreeMapper::TYPE_BOOKMARK)) - )) + ->leftJoin('b', 'bookmarks_tree', 'tr', 'b.id = tr.id AND tr.type = '.$qb->createPositionalParameter(TreeMapper::TYPE_BOOKMARK)) ->leftJoin('tr', 'bookmarks_shared_folders', 'sf', $qb->expr()->eq('tr.parent_folder', 'sf.folder_id')) ->where($qb->expr()->eq('b.user_id', $qb->createPositionalParameter($userId))) ->orWhere($qb->expr()->andX( diff --git a/lib/Db/TreeMapper.php b/lib/Db/TreeMapper.php index 6163114a..d0f6028d 100644 --- a/lib/Db/TreeMapper.php +++ b/lib/Db/TreeMapper.php @@ -388,10 +388,7 @@ class TreeMapper extends QBMapper { $qb = $this->db->getQueryBuilder(); $qb->select('b.id') ->from('bookmarks', 'b') - ->leftJoin('b', 'bookmarks_tree', 't', $qb->expr()->andX( - $qb->expr()->eq('b.id', 't.id'), - $qb->expr()->eq('t.type', $qb->createPositionalParameter(self::TYPE_BOOKMARK)) - )) + ->leftJoin('b', 'bookmarks_tree', 't', 'b.id = t.id AND t.type = '.$qb->createPositionalParameter(self::TYPE_BOOKMARK)) ->where($qb->expr()->isNull('t.id')); $orphanedBookmarks = $qb->execute(); while ($bookmark = $orphanedBookmarks->fetchColumn()) { diff --git a/lib/Migration/DeduplicateSharedFoldersRepairStep.php b/lib/Migration/DeduplicateSharedFoldersRepairStep.php index 3be94868..f201e08b 100644 --- a/lib/Migration/DeduplicateSharedFoldersRepairStep.php +++ b/lib/Migration/DeduplicateSharedFoldersRepairStep.php @@ -39,10 +39,7 @@ class DeduplicateSharedFoldersRepairStep implements IRepairStep { $qb = $this->db->getQueryBuilder(); $qb->select('p1.id') ->from('bookmarks_shared_folders', 'p1') - ->leftJoin('p1', 'bookmarks_shared_folders', 'p2', $qb->expr()->andX( - $qb->expr()->eq('p1.folder_id', 'p2.folder_id'), - $qb->expr()->eq('p1.user_id', 'p2.user_id') - )) + ->leftJoin('p1', 'bookmarks_shared_folders', 'p2', 'p1.folder_id = p2.folder_id AND p1.user_id = p2.user_id') ->where($qb->expr()->lt('p2.id', 'p1.id')); $duplicateSharedFolders = $qb->execute(); $i = 0; diff --git a/lib/Migration/Version000014000Date20181029094721.php b/lib/Migration/Version000014000Date20181029094721.php index 6d5e41d0..02e0a862 100644 --- a/lib/Migration/Version000014000Date20181029094721.php +++ b/lib/Migration/Version000014000Date20181029094721.php @@ -102,7 +102,7 @@ class Version000014000Date20181029094721 extends SimpleMigrationStep { $qb = $this->db->getQueryBuilder(); $qb ->update('bookmarks_folders_bookmarks') - ->set(['index' => $qb->createPositionalParameter($i)]) + ->set('index', $qb->createPositionalParameter($i)) ->where($qb->expr()->eq('bookmark_id', $qb->createPositionalParameter($child['id']))) ->andWhere($qb->expr()->eq('folder_id', $qb->createPositionalParameter($folder))); $qb->execute(); @@ -110,7 +110,7 @@ class Version000014000Date20181029094721 extends SimpleMigrationStep { $qb = $this->db->getQueryBuilder(); $qb ->update('bookmarks_folders') - ->set(['index' => $qb->createPositionalParameter($i)]) + ->set('index', $qb->createPositionalParameter($i)) ->where($qb->expr()->eq('id', $qb->createPositionalParameter($child['id']))) ->andWhere($qb->expr()->eq('parent_folder', $qb->createPositionalParameter($folder))); $qb->execute(); diff --git a/lib/QueryParameters.php b/lib/QueryParameters.php index 4b05a2ba..b8edf76f 100644 --- a/lib/QueryParameters.php +++ b/lib/QueryParameters.php @@ -97,13 +97,13 @@ class QueryParameters { /** * @param string|null $default * @param array|null $columns - * @return string + * @return string|null */ - public function getSortBy(string $default = null, array $columns = null): string { + public function getSortBy(string $default = null, array $columns = null): ?string { if (isset($default) && !isset($this->sortBy)) { return $default; } - if (isset($columns) && !in_array($this->sortBy, $columns, true)) { + if (isset($default, $columns) && !in_array($this->sortBy, $columns, true)) { return $default; } return $this->sortBy; diff --git a/lib/Service/BookmarksParser.php b/lib/Service/BookmarksParser.php index 3bfc67f7..60f85370 100644 --- a/lib/Service/BookmarksParser.php +++ b/lib/Service/BookmarksParser.php @@ -249,13 +249,15 @@ class BookmarksParser { */ private function getAttributes(DOMNode $node): array { $attributes = []; - $length = $node->attributes->length; - for ($i = 0; $i < $length; ++$i) { - $item = $node->attributes->item($i); - if ($item === null) { - continue; + if ($node->attributes) { + $length = $node->attributes->length; + for ($i = 0; $i < $length; ++$i) { + $item = $node->attributes->item($i); + if ($item === null) { + continue; + } + $attributes[strtolower($item->nodeName)] = $item->nodeValue; } - $attributes[strtolower($item->nodeName)] = $item->nodeValue; } $lastModified = null; if (isset($attributes['time_added'])) { diff --git a/lib/Service/FileCache.php b/lib/Service/FileCache.php index c61462b6..1c8fb1b6 100644 --- a/lib/Service/FileCache.php +++ b/lib/Service/FileCache.php @@ -59,7 +59,7 @@ class FileCache implements ICache { * @param string $key * @param mixed $value * @param int $ttl - * @return bool|mixed + * @return bool * @throws NotFoundException * @throws NotPermittedException */ @@ -82,12 +82,12 @@ class FileCache implements ICache { /** * @param string $key - * @return bool|mixed + * @return bool * @throws NotFoundException * @throws NotPermittedException */ public function remove($key) { - return $this->storage->getFile($key)->delete(); + return (boolean) $this->storage->getFile($key)->delete(); } /** diff --git a/lib/Service/FolderService.php b/lib/Service/FolderService.php index 18742c83..b69e4853 100644 --- a/lib/Service/FolderService.php +++ b/lib/Service/FolderService.php @@ -210,10 +210,10 @@ class FolderService { } /** - * @param $userId - * @param $folderId - * @param null $title - * @param null $parent_folder + * @param string $userId + * @param int $folderId + * @param string $title + * @param int $parent_folder * @return Folder|SharedFolder * @throws DoesNotExistException * @throws MultipleObjectsReturnedException @@ -271,6 +271,7 @@ class FolderService { public function createFolderPublicToken($folderId): string { $this->folderMapper->find($folderId); try { + /** @var PublicFolder $publicFolder */ $publicFolder = $this->publicFolderMapper->findByFolder($folderId); } catch (DoesNotExistException $e) { $publicFolder = new PublicFolder(); @@ -370,7 +371,7 @@ class FolderService { /** * @param string $userId * @param $file - * @param null $folder + * @param int $folder * @return array * @throws DoesNotExistException * @throws MultipleObjectsReturnedException diff --git a/lib/Service/HtmlImporter.php b/lib/Service/HtmlImporter.php index 1b0fba2b..842b5278 100644 --- a/lib/Service/HtmlImporter.php +++ b/lib/Service/HtmlImporter.php @@ -197,7 +197,7 @@ class HtmlImporter { * @param string $userId * @param int $folderId * @param array $bookmark - * @param null $index + * @param null|int $index * @return Bookmark|Entity * @throws UrlParseError * @throws AlreadyExistsError diff --git a/lib/Service/Previewers/PageresBookmarkPreviewer.php b/lib/Service/Previewers/PageresBookmarkPreviewer.php index c2aaefab..1ca37ee3 100644 --- a/lib/Service/Previewers/PageresBookmarkPreviewer.php +++ b/lib/Service/Previewers/PageresBookmarkPreviewer.php @@ -33,7 +33,7 @@ class PageresBookmarkPreviewer implements IBookmarkPreviewer { } /** - * @param Bookmark $bookmark + * @param Bookmark|null $bookmark * * @return Image|null */ diff --git a/lib/Service/Previewers/ScreeenlyBookmarkPreviewer.php b/lib/Service/Previewers/ScreeenlyBookmarkPreviewer.php index 2d09c314..84d25127 100644 --- a/lib/Service/Previewers/ScreeenlyBookmarkPreviewer.php +++ b/lib/Service/Previewers/ScreeenlyBookmarkPreviewer.php @@ -12,7 +12,7 @@ use OCA\Bookmarks\Contract\IBookmarkPreviewer; use OCA\Bookmarks\Contract\IImage; use OCA\Bookmarks\Db\Bookmark; use OCA\Bookmarks\Image; -use OCA\Bookmarks\Service\FileCache; +use OCP\Http\Client\IClient; use OCP\Http\Client\IClientService; use OCP\IConfig; use Psr\Log\LoggerInterface; @@ -22,28 +22,36 @@ class ScreeenlyBookmarkPreviewer implements IBookmarkPreviewer { public const HTTP_TIMEOUT = 10 * 1000; + /** + * @var string + */ private $apiKey; + /** + * @var IClient + */ private $client; - /** @var IConfig */ - private $config; - - private $cache; /** @var LoggerInterface */ private $logger; + /** + * @var int + */ private $width = 800; + /** + * @var int + */ private $height = 800; + /** * @var string */ private $apiUrl; - public function __construct(FileCache $cache, IConfig $config, IClientService $clientService, LoggerInterface $logger) { - $this->config = $config; + public function __construct(IConfig $config, IClientService $clientService, LoggerInterface $logger) { $this->apiUrl = $config->getAppValue('bookmarks', 'previews.screenly.url', 'http://screeenly.com/api/v1/fullsize'); $this->apiKey = $config->getAppValue('bookmarks', 'previews.screenly.token', ''); $this->client = $clientService->newClient(); @@ -51,7 +59,7 @@ class ScreeenlyBookmarkPreviewer implements IBookmarkPreviewer { } /** - * @param Bookmark $bookmark + * @param Bookmark|null $bookmark * * @return Image|null */ @@ -69,7 +77,7 @@ class ScreeenlyBookmarkPreviewer implements IBookmarkPreviewer { } /** - * @param $url + * @param string $url * @return Image|null */ public function fetchImage($url): ?Image { diff --git a/lib/Service/Previewers/ScreenshotMachineBookmarkPreviewer.php b/lib/Service/Previewers/ScreenshotMachineBookmarkPreviewer.php index fe158681..8cf417a9 100644 --- a/lib/Service/Previewers/ScreenshotMachineBookmarkPreviewer.php +++ b/lib/Service/Previewers/ScreenshotMachineBookmarkPreviewer.php @@ -12,7 +12,7 @@ use OCA\Bookmarks\Contract\IBookmarkPreviewer; use OCA\Bookmarks\Contract\IImage; use OCA\Bookmarks\Db\Bookmark; use OCA\Bookmarks\Image; -use OCA\Bookmarks\Service\FileCache; +use OCP\Http\Client\IClient; use OCP\Http\Client\IClientService; use OCP\IConfig; use Psr\Log\LoggerInterface; @@ -22,34 +22,38 @@ class ScreenshotMachineBookmarkPreviewer implements IBookmarkPreviewer { public const HTTP_TIMEOUT = 10 * 1000; + /** + * @var string + */ private $apiKey; + /** + * @var IClient + */ private $client; - /** @var IConfig */ - private $config; - /** @var LoggerInterface */ private $logger; + /** + * @var int + */ private $width = 800; - private $height = 800; /** - * @var FileCache + * @var int */ - private $cache; + private $height = 800; - public function __construct(FileCache $cache, IConfig $config, IClientService $clientService, LoggerInterface $logger) { - $this->config = $config; + + public function __construct(IConfig $config, IClientService $clientService, LoggerInterface $logger) { $this->apiKey = $config->getAppValue('bookmarks', 'previews.screenshotmachine.key', ''); - $this->cache = $cache; $this->client = $clientService->newClient(); $this->logger = $logger; } /** - * @param Bookmark $bookmark + * @param Bookmark|null $bookmark * * @return Image|null */ diff --git a/lib/Service/Previewers/WebshotBookmarkPreviewer.php b/lib/Service/Previewers/WebshotBookmarkPreviewer.php index 6b49299b..9e2a96e0 100644 --- a/lib/Service/Previewers/WebshotBookmarkPreviewer.php +++ b/lib/Service/Previewers/WebshotBookmarkPreviewer.php @@ -13,6 +13,7 @@ use OCA\Bookmarks\Contract\IImage; use OCA\Bookmarks\Db\Bookmark; use OCA\Bookmarks\Image; use OCA\Bookmarks\Service\FileCache; +use OCP\Http\Client\IClient; use OCP\Http\Client\IClientService; use OCP\IConfig; use Psr\Log\LoggerInterface; @@ -22,18 +23,30 @@ class WebshotBookmarkPreviewer implements IBookmarkPreviewer { public const HTTP_TIMEOUT = 10 * 1000; + /** + * @var IClient + */ private $client; /** @var IConfig */ private $config; + /** + * @var FileCache + */ private $cache; /** @var LoggerInterface */ private $logger; + /** + * @var int + */ private $width = 800; + /** + * @var int + */ private $height = 800; /** * @var string diff --git a/lib/Service/UrlNormalizer.php b/lib/Service/UrlNormalizer.php index f61f7533..d1b7ce33 100644 --- a/lib/Service/UrlNormalizer.php +++ b/lib/Service/UrlNormalizer.php @@ -12,6 +12,7 @@ use Rowbot\URL\Exception\TypeError; use Rowbot\URL\URL; class UrlNormalizer { + /** @var array */ private $cache = []; public function __construct() { diff --git a/psalm.xml b/psalm.xml index cd4d6623..bc2225b9 100644 --- a/psalm.xml +++ b/psalm.xml @@ -5,7 +5,7 @@ ~ This file is licensed under the Affero General Public License version 3 or later. See the COPYING file. --> + + + + + + + + + + + + + + + + + +