A free, self-hostable news aggregator…
Type hinting for Factory.php up to PHPStan 9 (#5090)
Luc SANCHEZ23447f122171
diff --git a/app/Controllers/entryController.php b/app/Controllers/entryController.phpindex 6750de43b..165e1437e 100644--- a/app/Controllers/entryController.php+++ b/app/Controllers/entryController.php@@ -75,7 +75,7 @@ class FreshRSS_entry_Controller extends FreshRSS_ActionController {$entryDAO->markReadEntries($id_max, false, 0, null, 0, $is_read);} else {$type_get = $get[0];- $get = substr($get, 2);+ $get = (int)substr($get, 2);switch($type_get) {case 'c':$entryDAO->markReadCat($get, $id_max, FreshRSS_Context::$search, FreshRSS_Context::$state, $is_read);@@ -93,7 +93,7 @@ class FreshRSS_entry_Controller extends FreshRSS_ActionController {$entryDAO->markReadTag($get, $id_max, FreshRSS_Context::$search, FreshRSS_Context::$state, $is_read);break;case 'T':- $entryDAO->markReadTag('', $id_max, FreshRSS_Context::$search, FreshRSS_Context::$state, $is_read);+ $entryDAO->markReadTag(0, $id_max, FreshRSS_Context::$search, FreshRSS_Context::$state, $is_read);break;}diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.phpindex 3b7c1ac3f..aab17d01e 100644--- a/app/Models/EntryDAO.php+++ b/app/Models/EntryDAO.php@@ -1197,11 +1197,11 @@ SQL;/*** For API- * @return array<string>+ * @return array<string>|false*/public function listIdsWhere($type = 'a', $id = '', $state = FreshRSS_Entry::STATE_ALL,- $order = 'DESC', $limit = 1, $firstId = '', $filters = null): array {- list($values, $sql) = $this->sqlListWhere($type, $id, $state, $order, $limit, $firstId, $filters);+ $order = 'DESC', $limit = 1, $firstId = '', $filters = null) {+ [$values, $sql] = $this->sqlListWhere($type, $id, $state, $order, $limit, $firstId, $filters);$stm = $this->pdo->prepare($sql);$stm->execute($values);diff --git a/app/Models/Factory.php b/app/Models/Factory.phpindex 308ff2864..80c611db5 100644--- a/app/Models/Factory.php+++ b/app/Models/Factory.php@@ -2,11 +2,17 @@class FreshRSS_Factory {- public static function createUserDao($username = null) {+ /**+ * @throws Minz_ConfigurationNamespaceException|Minz_PDOConnectionException+ */+ public static function createUserDao(?string $username = null): FreshRSS_UserDAO {return new FreshRSS_UserDAO($username);}- public static function createCategoryDao($username = null) {+ /**+ * @throws Minz_ConfigurationNamespaceException|Minz_PDOConnectionException+ */+ public static function createCategoryDao(?string $username = null): FreshRSS_CategoryDAO {switch (FreshRSS_Context::$system_conf->db['type']) {case 'sqlite':return new FreshRSS_CategoryDAOSQLite($username);@@ -15,7 +21,10 @@ class FreshRSS_Factory {}}- public static function createFeedDao($username = null) {+ /**+ * @throws Minz_ConfigurationNamespaceException|Minz_PDOConnectionException+ */+ public static function createFeedDao(?string $username = null): FreshRSS_FeedDAO {switch (FreshRSS_Context::$system_conf->db['type']) {case 'sqlite':return new FreshRSS_FeedDAOSQLite($username);@@ -24,7 +33,10 @@ class FreshRSS_Factory {}}- public static function createEntryDao($username = null) {+ /**+ * @throws Minz_ConfigurationNamespaceException|Minz_PDOConnectionException+ */+ public static function createEntryDao(?string $username = null): FreshRSS_EntryDAO {switch (FreshRSS_Context::$system_conf->db['type']) {case 'sqlite':return new FreshRSS_EntryDAOSQLite($username);@@ -35,7 +47,10 @@ class FreshRSS_Factory {}}- public static function createTagDao($username = null) {+ /**+ * @throws Minz_ConfigurationNamespaceException|Minz_PDOConnectionException+ */+ public static function createTagDao(?string $username = null): FreshRSS_TagDAO {switch (FreshRSS_Context::$system_conf->db['type']) {case 'sqlite':return new FreshRSS_TagDAOSQLite($username);@@ -46,7 +61,10 @@ class FreshRSS_Factory {}}- public static function createStatsDAO($username = null) {+ /**+ * @throws Minz_ConfigurationNamespaceException|Minz_PDOConnectionException+ */+ public static function createStatsDAO(?string $username = null): FreshRSS_StatsDAO {switch (FreshRSS_Context::$system_conf->db['type']) {case 'sqlite':return new FreshRSS_StatsDAOSQLite($username);@@ -57,7 +75,10 @@ class FreshRSS_Factory {}}- public static function createDatabaseDAO($username = null) {+ /**+ * @throws Minz_ConfigurationNamespaceException|Minz_PDOConnectionException+ */+ public static function createDatabaseDAO(?string $username = null): FreshRSS_DatabaseDAO {switch (FreshRSS_Context::$system_conf->db['type']) {case 'sqlite':return new FreshRSS_DatabaseDAOSQLite($username);