diff options
| author | 2024-09-11 17:14:53 +0200 | |
|---|---|---|
| committer | 2024-09-11 17:14:53 +0200 | |
| commit | dfac9f5813df7d4c7c812c381364c8898333f559 (patch) | |
| tree | 978496d0a8d8b0d6b5dbe836c6829296133b337c /app/Models/CategoryDAO.php | |
| parent | 31c8846791d4b5316fbc790202f79545c012f9c2 (diff) | |
PHPStan booleansInConditions (#6793)
* PHPStan booleansInConditions
* Uniformisation
Diffstat (limited to 'app/Models/CategoryDAO.php')
| -rw-r--r-- | app/Models/CategoryDAO.php | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.php index b101f0b3f..2e9892df9 100644 --- a/app/Models/CategoryDAO.php +++ b/app/Models/CategoryDAO.php @@ -12,7 +12,7 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo { $stm->bindValue(':id', self::DEFAULTCATEGORYID, PDO::PARAM_INT); $stm->bindValue(':name', 'Uncategorized'); } - return $stm && $stm->execute(); + return $stm !== false && $stm->execute(); } protected function addColumn(string $name): bool { @@ -126,7 +126,7 @@ SQL; $catId = $this->pdo->lastInsertId('`_category_id_seq`'); return $catId === false ? false : (int)$catId; } else { - $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo(); + $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo(); if ($this->autoUpdateDb($info)) { return $this->addCategory($valuesTmp); } @@ -137,7 +137,7 @@ SQL; public function addCategoryObject(FreshRSS_Category $category): int|false { $cat = $this->searchByName($category->name()); - if (!$cat) { + if ($cat === null) { $values = [ 'kind' => $category->kind(), 'name' => $category->name(), @@ -175,7 +175,7 @@ SQL; if ($stm !== false && $stm->execute($values)) { return $stm->rowCount(); } else { - $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo(); + $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo(); if ($this->autoUpdateDb($info)) { return $this->updateCategory($id, $valuesTmp); } @@ -196,7 +196,7 @@ SQL; if ($stm !== false && $stm->execute($values)) { return $stm->rowCount(); } else { - $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo(); + $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo(); Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info)); return false; } @@ -211,7 +211,7 @@ SQL; if ($stm !== false && $stm->bindParam(':id', $id, PDO::PARAM_INT) && $stm->execute()) { return $stm->rowCount(); } else { - $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo(); + $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo(); Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info)); return false; } @@ -290,7 +290,7 @@ SQL; * 'id'?:int,'name'?:string,'url'?:string,'kind'?:int,'category'?:int,'website'?:string,'priority'?:int,'error'?:int|bool,'attributes'?:string,'cache_nbEntries'?:int,'cache_nbUnreads'?:int,'ttl'?:int}> $res */ return self::daoToCategoriesPrepopulated($res); } else { - $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo(); + $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo(); if ($this->autoUpdateDb($info)) { return $this->listCategories($prePopulateFeeds, $details); } @@ -315,7 +315,7 @@ SQL; $stm->execute()) { return self::daoToCategories($stm->fetchAll(PDO::FETCH_ASSOC)); } else { - $info = $stm ? $stm->errorInfo() : $this->pdo->errorInfo(); + $info = $stm !== false ? $stm->errorInfo() : $this->pdo->errorInfo(); if ($this->autoUpdateDb($info)) { return $this->listCategoriesOrderUpdate($defaultCacheDuration, $limit); } @@ -362,7 +362,7 @@ SQL; $catId = $this->pdo->lastInsertId('`_category_id_seq`'); return $catId === false ? false : (int)$catId; } else { - $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo(); + $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo(); Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info)); return false; } |
