summaryrefslogtreecommitdiffstats
path: root/lib/Service
diff options
context:
space:
mode:
authorSean Molenaar <sean@seanmolenaar.eu>2020-11-20 20:52:54 +0100
committerSean Molenaar <SMillerDev@users.noreply.github.com>2021-03-25 18:47:38 +0100
commit2baa7a2b9136d4d4dc1e56dfc043cc71da3ee1df (patch)
treed8f970ce85442869ad9547f80f70153a31820563 /lib/Service
parent8b519cd234b1293e03ef288617287be1a30cfc75 (diff)
Make PHPstan stricter
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
Diffstat (limited to 'lib/Service')
-rw-r--r--lib/Service/Exceptions/ServiceException.php8
-rw-r--r--lib/Service/FeedServiceV2.php5
-rw-r--r--lib/Service/ImportService.php1
-rw-r--r--lib/Service/ItemServiceV2.php5
-rw-r--r--lib/Service/StatusService.php4
5 files changed, 12 insertions, 11 deletions
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;