From 67c42b0e7c4250d7befe61e35994d8f6e439ca7a Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 15 Jun 2025 01:17:20 +0200 Subject: Remove several PHPStan ignore (#7665) * Remove several PHPStan ignore * One syntax error * PDO returns int, not bool (MySQL and SQLite Boolean types are aliases for tinyint). * A few missing type hints * Revert strange PHPStan bug --- app/Models/CategoryDAO.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'app/Models/CategoryDAO.php') diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.php index 7dfb32076..3a714afed 100644 --- a/app/Models/CategoryDAO.php +++ b/app/Models/CategoryDAO.php @@ -244,16 +244,16 @@ SQL; public function searchById(int $id): ?FreshRSS_Category { $sql = 'SELECT * FROM `_category` WHERE id=:id'; $res = $this->fetchAssoc($sql, ['id' => $id]) ?? []; - /** @var array $res */ - $categories = self::daoToCategories($res); // @phpstan-ignore varTag.type + /** @var list $res */ + $categories = self::daoToCategories($res); return reset($categories) ?: null; } public function searchByName(string $name): ?FreshRSS_Category { $sql = 'SELECT * FROM `_category` WHERE name=:name'; $res = $this->fetchAssoc($sql, ['name' => $name]) ?? []; - /** @var array $res */ - $categories = self::daoToCategories($res); // @phpstan-ignore varTag.type + /** @var list $res */ + $categories = self::daoToCategories($res); return reset($categories) ?: null; } @@ -290,8 +290,8 @@ SQL; $stm = $this->pdo->prepare($sql); $values = [ ':priority' => FreshRSS_Feed::PRIORITY_CATEGORY ]; if ($stm !== false && $stm->execute($values) && ($res = $stm->fetchAll(PDO::FETCH_ASSOC)) !== false) { - /** @var list $res */ + /** @var list $res */ return self::daoToCategoriesPrepopulated($res); } else { $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo(); @@ -304,8 +304,8 @@ SQL; } } else { $res = $this->fetchAssoc('SELECT * FROM `_category` ORDER BY name') ?? []; - /** @var list $res */ - return empty($res) ? [] : self::daoToCategories($res); // @phpstan-ignore varTag.type + /** @var list $res */ + return empty($res) ? [] : self::daoToCategories($res); } } @@ -319,7 +319,7 @@ SQL; $stm->bindValue(':lu', time() - $defaultCacheDuration, PDO::PARAM_INT) && $stm->execute()) { $res = $stm->fetchAll(PDO::FETCH_ASSOC); - /** @var list $res */ + /** @var list $res */ return self::daoToCategories($res); } else { $info = $stm !== false ? $stm->errorInfo() : $this->pdo->errorInfo(); @@ -335,8 +335,8 @@ SQL; public function getDefault(): ?FreshRSS_Category { $sql = 'SELECT * FROM `_category` WHERE id=:id'; $res = $this->fetchAssoc($sql, [':id' => self::DEFAULTCATEGORYID]) ?? []; - /** @var array $res */ - $categories = self::daoToCategories($res); // @phpstan-ignore varTag.type + /** @var list $res */ + $categories = self::daoToCategories($res); if (isset($categories[self::DEFAULTCATEGORYID])) { return $categories[self::DEFAULTCATEGORYID]; } else { -- cgit v1.2.3