From f39a439895b7ea355f8af69428a84bc7d2fa22f4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Jan 2024 03:35:00 +0100 Subject: [PATCH] Clean code --- htdocs/adherents/class/api_members.class.php | 6 +++--- .../categories/class/api_categories.class.php | 17 ++++++++--------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index ea7da54148b..5cb0ee3c09c 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -423,7 +423,7 @@ class Members extends DolibarrApi * Validate fields before creating an object * * @param array|null $data Data to validate - * @return array + * @return array Return array with validated mandatory fields and their value * * @throws RestException */ @@ -443,8 +443,8 @@ class Members extends DolibarrApi /** * Clean sensible object datas * - * @param Object $object Object to clean - * @return Object Object with cleaned properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 159d7925e3a..12d8cd01284 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -70,7 +70,8 @@ class Categories extends DolibarrApi */ public function __construct() { - global $db, $conf; + global $db; + $this->db = $db; $this->category = new Categorie($this->db); } @@ -133,8 +134,6 @@ class Categories extends DolibarrApi */ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $sqlfilters = '', $properties = '') { - global $db, $conf; - $obj_ret = array(); if (!DolibarrApiAccess::$user->rights->categorie->lire) { @@ -198,8 +197,8 @@ class Categories extends DolibarrApi throw new RestException(401); } - // Check mandatory fields - $result = $this->_validate($request_data); + // Check mandatory fields (throw an exception if wrong) + $this->_validate($request_data); foreach ($request_data as $field => $value) { if ($field === 'caller') { @@ -666,8 +665,8 @@ class Categories extends DolibarrApi /** * Clean sensible object datas * - * @param Categorie $object Object to clean - * @return Object Object with cleaned properties + * @param Categorie $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { @@ -722,8 +721,8 @@ class Categories extends DolibarrApi /** * Validate fields before create or update object * - * @param array|null $data Data to validate - * @return array + * @param array|null $data Data to validate + * @return array Return array with validated mandatory fields and their value * * @throws RestException */