From 2baa7a2b9136d4d4dc1e56dfc043cc71da3ee1df Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Fri, 20 Nov 2020 20:52:54 +0100 Subject: Make PHPstan stricter Signed-off-by: Sean Molenaar --- lib/Service/Exceptions/ServiceException.php | 8 ++++---- lib/Service/FeedServiceV2.php | 5 ++--- lib/Service/ImportService.php | 1 + lib/Service/ItemServiceV2.php | 5 +++-- lib/Service/StatusService.php | 4 ++-- 5 files changed, 12 insertions(+), 11 deletions(-) (limited to 'lib/Service') diff --git a/lib/Service/Exceptions/ServiceException.php b/lib/Service/Exceptions/ServiceException.php index 69b963ab6..b4804f1de 100644 --- a/lib/Service/Exceptions/ServiceException.php +++ b/lib/Service/Exceptions/ServiceException.php @@ -27,9 +27,9 @@ abstract class ServiceException extends Exception /** * Constructor * - * @param string $msg the error message - * @param int $code - * @param Exception|null $previous + * @param string $msg the error message + * @param int $code + * @param Exception|null $previous */ final public function __construct(string $msg, int $code = 0, ?Exception $previous = null) { @@ -39,7 +39,7 @@ abstract class ServiceException extends Exception /** * Create exception from Mapper exception. * - * @param IMapperException|Exception $exception Existing exception + * @param IMapperException $exception Existing exception * * @return static */ diff --git a/lib/Service/FeedServiceV2.php b/lib/Service/FeedServiceV2.php index d49c540b1..9d577db97 100644 --- a/lib/Service/FeedServiceV2.php +++ b/lib/Service/FeedServiceV2.php @@ -18,7 +18,6 @@ use FeedIo\Reader\ReadErrorException; use HTMLPurifier; use OCA\News\Db\FeedMapperV2; -use OCA\News\Db\Folder; use OCA\News\Fetcher\FeedFetcher; use OCA\News\Service\Exceptions\ServiceConflictException; use OCA\News\Service\Exceptions\ServiceNotFoundException; @@ -206,7 +205,7 @@ class FeedServiceV2 extends Service * @var Feed $feed * @var Item[] $items */ - list($feed, $items) = $this->feedFetcher->fetch($feedUrl, true, '0', $full_text, $user, $password); + list($feed, $items) = $this->feedFetcher->fetch($feedUrl, $full_text, $user, $password); } catch (ReadErrorException $ex) { $this->logger->debug($ex->getMessage()); throw new ServiceNotFoundException($ex->getMessage()); @@ -307,7 +306,7 @@ class FeedServiceV2 extends Service $feed->setLastUpdateError(null); $unreadCount = 0; - array_map(function (Item $item) use (&$unreadCount) { + array_map(function (Item $item) use (&$unreadCount): void { if ($item->isUnread()) { $unreadCount++; } diff --git a/lib/Service/ImportService.php b/lib/Service/ImportService.php index e7b6ab7be..7b593356e 100644 --- a/lib/Service/ImportService.php +++ b/lib/Service/ImportService.php @@ -106,6 +106,7 @@ class ImportService ->setFolderId(null) ->setPreventUpdate(true); + /** @var Feed $feed */ $feed = $this->feedService->insert($feed); $feedsDict[$feed->getLink()] = $feed; } diff --git a/lib/Service/ItemServiceV2.php b/lib/Service/ItemServiceV2.php index da675450f..fafd5e558 100644 --- a/lib/Service/ItemServiceV2.php +++ b/lib/Service/ItemServiceV2.php @@ -89,6 +89,7 @@ class ItemServiceV2 extends Service public function insertOrUpdate(Item $item): Entity { try { + /** @var Item $db_item */ $db_item = $this->findByGuidHash($item->getFeedId(), $item->getGuidHash()); // Transfer user modifications @@ -243,7 +244,7 @@ class ItemServiceV2 extends Service * @param int $feedId * @param string $guidHash * - * @return Item|Entity + * @return Item * * @throws DoesNotExistException * @throws MultipleObjectsReturnedException @@ -307,7 +308,7 @@ class ItemServiceV2 extends Service */ public function findAllAfter(string $userId, int $feedType, int $updatedSince): array { - if (!in_array($feedType, [ListType::STARRED, ListType::UNREAD, ListType::ALL_ITEMS])) { + if (!in_array($feedType, [ListType::STARRED, ListType::UNREAD, ListType::ALL_ITEMS], true)) { throw new ServiceValidationException('Trying to find in unknown type'); } diff --git a/lib/Service/StatusService.php b/lib/Service/StatusService.php index d33d99bad..a15f30c76 100644 --- a/lib/Service/StatusService.php +++ b/lib/Service/StatusService.php @@ -45,11 +45,11 @@ class StatusService //Is NC cron enabled? $cronMode = $this->settings->getAppValue('core', 'backgroundjobs_mode'); //Expect nextcloud cron - $cronOff = !$this->settings->getAppValue( + $cronOff = !boolval($this->settings->getAppValue( Application::NAME, 'useCronUpdates', Application::DEFAULT_SETTINGS['useCronUpdates'] - ); + )); // check for cron modes which may lead to problems return $cronMode === 'cron' || $cronOff; -- cgit v1.2.3