From c72914bba2363e436574204b3d6093a6f3cfce89 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Fri, 28 Apr 2023 14:01:11 +0200 Subject: PHPStan Level 7 for more DAO PDO (#5328) * PHPStan Level 7 for more DAO PDO With new function to address common type and check problems * A bit more * PHPStan Level 7 for FreshRSS_Entry --- p/api/fever.php | 11 ++++------- p/api/greader.php | 8 +++++--- 2 files changed, 9 insertions(+), 10 deletions(-) (limited to 'p/api') diff --git a/p/api/fever.php b/p/api/fever.php index 26efe841b..fde4ba7f5 100644 --- a/p/api/fever.php +++ b/p/api/fever.php @@ -113,7 +113,7 @@ final class FeverDAO extends Minz_ModelPdo $sql .= ' LIMIT 50'; $stm = $this->pdo->prepare($sql); - if ($stm && $stm->execute($values)) { + if ($stm !== false && $stm->execute($values)) { $result = $stm->fetchAll(PDO::FETCH_ASSOC); $entries = array(); @@ -374,10 +374,7 @@ final class FeverAPI return $favicons; } - /** - * @return int|false - */ - private function getTotalItems() { + private function getTotalItems(): int { return $this->entryDAO->count(); } @@ -419,12 +416,12 @@ final class FeverAPI } private function getUnreadItemIds(): string { - $entries = $this->entryDAO->listIdsWhere('a', 0, FreshRSS_Entry::STATE_NOT_READ, 'ASC', 0) ?: []; + $entries = $this->entryDAO->listIdsWhere('a', 0, FreshRSS_Entry::STATE_NOT_READ, 'ASC', 0) ?? []; return $this->entriesToIdList($entries); } private function getSavedItemIds(): string { - $entries = $this->entryDAO->listIdsWhere('a', 0, FreshRSS_Entry::STATE_FAVORITE, 'ASC', 0) ?: []; + $entries = $this->entryDAO->listIdsWhere('a', 0, FreshRSS_Entry::STATE_FAVORITE, 'ASC', 0) ?? []; return $this->entriesToIdList($entries); } diff --git a/p/api/greader.php b/p/api/greader.php index f1cb7d615..34b74fd19 100644 --- a/p/api/greader.php +++ b/p/api/greader.php @@ -746,7 +746,7 @@ final class GReaderAPI { $entryDAO = FreshRSS_Factory::createEntryDao(); $ids = $entryDAO->listIdsWhere($type, $id, $state, $order === 'o' ? 'ASC' : 'DESC', $count, $continuation, $searches); - if ($ids === false) { + if ($ids == null) { self::internalServerError(); } @@ -898,13 +898,15 @@ final class GReaderAPI { $categoryDAO = FreshRSS_Factory::createCategoryDao(); $cat = $categoryDAO->searchByName($s); if ($cat != null) { - $categoryDAO->updateCategory($cat->id(), array('name' => $dest)); + $categoryDAO->updateCategory($cat->id(), [ + 'name' => $dest, 'kind' => $cat->kind(), 'attributes' => $cat->attributes() + ]); exit('OK'); } else { $tagDAO = FreshRSS_Factory::createTagDao(); $tag = $tagDAO->searchByName($s); if ($tag != null) { - $tagDAO->updateTag($tag->id(), array('name' => $dest)); + $tagDAO->updateTagName($tag->id(), $dest); exit('OK'); } } -- cgit v1.2.3