aboutsummaryrefslogtreecommitdiff
path: root/app/Models
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2022-01-01 11:26:56 +0100
committerGravatar GitHub <noreply@github.com> 2022-01-01 11:26:56 +0100
commit3f6aa42b817145a3b00f4d615f87728b55c4413a (patch)
treee5b31941b0acc3a2f4c47e4846afcfe987b9852f /app/Models
parent77e9877316fcfacb26799afdf32d94c8411da80e (diff)
Fix most PHPDocs errors (#4107)
Contributes to https://github.com/FreshRSS/FreshRSS/issues/4103 https://phpstan.org/writing-php-code/phpdoc-types
Diffstat (limited to 'app/Models')
-rw-r--r--app/Models/ConfigurationSetter.php12
-rw-r--r--app/Models/Context.php2
-rw-r--r--app/Models/EntryDAO.php6
-rw-r--r--app/Models/EntryDAOSQLite.php6
-rw-r--r--app/Models/Share.php36
-rw-r--r--app/Models/TagDAO.php21
6 files changed, 53 insertions, 30 deletions
diff --git a/app/Models/ConfigurationSetter.php b/app/Models/ConfigurationSetter.php
index 535f17e2e..3c07db4a0 100644
--- a/app/Models/ConfigurationSetter.php
+++ b/app/Models/ConfigurationSetter.php
@@ -3,8 +3,8 @@
class FreshRSS_ConfigurationSetter {
/**
* Return if the given key is supported by this setter.
- * @param $key the key to test.
- * @return boolean true if the key is supported, false else.
+ * @param string $key the key to test.
+ * @return boolean true if the key is supported, false otherwise.
*/
public function support($key) {
$name_setter = '_' . $key;
@@ -13,9 +13,9 @@ class FreshRSS_ConfigurationSetter {
/**
* Set the given key in data with the current value.
- * @param $data an array containing the list of all configuration data.
- * @param $key the key to update.
- * @param $value the value to set.
+ * @param array $data an array containing the list of all configuration data.
+ * @param string $key the key to update.
+ * @param mixed $value the value to set.
*/
public function handle(&$data, $key, $value) {
$name_setter = '_' . $key;
@@ -25,7 +25,7 @@ class FreshRSS_ConfigurationSetter {
/**
* A helper to set boolean values.
*
- * @param $value the tested value.
+ * @param mixed $value the tested value.
* @return boolean true if value is true and different from no, false else.
*/
private function handleBool($value) {
diff --git a/app/Models/Context.php b/app/Models/Context.php
index 14bca866c..6b2043bd3 100644
--- a/app/Models/Context.php
+++ b/app/Models/Context.php
@@ -125,6 +125,7 @@ class FreshRSS_Context {
/**
* Returns if the current state includes $state parameter.
+ * @param int $state
*/
public static function isStateEnabled($state) {
return self::$state & $state;
@@ -132,6 +133,7 @@ class FreshRSS_Context {
/**
* Returns the current state with or without $state parameter.
+ * @param int $state
*/
public static function getRevertState($state) {
if (self::$state & $state) {
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php
index 7b7f5f53e..2e4f52d0b 100644
--- a/app/Models/EntryDAO.php
+++ b/app/Models/EntryDAO.php
@@ -546,7 +546,7 @@ SQL;
* @param integer $idMax max article ID
* @return integer affected rows
*/
- public function markReadTag($id = '', $idMax = 0, $filters = null, $state = 0, $is_read = true) {
+ public function markReadTag($id = 0, $idMax = 0, $filters = null, $state = 0, $is_read = true) {
FreshRSS_UserDAO::touch();
if ($idMax == 0) {
$idMax = time() . '000000';
@@ -556,10 +556,10 @@ SQL;
$sql = 'UPDATE `_entry` e INNER JOIN `_entrytag` et ON et.id_entry = e.id '
. 'SET e.is_read = ? '
. 'WHERE '
- . ($id == '' ? '' : 'et.id_tag = ? AND ')
+ . ($id == 0 ? '' : 'et.id_tag = ? AND ')
. 'e.is_read <> ? AND e.id <= ?';
$values = array($is_read ? 1 : 0);
- if ($id != '') {
+ if ($id != 0) {
$values[] = $id;
}
$values[] = $is_read ? 1 : 0;
diff --git a/app/Models/EntryDAOSQLite.php b/app/Models/EntryDAOSQLite.php
index f0b9a318b..65df483ff 100644
--- a/app/Models/EntryDAOSQLite.php
+++ b/app/Models/EntryDAOSQLite.php
@@ -246,7 +246,7 @@ DROP TABLE IF EXISTS `tmp`;
* @param integer $idMax max article ID
* @return integer affected rows
*/
- public function markReadTag($id = '', $idMax = 0, $filters = null, $state = 0, $is_read = true) {
+ public function markReadTag($id = 0, $idMax = 0, $filters = null, $state = 0, $is_read = true) {
FreshRSS_UserDAO::touch();
if ($idMax == 0) {
$idMax = time() . '000000';
@@ -257,10 +257,10 @@ DROP TABLE IF EXISTS `tmp`;
. 'SET is_read = ? '
. 'WHERE is_read <> ? AND id <= ? AND '
. 'id IN (SELECT et.id_entry FROM `_entrytag` et '
- . ($id == '' ? '' : 'WHERE et.id_tag = ?')
+ . ($id == 0 ? '' : 'WHERE et.id_tag = ?')
. ')';
$values = array($is_read ? 1 : 0, $is_read ? 1 : 0, $idMax);
- if ($id != '') {
+ if ($id != 0) {
$values[] = $id;
}
diff --git a/app/Models/Share.php b/app/Models/Share.php
index f536418fc..695b16eca 100644
--- a/app/Models/Share.php
+++ b/app/Models/Share.php
@@ -11,7 +11,7 @@ class FreshRSS_Share {
/**
* Register a new sharing option.
- * @param $share_options is an array defining the share option.
+ * @param array<string,string> $share_options is an array defining the share option.
*/
public static function register($share_options) {
$type = $share_options['type'];
@@ -31,7 +31,7 @@ class FreshRSS_Share {
/**
* Register sharing options in a file.
- * @param $filename the name of the file to load.
+ * @param string $filename the name of the file to load.
*/
public static function load($filename) {
$shares_from_file = @include($filename);
@@ -51,7 +51,7 @@ class FreshRSS_Share {
/**
* Return the list of sharing options.
- * @return array[FreshRSS_Share]
+ * @return array<FreshRSS_Share>
*/
public static function enum() {
return self::$list_sharing;
@@ -59,7 +59,7 @@ class FreshRSS_Share {
/**
* Return FreshRSS_Share object related to the given type.
- * @param $type the share type, null if $type is not registered.
+ * @param string $type the share type, null if $type is not registered.
*/
public static function get($type) {
if (!isset(self::$list_sharing[$type])) {
@@ -88,14 +88,14 @@ class FreshRSS_Share {
/**
* Create a FreshRSS_Share object.
- * @param $type is a unique string defining the kind of share option.
- * @param $url_transform defines the url format to use in order to share.
- * @param $transform is an array of transformations to apply on link and title.
- * @param $form_type defines which form we have to use to complete. "simple"
+ * @param string $type is a unique string defining the kind of share option.
+ * @param string $url_transform defines the url format to use in order to share.
+ * @param array<string> $transform is an array of transformations to apply on link and title.
+ * @param string $form_type defines which form we have to use to complete. "simple"
* is typically for a centralized service while "advanced" is for
* decentralized ones.
- * @param $help_url is an optional url to give help on this option.
- * @param $method defines the sharing method (GET or POST)
+ * @param string $help_url is an optional url to give help on this option.
+ * @param string $method defines the sharing method (GET or POST)
*/
private function __construct($type, $url_transform, $transform, $form_type, $help_url, $method, $field) {
$this->type = $type;
@@ -121,7 +121,7 @@ class FreshRSS_Share {
/**
* Update a FreshRSS_Share object with information from an array.
- * @param $options is a list of informations to update where keys should be
+ * @param array<string,string> $options is a list of informations to update where keys should be
* in this list: name, url, id, title, link.
*/
public function update($options) {
@@ -217,7 +217,7 @@ class FreshRSS_Share {
/**
* Return the id.
- * @param $raw true if we should get the id without transformations.
+ * @param bool $raw true if we should get the id without transformations.
*/
public function id($raw = false) {
if ($raw) {
@@ -229,7 +229,7 @@ class FreshRSS_Share {
/**
* Return the title.
- * @param $raw true if we should get the title without transformations.
+ * @param bool $raw true if we should get the title without transformations.
*/
public function title($raw = false) {
if ($raw) {
@@ -241,7 +241,7 @@ class FreshRSS_Share {
/**
* Return the link.
- * @param $raw true if we should get the link without transformations.
+ * @param bool $raw true if we should get the link without transformations.
*/
public function link($raw = false) {
if ($raw) {
@@ -253,8 +253,8 @@ class FreshRSS_Share {
/**
* Transform a data with the given functions.
- * @param $data the data to transform.
- * @param $tranform an array containing a list of functions to apply.
+ * @param string $data the data to transform.
+ * @param array<string> $transform an array containing a list of functions to apply.
* @return mixed the transformed data.
*/
private static function transform($data, $transform) {
@@ -273,8 +273,8 @@ class FreshRSS_Share {
/**
* Get the list of transformations for the given attribute.
- * @param $attr the attribute of which we want the transformations.
- * @return an array containing a list of transformations to apply.
+ * @param string $attr the attribute of which we want the transformations.
+ * @return array<string> containing a list of transformations to apply.
*/
private function getTransform($attr) {
if (array_key_exists($attr, $this->transform)) {
diff --git a/app/Models/TagDAO.php b/app/Models/TagDAO.php
index 03ef5421b..a0e492739 100644
--- a/app/Models/TagDAO.php
+++ b/app/Models/TagDAO.php
@@ -70,6 +70,9 @@ SQL;
}
}
+ /**
+ * @param FreshRSS_Tag $tag
+ */
public function addTagObject($tag) {
$tag = $this->searchByName($tag->name());
if (!$tag) {
@@ -82,6 +85,9 @@ SQL;
return $tag->id();
}
+ /**
+ * @return integer|false
+ */
public function updateTag($id, $valuesTmp) {
// No category of the same name
$sql = <<<'SQL'
@@ -111,6 +117,9 @@ SQL;
}
}
+ /**
+ * @return integer|false
+ */
public function updateTagAttribute($tag, $key, $value) {
if ($tag instanceof FreshRSS_Tag) {
$tag->_attributes($key, $value);
@@ -122,6 +131,9 @@ SQL;
return false;
}
+ /**
+ * @return integer|false
+ */
public function deleteTag($id) {
if ($id <= 0) {
return false;
@@ -156,6 +168,9 @@ SQL;
}
}
+ /**
+ * @return integer|false
+ */
public function updateEntryTag($oldTagId, $newTagId) {
$sql = <<<'SQL'
DELETE FROM `_entrytag` WHERE EXISTS (
@@ -182,6 +197,9 @@ SQL;
}
}
+ /**
+ * @return FreshRSS_Tag
+ */
public function searchById($id) {
$sql = 'SELECT * FROM `_tag` WHERE id=?';
$stm = $this->pdo->prepare($sql);
@@ -192,6 +210,9 @@ SQL;
return isset($tag[0]) ? $tag[0] : null;
}
+ /**
+ * @return FreshRSS_Tag
+ */
public function searchByName($name) {
$sql = 'SELECT * FROM `_tag` WHERE name=?';
$stm = $this->pdo->prepare($sql);