aboutsummaryrefslogtreecommitdiff
path: root/app/Models/CategoryDAO.php
diff options
context:
space:
mode:
authorGravatar Luc SANCHEZ <4697568+ColonelMoutarde@users.noreply.github.com> 2023-07-07 22:36:27 +0200
committerGravatar GitHub <noreply@github.com> 2023-07-07 22:36:27 +0200
commitf8f163d054110f7e0ff6650fca146b474335f4bd (patch)
treedbd831e600bc76ca2830cd417bd52b712ff97309 /app/Models/CategoryDAO.php
parent7f9594b8c7d7799f2e5f89328bd5981410db8cf0 (diff)
Chore/processing of depreciations and updating code to php72 minimum (#5504)
* processing of depreciations and updating of code to php7.2 minimum * Autoformat many strange array indenting And revert a few unwanted changes --------- Co-authored-by: Luc <sanchezluc+freshrss@gmail.com> Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Diffstat (limited to 'app/Models/CategoryDAO.php')
-rw-r--r--app/Models/CategoryDAO.php20
1 files changed, 11 insertions, 9 deletions
diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.php
index ccfd5c08a..d617fd672 100644
--- a/app/Models/CategoryDAO.php
+++ b/app/Models/CategoryDAO.php
@@ -2,7 +2,7 @@
class FreshRSS_CategoryDAO extends Minz_ModelPdo {
- const DEFAULTCATEGORYID = 1;
+ public const DEFAULTCATEGORYID = 1;
public function resetDefaultCategoryName(): bool {
//FreshRSS 1.15.1
@@ -51,7 +51,7 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo {
$attributes = [];
}
if ($keepHistory > 0) {
- $attributes['archiving']['keep_min'] = intval($keepHistory);
+ $attributes['archiving']['keep_min'] = (int)$keepHistory;
} elseif ($keepHistory == -1) { //Infinite
$attributes['archiving']['keep_period'] = false;
$attributes['archiving']['keep_max'] = false;
@@ -100,6 +100,7 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo {
/**
* @param array{'name':string,'id'?:int,'kind'?:int,'lastUpdate'?:int,'error'?:int|bool,'attributes'?:string|array<string,mixed>} $valuesTmp
* @return int|false
+ * @throws JsonException
*/
public function addCategory(array $valuesTmp) {
// TRIM() to provide a type hint as text
@@ -115,12 +116,12 @@ SQL;
if (!isset($valuesTmp['attributes'])) {
$valuesTmp['attributes'] = [];
}
- $values = array(
+ $values = [
$valuesTmp['kind'] ?? FreshRSS_Category::KIND_NORMAL,
$valuesTmp['name'],
is_string($valuesTmp['attributes']) ? $valuesTmp['attributes'] : json_encode($valuesTmp['attributes'], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE),
$valuesTmp['name'],
- );
+ ];
if ($stm !== false && $stm->execute($values) && $stm->rowCount() > 0) {
$catId = $this->pdo->lastInsertId('`_category_id_seq`');
@@ -153,6 +154,7 @@ SQL;
/**
* @param array{'name':string,'kind':int,'attributes'?:string|array<string,mixed>} $valuesTmp
* @return int|false
+ * @throws JsonException
*/
public function updateCategory(int $id, array $valuesTmp) {
// No tag of the same name
@@ -166,13 +168,13 @@ SQL;
if (empty($valuesTmp['attributes'])) {
$valuesTmp['attributes'] = [];
}
- $values = array(
+ $values = [
$valuesTmp['name'],
$valuesTmp['kind'] ?? FreshRSS_Category::KIND_NORMAL,
is_string($valuesTmp['attributes']) ? $valuesTmp['attributes'] : json_encode($valuesTmp['attributes'], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE),
$id,
$valuesTmp['name'],
- );
+ ];
if ($stm !== false && $stm->execute($values)) {
return $stm->rowCount();
@@ -358,10 +360,10 @@ SQL;
}
$stm = $this->pdo->prepare($sql);
- $values = array(
+ $values = [
$cat->id(),
$cat->name(),
- );
+ ];
if ($stm !== false && $stm->execute($values)) {
$catId = $this->pdo->lastInsertId('`_category_id_seq`');
@@ -482,7 +484,7 @@ SQL;
$cat->_kind($dao['kind']);
$cat->_lastUpdate($dao['lastUpdate'] ?? 0);
$cat->_error($dao['error'] ?? 0);
- $cat->_attributes('', isset($dao['attributes']) ? $dao['attributes'] : '');
+ $cat->_attributes('', $dao['attributes'] ?? '');
$list[] = $cat;
}