mirror of https://github.com/nextcloud/bookmarks
Psalm: Fix typings
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
This commit is contained in:
parent
130635a40e
commit
e02b440909
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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'];
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -249,6 +249,7 @@ class BookmarksParser {
|
|||
*/
|
||||
private function getAttributes(DOMNode $node): array {
|
||||
$attributes = [];
|
||||
if ($node->attributes) {
|
||||
$length = $node->attributes->length;
|
||||
for ($i = 0; $i < $length; ++$i) {
|
||||
$item = $node->attributes->item($i);
|
||||
|
@ -257,6 +258,7 @@ class BookmarksParser {
|
|||
}
|
||||
$attributes[strtolower($item->nodeName)] = $item->nodeValue;
|
||||
}
|
||||
}
|
||||
$lastModified = null;
|
||||
if (isset($attributes['time_added'])) {
|
||||
$attributes['add_date'] = $attributes['time_added'];
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -33,7 +33,7 @@ class PageresBookmarkPreviewer implements IBookmarkPreviewer {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Bookmark $bookmark
|
||||
* @param Bookmark|null $bookmark
|
||||
*
|
||||
* @return Image|null
|
||||
*/
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -12,6 +12,7 @@ use Rowbot\URL\Exception\TypeError;
|
|||
use Rowbot\URL\URL;
|
||||
|
||||
class UrlNormalizer {
|
||||
/** @var array<string, string> */
|
||||
private $cache = [];
|
||||
|
||||
public function __construct() {
|
||||
|
|
20
psalm.xml
20
psalm.xml
|
@ -5,7 +5,7 @@
|
|||
~ This file is licensed under the Affero General Public License version 3 or later. See the COPYING file.
|
||||
-->
|
||||
<psalm
|
||||
errorLevel="1"
|
||||
errorLevel="5"
|
||||
resolveFromConfigFile="true"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="https://getpsalm.org/schema/config"
|
||||
|
@ -21,6 +21,24 @@
|
|||
<directory name="vendor" />
|
||||
<ignoreFiles>
|
||||
<directory name="vendor/phpunit/php-code-coverage" />
|
||||
<directory name="vendor/vimeo" />
|
||||
</ignoreFiles>
|
||||
</extraFiles>
|
||||
<issueHandlers>
|
||||
<UndefinedClass>
|
||||
<errorLevel type="suppress">
|
||||
<referencedClass name="OC" />
|
||||
<referencedClass name="Doctrine\DBAL\Types\Type" />
|
||||
</errorLevel>
|
||||
</UndefinedClass>
|
||||
<UndefinedDocblockClass>
|
||||
<errorLevel type="suppress">
|
||||
<referencedClass name="Doctrine\DBAL\Schema\Schema" />
|
||||
<referencedClass name="Doctrine\DBAL\Schema\SchemaException" />
|
||||
<referencedClass name="Doctrine\DBAL\Driver\Statement" />
|
||||
<referencedClass name="Doctrine\DBAL\Schema\Table" />
|
||||
<referencedClass name="Doctrine\DBAL\Types\Type" />
|
||||
</errorLevel>
|
||||
</UndefinedDocblockClass>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
|
|
Loading…
Reference in New Issue