From 1a0616562db5c096dc7ca187f0210b3d57bffebf Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Wed, 22 Mar 2023 08:26:39 +0100 Subject: Remove FreshRSS_Searchable for better types (#5212) * Remove FreshRSS_Searchable for better types The interface was not used, and it was preventing more precise types for the different `searchById()` methods, as they each have different input and output types. * Fix type --- app/Models/CategoryDAO.php | 5 ++--- app/Models/EntryDAO.php | 5 ++--- app/Models/FeedDAO.php | 7 ++----- app/Models/Searchable.php | 10 ---------- app/Models/TagDAO.php | 7 ++----- p/api/fever.php | 2 +- 6 files changed, 9 insertions(+), 27 deletions(-) delete mode 100644 app/Models/Searchable.php diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.php index c855f1495..02845ebe7 100644 --- a/app/Models/CategoryDAO.php +++ b/app/Models/CategoryDAO.php @@ -1,6 +1,6 @@ pdo->prepare($sql); if ($stm && diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index aab17d01e..0740f1ac4 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -1,6 +1,6 @@ pdo->inTransaction()) { @@ -284,10 +284,7 @@ SQL; } } - /** - * @return FreshRSS_Feed|null - */ - public function searchById($id) { + public function searchById(int $id): ?FreshRSS_Feed { $sql = 'SELECT * FROM `_feed` WHERE id=:id'; $stm = $this->pdo->prepare($sql); $stm->bindParam(':id', $id, PDO::PARAM_INT); diff --git a/app/Models/Searchable.php b/app/Models/Searchable.php deleted file mode 100644 index a15a44ed7..000000000 --- a/app/Models/Searchable.php +++ /dev/null @@ -1,10 +0,0 @@ -pdo->prepare($sql); $values = array($id); diff --git a/p/api/fever.php b/p/api/fever.php index c83b28da3..1bc7068ab 100644 --- a/p/api/fever.php +++ b/p/api/fever.php @@ -474,7 +474,7 @@ final class FeverAPI $group_ids = explode(',', $_REQUEST['group_ids']); $feeds = []; foreach ($group_ids as $id) { - $category = $categoryDAO->searchById($id); //TODO: Transform to SQL query without loop! Consider FreshRSS_CategoryDAO::listCategories(true) + $category = $categoryDAO->searchById((int)$id); //TODO: Transform to SQL query without loop! Consider FreshRSS_CategoryDAO::listCategories(true) if ($category == null) { continue; } -- cgit v1.2.3