From 27792fe1adc45eef1e6a05536121fb042b9ee6bc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Jan 2023 18:34:54 +0100 Subject: [PATCH] Fix qodana --- htdocs/commande/class/api_orders.class.php | 6 +++--- htdocs/compta/bank/class/api_bankaccounts.class.php | 10 +++++----- htdocs/core/class/comment.class.php | 6 ++++-- htdocs/core/class/evalmath.class.php | 13 +++++++------ htdocs/core/class/html.formticket.class.php | 3 +-- htdocs/core/class/openid.class.php | 4 ++-- .../core/modules/propale/doc/pdf_azur.modules.php | 2 +- .../supplier_proposal/doc/pdf_aurore.modules.php | 2 +- htdocs/projet/class/api_projects.class.php | 5 ++--- htdocs/projet/class/project.class.php | 2 +- htdocs/user/class/user.class.php | 2 +- htdocs/user/class/usergroup.class.php | 12 ++++++------ 12 files changed, 34 insertions(+), 33 deletions(-) diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 8e389d862d3..1a879173684 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -108,11 +108,11 @@ class Orders extends DolibarrApi * * Return an array with order informations * - * @param int $id ID of order + * @param int $id ID of order * @param string $ref Ref of object * @param string $ref_ext External reference of object - * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id - * @return array|mixed data without useless information + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return Object Object with cleaned properties * * @throws RestException */ diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index c9886a176f0..537c7c9acb6 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -122,8 +122,8 @@ class BankAccounts extends DolibarrApi /** * Get account by ID. * - * @param int $id ID of account - * @return array Account object + * @param int $id ID of account + * @return Object Object with cleaned properties * * @throws RestException */ @@ -313,9 +313,9 @@ class BankAccounts extends DolibarrApi /** * Update account * - * @param int $id ID of account - * @param array $request_data data - * @return int + * @param int $id ID of account + * @param array $request_data data + * @return Object Object with cleaned properties */ public function put($id, $request_data = null) { diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php index 960d2ac4744..4a743e5b070 100644 --- a/htdocs/core/class/comment.class.php +++ b/htdocs/core/class/comment.class.php @@ -351,16 +351,18 @@ class Comment extends CommonObject /** - * Load comments linked with current task + * Load comments linked with current task into ->comments * * @param string $element_type Element type * @param int $fk_element Id of element - * @return array Comment array + * @return int Result */ public function fetchAllFor($element_type, $fk_element) { global $db, $conf; + $this->comments = array(); + if (!empty($element_type) && !empty($fk_element)) { $sql = "SELECT"; $sql .= " c.rowid"; diff --git a/htdocs/core/class/evalmath.class.php b/htdocs/core/class/evalmath.class.php index f2dfb80960e..9c01f133bf6 100644 --- a/htdocs/core/class/evalmath.class.php +++ b/htdocs/core/class/evalmath.class.php @@ -198,9 +198,9 @@ class EvalMath } /** - * vars + * Function vars * - * @return string Output + * @return array Output */ public function vars() { @@ -211,9 +211,9 @@ class EvalMath } /** - * vars + * Function funcs * - * @return string Output + * @return array Output */ private function funcs() { @@ -229,8 +229,8 @@ class EvalMath /** * Convert infix to postfix notation * - * @param string $expr Expression - * @return string Output + * @param string $expr Expression + * @return boolean|array Output */ private function nfx($expr) { @@ -367,6 +367,7 @@ class EvalMath } $output[] = $op; } + return $output; } diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 0aa2c39de91..a34861e17d6 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -779,7 +779,7 @@ class FormTicket * @param string $morecss More CSS * @param int $use_multilevel If > 0 create a multilevel select which use $htmlname example: $use_multilevel = 1 permit to have 2 select boxes. * @param Translate $outputlangs Output language - * @return void + * @return string|void String of HTML component */ public function selectGroupTickets($selected = '', $htmlname = 'ticketcategory', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss = '', $use_multilevel = 0, $outputlangs = null) { @@ -985,7 +985,6 @@ class FormTicket } $sql = substr($sql, 0, -2); $sql .= ")"; - } else { } $sql .= $this->db->order('ctc.pos', 'ASC'); diff --git a/htdocs/core/class/openid.class.php b/htdocs/core/class/openid.class.php index 79cf9137a99..7198f532358 100644 --- a/htdocs/core/class/openid.class.php +++ b/htdocs/core/class/openid.class.php @@ -178,7 +178,7 @@ class SimpleOpenID /** * SetOpenIDServer * - * @return void + * @return array */ public function GetError() { @@ -225,7 +225,7 @@ class SimpleOpenID * splitResponse * * @param string $response Server - * @return void + * @return array */ public function splitResponse($response) { diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index ff5283e2bb8..eac6e0261ee 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -907,7 +907,7 @@ class pdf_azur extends ModelePDFPropales * @param Propal $object Object to show * @param int $posy Y * @param Translate $outputlangs Langs object - * @return void + * @return int */ protected function _tableau_info(&$pdf, $object, $posy, $outputlangs) { diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 8e25a227ad7..ff90b500969 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -744,7 +744,7 @@ class pdf_aurore extends ModelePDFSupplierProposal * @param Object $object Object to show * @param int $posy Y * @param Translate $outputlangs Langs object - * @return void + * @return int */ protected function _tableau_info(&$pdf, $object, $posy, $outputlangs) { diff --git a/htdocs/projet/class/api_projects.class.php b/htdocs/projet/class/api_projects.class.php index 6a18057afd5..8cbb3949cd5 100644 --- a/htdocs/projet/class/api_projects.class.php +++ b/htdocs/projet/class/api_projects.class.php @@ -29,7 +29,6 @@ */ class Projects extends DolibarrApi { - /** * @var array $FIELDS Mandatory fields, checked when create and update object */ @@ -267,10 +266,9 @@ class Projects extends DolibarrApi * * @param int $id Id of project * @param int $userid Id of user (0 = connected user) + * @return array * * @url GET {id}/roles - * - * @return int */ public function getRoles($id, $userid = 0) { @@ -301,6 +299,7 @@ class Projects extends DolibarrApi foreach ($this->project->roles as $line) { array_push($result, $this->_cleanObjectDatas($line)); } + return $result; } diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 57235d491da..79ea13dcd40 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1480,7 +1480,7 @@ class Project extends CommonObject * @param int $list 0=Return array, 1=Return string list * @param int $socid 0=No filter on third party, id of third party * @param string $filter additionnal filter on project (statut, ref, ...) - * @return array or string Array of projects id, or string with projects id separated with "," if list is 1 + * @return array|string Array of projects id, or string with projects id separated with "," if list is 1 */ public function getProjectsAuthorizedForUser($user, $mode = 0, $list = 0, $socid = 0, $filter = '') { diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 5c0f3f15b45..a4d4c7acfe6 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -3489,7 +3489,7 @@ class User extends CommonObject * * @param int $deleteafterid Removed all users including the leaf $deleteafterid (and all its child) in user tree. * @param string $filter SQL filter on users. This parameter must not come from user intput. - * @return array Array of users $this->users. Note: $this->parentof is also set. + * @return array|int Array of users $this->users. Note: $this->parentof is also set. */ public function get_full_tree($deleteafterid = 0, $filter = '') { diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 849b08bc7f6..71339991172 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -180,9 +180,9 @@ class UserGroup extends CommonObject /** * Return array of groups objects for a particular user * - * @param int $userid User id to search - * @param boolean $load_members Load all members of the group - * @return array Array of groups objects + * @param int $userid User id to search + * @param boolean $load_members Load all members of the group + * @return array|int Array of groups objects */ public function listGroupsForUser($userid, $load_members = true) { @@ -544,7 +544,7 @@ class UserGroup extends CommonObject * Charge dans l'objet group, la liste des permissions auquels le groupe a droit * * @param string $moduletag Name of module we want permissions ('' means all) - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, >=0 if OK */ public function getrights($moduletag = '') { @@ -552,12 +552,12 @@ class UserGroup extends CommonObject if ($moduletag && isset($this->_tab_loaded[$moduletag]) && $this->_tab_loaded[$moduletag]) { // Rights for this module are already loaded, so we leave - return; + return 0; } if (!empty($this->all_permissions_are_loaded)) { // We already loaded all rights for this group, so we leave - return; + return 0; } /*