From d08f91e4cbfca3a0f2d570451dd7453f834e2b9e Mon Sep 17 00:00:00 2001 From: Hystepik Date: Thu, 21 Dec 2023 13:43:19 +0100 Subject: [PATCH] Fix some phpstan warnings --- htdocs/commande/class/commande.class.php | 6 +++--- htdocs/compta/bank/class/account.class.php | 4 ++-- .../compta/facture/class/facture-rec.class.php | 8 ++++---- htdocs/compta/facture/class/facture.class.php | 18 +++++++++--------- .../cheque/class/remisecheque.class.php | 2 +- .../compta/paiement/class/paiement.class.php | 2 +- .../prelevement/class/bonprelevement.class.php | 2 +- htdocs/contrat/class/contrat.class.php | 8 ++++---- htdocs/core/class/comment.class.php | 2 +- htdocs/core/class/commondocgenerator.class.php | 4 ++-- htdocs/core/class/commonobject.class.php | 4 ++-- htdocs/core/class/discount.class.php | 2 +- htdocs/core/class/doleditor.class.php | 4 ++-- 13 files changed, 33 insertions(+), 33 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 5ec0a3374d1..815c776ad26 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3092,8 +3092,8 @@ class Commande extends CommonOrder * @param float $txlocaltax2 Local tax 2 rate * @param string $price_base_type HT or TTC * @param int $info_bits Miscellaneous informations on line - * @param int $date_start Start date of the line - * @param int $date_end End date of the line + * @param int|string $date_start Start date of the line + * @param int|string $date_end End date of the line * @param int $type Type of line (0=product, 1=service) * @param int $fk_parent_line Id of parent line (0 in most cases, used by modules adding sublevels into lines). * @param int $skip_update_total Keep fields total_xxx to 0 (used for special lines by some modules) @@ -3109,7 +3109,7 @@ class Commande extends CommonOrder * @param integer $rang line rank * @return int Return integer < 0 if KO, > 0 if OK */ - public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $price_base_type = 'HT', $info_bits = 0, $date_start = '', $date_end = '', $type = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $ref_ext = '', $rang = 0) + public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $price_base_type = 'HT', $info_bits = 0, $date_start = '', $date_end = '', $type = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = array(), $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $ref_ext = '', $rang = 0) { global $conf, $mysoc, $langs, $user; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index c6ad77c7475..bdeed68f0b0 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -491,7 +491,7 @@ class Account extends CommonObject * @param string $type To search using type * @return array|int Array of links array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> ) or -1 on error */ - public function get_url($fk_bank = '', $url_id = '', $type = '') + public function get_url($fk_bank = 0, $url_id = 0, $type = '') { // phpcs:enable $lines = array(); @@ -1258,7 +1258,7 @@ class Account extends CommonObject * Return current sold * * @param int $option 1=Exclude future operation date (this is to exclude input made in advance and have real account sold) - * @param int $date_end Date until we want to get bank account sold + * @param int|string $date_end Date until we want to get bank account sold * @param string $field dateo or datev * @return int current sold (value date <= today) */ diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 1410c86b0dd..9a0127134fa 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -873,7 +873,7 @@ class FactureRec extends CommonInvoice * @param int $fk_parent_line Id of parent line * @return int Return integer <0 if KO, Id of line if OK */ - public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $date_start_fill = 0, $date_end_fill = 0, $fk_fournprice = null, $pa_ht = 0, $fk_parent_line = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = 0, $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $date_start_fill = 0, $date_end_fill = 0, $fk_fournprice = null, $pa_ht = 0, $fk_parent_line = 0) { global $mysoc; @@ -1080,7 +1080,7 @@ class FactureRec extends CommonInvoice * @param int $fk_parent_line Id of parent line * @return int Return integer <0 if KO, Id of line if OK */ - public function updateline($rowid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $date_start_fill = 0, $date_end_fill = 0, $fk_fournprice = null, $pa_ht = 0, $fk_parent_line = 0) + public function updateline($rowid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = 0, $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $date_start_fill = 0, $date_end_fill = 0, $fk_fournprice = null, $pa_ht = 0, $fk_parent_line = 0) { global $mysoc; @@ -1447,7 +1447,7 @@ class FactureRec extends CommonInvoice * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = '', $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1) { global $langs, $hookmanager; @@ -2172,7 +2172,7 @@ class FactureLigneRec extends CommonInvoiceLine * @param int $notrigger Disable triggers * @return int Return integer <0 if KO, >0 if OK */ - public function delete(User $user, $notrigger = false) + public function delete(User $user, $notrigger = 0) { $error = 0; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index b277db0da53..dad469a8eea 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2113,7 +2113,7 @@ class Facture extends CommonInvoice * @param bool $fetch_situation Load also the previous and next situation invoice into $tab_previous_situation_invoice and $tab_next_situation_invoice * @return int >0 if OK, <0 if KO, 0 if not found */ - public function fetch($rowid, $ref = '', $ref_ext = '', $notused = '', $fetch_situation = false) + public function fetch($rowid, $ref = '', $ref_ext = '', $notused = 0, $fetch_situation = false) { if (empty($rowid) && empty($ref) && empty($ref_ext)) { return -1; @@ -3747,8 +3747,8 @@ class Facture extends CommonInvoice * @param double $txlocaltax2 Local tax 2 rate (deprecated, use instead txtva with code inside) * @param int $fk_product Id of predefined product/service * @param double $remise_percent Percent of discount on line - * @param int $date_start Date start of service - * @param int $date_end Date end of service + * @param int|string $date_start Date start of service + * @param int|string $date_end Date end of service * @param int $ventil Code of dispatching into accountancy * @param int $info_bits Bits of type of lines * @param int $fk_remise_except Id discount used @@ -3785,7 +3785,7 @@ class Facture extends CommonInvoice $date_end = '', $ventil = 0, $info_bits = 0, - $fk_remise_except = '', + $fk_remise_except = 0, $price_base_type = 'HT', $pu_ttc = 0, $type = 0, @@ -3797,7 +3797,7 @@ class Facture extends CommonInvoice $fk_fournprice = null, $pa_ht = 0, $label = '', - $array_options = 0, + $array_options = array(), $situation_percent = 100, $fk_prev_id = 0, $fk_unit = null, @@ -4068,7 +4068,7 @@ class Facture extends CommonInvoice * @param integer $rang rank of line * @return int Return integer < 0 if KO, > 0 if OK */ - public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = self::TYPE_STANDARD, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $situation_percent = 100, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $ref_ext = '', $rang = 0) + public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = self::TYPE_STANDARD, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = array(), $situation_percent = 100, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $ref_ext = '', $rang = 0) { global $conf, $user; // Deprecation warning @@ -4709,7 +4709,7 @@ class Facture extends CommonInvoice * @param string $sortorder Sort order * @return array|int -1 if KO, array with result if OK */ - public function liste_array($shortlist = 0, $draft = 0, $excluser = '', $socid = 0, $limit = 0, $offset = 0, $sortfield = 'f.datef,f.rowid', $sortorder = 'DESC') + public function liste_array($shortlist = 0, $draft = 0, $excluser = null, $socid = 0, $limit = 0, $offset = 0, $sortfield = 'f.datef,f.rowid', $sortorder = 'DESC') { // phpcs:enable global $conf, $user; @@ -5581,7 +5581,7 @@ class Facture extends CommonInvoice * @param string $dateYmd date limit of retained warranty in Y m d format * @return int >0 if OK, <0 if KO */ - public function setRetainedWarrantyDateLimit($timestamp, $dateYmd = false) + public function setRetainedWarrantyDateLimit($timestamp, $dateYmd = '') { if (!$timestamp && $dateYmd) { $timestamp = $this->db->jdate($dateYmd); @@ -6449,7 +6449,7 @@ class FactureLigne extends CommonInvoiceLine * @param int $notrigger Disable triggers * @return int Return integer <0 if KO, >0 if OK */ - public function update($user = '', $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $user, $conf; diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 562d9da587f..7eba56434fe 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -291,7 +291,7 @@ class RemiseCheque extends CommonObject * @param User $user User that delete * @return int */ - public function delete($user = '') + public function delete($user = null) { global $conf; diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index ffb3f5083b8..64335484aa1 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -178,7 +178,7 @@ class Paiement extends CommonObject * @param int $fk_bank Id of bank line associated to payment * @return int Return integer <0 if KO, 0 if not found, >0 if OK */ - public function fetch($id, $ref = '', $fk_bank = '') + public function fetch($id, $ref = '', $fk_bank = 0) { $sql = 'SELECT p.rowid, p.ref, p.ref_ext, p.datep as dp, p.amount, p.statut, p.ext_payment_id, p.ext_payment_site, p.fk_bank, p.multicurrency_amount,'; $sql .= ' c.code as type_code, c.libelle as type_label,'; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 6ec256df84f..48b82d45d8a 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -954,7 +954,7 @@ class BonPrelevement extends CommonObject * @param string $type 'direct-debit' or 'bank-transfer' * @param int $did ID of an existing payment request. If $did is defined, we use the existing payment request. * @param int $fk_bank_account Bank account ID the receipt is generated for. Will use the ID into the setup of module Direct Debit or Credit Transfer if 0. - * @param int $sourcetype 'invoice' or 'salary' + * @param string $sourcetype 'invoice' or 'salary' * @return int Return integer <0 if KO, No of invoice included into file if OK */ public function create($banque = 0, $agence = 0, $mode = 'real', $format = 'ALL', $executiondate = '', $notrigger = 0, $type = 'direct-debit', $did = 0, $fk_bank_account = 0, $sourcetype = 'invoice') diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index d524c6973a1..ac760bd8ecc 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1474,10 +1474,10 @@ class Contrat extends CommonObject * @param int $pa_ht Buying price HT * @param array $array_options extrafields array * @param string $fk_unit Code of the unit to use. Null to use the default one - * @param string $rang Position + * @param int $rang Position * @return int Return integer <0 if KO, >0 if OK */ - public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type = 'HT', $pu_ttc = 0.0, $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = 0, $fk_unit = null, $rang = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type = 'HT', $pu_ttc = 0.0, $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = array(), $fk_unit = null, $rang = 0) { global $user, $langs, $conf, $mysoc; $error = 0; @@ -1706,10 +1706,10 @@ class Contrat extends CommonObject * @param int $pa_ht Buying price HT * @param array $array_options extrafields array * @param string $fk_unit Code of the unit to use. Null to use the default one - * @param string $rang Position + * @param int $rang Position * @return int Return integer <0 if KO, >0 if OK */ - public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx = 0.0, $localtax2tx = 0.0, $date_start_real = '', $date_end_real = '', $price_base_type = 'HT', $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = 0, $fk_unit = null, $rang = 0) + public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx = 0.0, $localtax2tx = 0.0, $date_start_real = '', $date_end_real = '', $price_base_type = 'HT', $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = array(), $fk_unit = null, $rang = 0) { global $user, $conf, $langs, $mysoc; diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php index 3bae32d81e3..491c84f2a11 100644 --- a/htdocs/core/class/comment.class.php +++ b/htdocs/core/class/comment.class.php @@ -177,7 +177,7 @@ class Comment extends CommonObject * Load object in memory from database * * @param int $id Id object - * @param int $ref ref object + * @param string $ref ref object * @return int Return integer <0 if KO, 0 if not found, >0 if OK */ public function fetch($id, $ref = '') diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index e211cd631d0..9b6c0b4bf75 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -825,7 +825,7 @@ abstract class CommonDocGenerator * * @param Expedition $object Main object to use as data source * @param Translate $outputlangs Lang object to use for output - * @param array $array_key Name of the key for return array + * @param string $array_key Name of the key for return array * @return array Array of substitution */ public function get_substitutionarray_shipment($object, $outputlangs, $array_key = 'object') @@ -1189,7 +1189,7 @@ abstract class CommonDocGenerator * @param bool $insertAfterTarget insert before or after target column ? * @return int new rank on success and -1 on error */ - public function insertNewColumnDef($newColKey, $defArray, $targetCol = false, $insertAfterTarget = false) + public function insertNewColumnDef($newColKey, $defArray, $targetCol = '', $insertAfterTarget = false) { // prepare wanted rank $rank = -1; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 4ab1a0577ff..8628d98ab2e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4342,7 +4342,7 @@ abstract class CommonObject * @return int >0 if OK, <0 if KO * @see add_object_linked(), updateObjectLinked(), fetchObjectLinked() */ - public function deleteObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $rowid = '', $f_user = null, $notrigger = 0) + public function deleteObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $rowid = 0, $f_user = null, $notrigger = 0) { global $user; $deletesource = false; @@ -8490,7 +8490,7 @@ abstract class CommonObject * @param string $display_type "card" for form display, "line" for document line display (extrafields on propal line, order line, etc...) * @return string String with html content to show */ - public function showOptionals($extrafields, $mode = 'view', $params = null, $keysuffix = '', $keyprefix = '', $onetrtd = 0, $display_type = 'card') + public function showOptionals($extrafields, $mode = 'view', $params = null, $keysuffix = '', $keyprefix = '', $onetrtd = '', $display_type = 'card') { global $db, $conf, $langs, $action, $form, $hookmanager; diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index f92ce30e087..07e3ffe8d94 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -532,7 +532,7 @@ class DiscountAbsolute * @param int $multicurrency Return multicurrency_amount instead of amount * @return int Return integer <0 if KO, amount otherwise */ - public function getAvailableDiscounts($company = '', $user = '', $filter = '', $maxvalue = 0, $discount_type = 0, $multicurrency = 0) + public function getAvailableDiscounts($company = null, $user = null, $filter = '', $maxvalue = 0, $discount_type = 0, $multicurrency = 0) { global $conf; diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 4a9d216bca2..6e7e59f21f0 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -54,7 +54,7 @@ class DolEditor * * @param string $htmlname HTML name of WYSIWIG field * @param string $content Content of WYSIWIG field - * @param int $width Width in pixel of edit area (auto by default) + * @param int|string $width Width in pixel of edit area (auto by default) * @param int $height Height in pixel of edit area (200px by default) * @param string $toolbarname Name of bar set to use ('Full', 'dolibarr_notes[_encoded]', 'dolibarr_details[_encoded]'=the less featured, 'dolibarr_mailings[_encoded]', 'dolibarr_readonly'). * @param string $toolbarlocation Deprecated. Not used @@ -67,7 +67,7 @@ class DolEditor * @param int $readonly 0=Read/Edit, 1=Read only * @param array $poscursor Array for initial cursor position array('x'=>x, 'y'=>y) */ - public function __construct($htmlname, $content, $width = '', $height = 200, $toolbarname = 'Basic', $toolbarlocation = 'In', $toolbarstartexpanded = false, $uselocalbrowser = 1, $okforextendededitor = true, $rows = 0, $cols = 0, $readonly = 0, $poscursor = array()) + public function __construct($htmlname, $content, $width = '', $height = 200, $toolbarname = 'Basic', $toolbarlocation = 'In', $toolbarstartexpanded = false, $uselocalbrowser = 1, $okforextendededitor = true, $rows = 0, $cols = '', $readonly = 0, $poscursor = array()) { global $conf;