From c5479f45207457a4563c5fa40b9e30fa4a72bdd7 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 15:55:46 +0100 Subject: [PATCH 01/36] Fix: Update typing for qty as float --- htdocs/bom/class/bom.class.php | 12 ++++++------ htdocs/comm/propal/class/propal.class.php | 4 ++-- htdocs/core/lib/price.lib.php | 3 ++- htdocs/delivery/class/delivery.class.php | 2 +- htdocs/expedition/class/expedition.class.php | 4 ++-- htdocs/fourn/class/fournisseur.product.class.php | 11 ++++++----- htdocs/product/class/product.class.php | 4 ++-- htdocs/product/stock/class/mouvementstock.class.php | 10 +++++----- htdocs/reception/class/reception.class.php | 2 +- .../class/supplier_proposal.class.php | 9 +++++---- 10 files changed, 32 insertions(+), 29 deletions(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 72aab83ac21..b8cfedf697d 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -580,7 +580,7 @@ class BOM extends CommonObject * * @param int $fk_product Id of product * @param float $qty Quantity - * @param int $qty_frozen Frozen quantity + * @param float $qty_frozen Frozen quantity * @param int $disable_stock_change Disable stock change on using in MO * @param float $efficiency Efficiency in MO * @param int $position Position of BOM-Line in BOM-Lines @@ -689,7 +689,7 @@ class BOM extends CommonObject * * @param int $rowid Id of line to update * @param float $qty Quantity - * @param int $qty_frozen Frozen quantity + * @param float $qty_frozen Frozen quantity * @param int $disable_stock_change Disable stock change on using in MO * @param float $efficiency Efficiency in MO * @param int $position Position of BOM-Line in BOM-Lines @@ -1531,8 +1531,8 @@ class BOM extends CommonObject /** * Get Net needs by product * - * @param array $TNetNeeds Array of ChildBom and infos linked to - * @param int $qty qty needed + * @param array $TNetNeeds Array of ChildBom and infos linked to + * @param float $qty qty needed * @return void */ public function getNetNeeds(&$TNetNeeds = array(), $qty = 0) @@ -1557,7 +1557,7 @@ class BOM extends CommonObject * Get Net needs Tree by product or bom * * @param array $TNetNeeds Array of ChildBom and infos linked to - * @param int $qty qty needed + * @param float $qty qty needed * @param int $level level of recursivity * @return void */ @@ -1763,7 +1763,7 @@ class BOMLine extends CommonObjectLine public $qty; /** - * @var int qty frozen + * @var float qty frozen */ public $qty_frozen; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 9ea34ae4d3a..6a10c7fbb14 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -413,8 +413,8 @@ class Propal extends CommonObject * $this->thirdparty should be loaded * * @param int $idproduct Product Id to add - * @param int $qty Quantity - * @param int $remise_percent Discount effected on Product + * @param float $qty Quantity + * @param float $remise_percent Discount effected on Product * @return int Return integer <0 if KO, >0 if OK * * TODO Replace calls to this function by generation object Ligne diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index 0d448eb4142..9da3eaf69c2 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -6,6 +6,7 @@ * Copyright (C) 2012 Cédric Salvador * Copyright (C) 2012-2014 Raphaël Doursenaud * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,7 +38,7 @@ * '5' : local tax apply on services without vat (localtax is calculated on amount without tax) * '6' : local tax apply on services including vat (localtax is calculated on amount + tax) * - * @param int $qty Quantity + * @param float $qty Quantity * @param float $pu Unit price (HT or TTC depending on price_base_type. TODO Add also mode 'INCT' when pu is price HT+VAT+LT1+LT2) * @param float $remise_percent_ligne Discount for line * @param float $txtva 0=do not apply VAT tax, VAT rate=apply (this is VAT rate only without text code, we don't need text code because we alreaydy have all tax info into $localtaxes_array) diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index d57a25e96ba..9b964889136 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -633,7 +633,7 @@ class Delivery extends CommonObject * Add line * * @param int $origin_id Origin id - * @param int $qty Qty + * @param float $qty Qty * @param array $array_options Array options * @return void */ diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index dac6efee52c..3f01aceb4e0 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -493,7 +493,7 @@ class Expedition extends CommonObject * * @param int $entrepot_id Id of warehouse * @param int $origin_line_id Id of source line - * @param int $qty Quantity + * @param float $qty Quantity * @param int $rang Rang * @param array $array_options extrafields array * @return int Return integer <0 if KO, line_id if OK @@ -895,7 +895,7 @@ class Expedition extends CommonObject * * @param int $entrepot_id Id of warehouse * @param int $id Id of source line (order line) - * @param int $qty Quantity + * @param float $qty Quantity * @param array $array_options extrafields array * @return int Return integer <0 if KO, >0 if OK */ diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index a809866be18..0a3dffdf3dc 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -8,6 +8,7 @@ * Copyright (C) 2016-2023 Charlene Benke * Copyright (C) 2019-2024 Frédéric France * Copyright (C) 2020 Pierre Ardoin + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -224,7 +225,7 @@ class ProductFournisseur extends Product $this->db = $db; $langs->load("suppliers"); - $this->reputations = array('-1'=>'', 'FAVORITE'=>$langs->trans('Favorite'), 'NOTTHGOOD'=>$langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER'=>$langs->trans('DoNotOrderThisProductToThisSupplier')); + $this->reputations = array('-1' => '', 'FAVORITE' => $langs->trans('Favorite'), 'NOTTHGOOD' => $langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER' => $langs->trans('DoNotOrderThisProductToThisSupplier')); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -512,7 +513,7 @@ class ProductFournisseur extends Product $productfournisseurprice = new ProductFournisseurPrice($this->db); $res = $productfournisseurprice->fetch($this->product_fourn_price_id); if ($res > 0) { - foreach ($options as $key=>$value) { + foreach ($options as $key => $value) { $productfournisseurprice->array_options[$key] = $value; } $res = $productfournisseurprice->update($user); @@ -616,7 +617,7 @@ class ProductFournisseur extends Product $productfournisseurprice = new ProductFournisseurPrice($this->db); $res = $productfournisseurprice->fetch($this->product_fourn_price_id); if ($res > 0) { - foreach ($options as $key=>$value) { + foreach ($options as $key => $value) { $productfournisseurprice->array_options[$key] = $value; } $res = $productfournisseurprice->update($user); @@ -881,7 +882,7 @@ class ProductFournisseur extends Product * Load properties for minimum price * * @param int $prodid Product id - * @param int $qty Minimum quantity + * @param float $qty Minimum quantity * @param int $socid get min price for specific supplier * @return int Return integer <0 if KO, 0=Not found of no product id provided, >0 if OK * @see list_product_fournisseur_price() @@ -1391,7 +1392,7 @@ class ProductFournisseur extends Product global $action; $hookmanager->initHooks(array($this->element . 'dao')); - $parameters = array('id'=>$this->id, 'getnomurl' => &$result); + $parameters = array('id' => $this->id, 'getnomurl' => &$result); $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) { $result = $hookmanager->resPrint; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 17aa0d9a6bb..22dd897127c 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4447,7 +4447,7 @@ class Product extends CommonObject * * @param int $id_pere Id of parent product/service * @param int $id_fils Id of child product/service - * @param int $qty Quantity + * @param float $qty Quantity * @param int $incdec 1=Increase/decrease stock of child when parent stock increase/decrease * @param int $notrigger Disable triggers * @return int Return integer < 0 if KO, > 0 if OK @@ -4520,7 +4520,7 @@ class Product extends CommonObject * * @param int $id_pere Id of parent product/service * @param int $id_fils Id of child product/service - * @param int $qty Quantity + * @param float $qty Quantity * @param int $incdec 1=Increase/decrease stock of child when parent stock increase/decrease * @param int $notrigger Disable triggers * @return int Return integer < 0 if KO, > 0 if OK diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index e49a1904246..d4899512a9d 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -166,7 +166,7 @@ class MouvementStock extends CommonObject * @param User $user User object * @param int $fk_product Id of product * @param int $entrepot_id Id of warehouse - * @param int $qty Qty of movement (can be <0 or >0 depending on parameter type) + * @param float $qty Qty of movement (can be <0 or >0 depending on parameter type) * @param int $type Direction of movement: * 0=input (stock increase by a stock transfer), 1=output (stock decrease by a stock transfer), * 2=output (stock decrease), 3=input (stock increase) @@ -747,7 +747,7 @@ class MouvementStock extends CommonObject * @param User $user Object user * @param int $idProduct Id product * @param int $entrepot_id Warehouse id - * @param int $qty Quantity + * @param float $qty Quantity * @param int $type Type * @param int $price Price * @param string $label Label of movement @@ -810,7 +810,7 @@ class MouvementStock extends CommonObject * @param User $user Object user * @param int $fk_product Id product * @param int $entrepot_id Warehouse id - * @param int $qty Quantity + * @param float $qty Quantity * @param int $price Price * @param string $label Label of stock movement * @param int|string $datem Force date of movement @@ -837,7 +837,7 @@ class MouvementStock extends CommonObject * @param User $user Object user * @param int $fk_product Id product * @param int $entrepot_id Warehouse id - * @param int $qty Quantity + * @param float $qty Quantity * @param int $price Price * @param string $label Label of stock movement * @param integer|string $eatby eat-by date @@ -893,7 +893,7 @@ class MouvementStock extends CommonObject * @param array|int $dluo Could be either * - int if row id of product_batch table (for update) * - or complete array('fk_product_stock'=>, 'batchnumber'=>) - * @param int $qty Quantity of product with batch number. May be a negative amount. + * @param float $qty Quantity of product with batch number. May be a negative amount. * @return int Return integer <0 if KO, -2 if we try to update a product_batchid that does not exist, else return productbatch id */ private function createBatch($dluo, $qty) diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 5a9257f8259..c0a57b045f7 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -817,7 +817,7 @@ class Reception extends CommonObject * * @param int $entrepot_id Id of warehouse * @param int $id Id of source line (supplier order line) - * @param int $qty Quantity + * @param float $qty Quantity * @param array $array_options extrafields array * @param string $comment Comment for stock movement * @param int $eatby eat-by date diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 05f790292a4..06b5a8078cf 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -16,6 +16,7 @@ * Copyright (C) 2019-2024 Frédéric France * Copyright (C) 2020 Tobias Sekan * Copyright (C) 2022 Gauthier VERDOL + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -244,7 +245,7 @@ class SupplierProposal extends CommonObject * Add line into array ->lines * * @param int $idproduct Product Id to add - * @param int $qty Quantity + * @param float $qty Quantity * @param int $remise_percent Discount effected on Product * @return int Return integer <0 if KO, >0 if OK * @@ -1164,7 +1165,7 @@ class SupplierProposal extends CommonObject if (!$error) { // Hook of thirdparty module if (is_object($hookmanager)) { - $parameters = array('objFrom'=>$objFrom); + $parameters = array('objFrom' => $objFrom); $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { @@ -2588,7 +2589,7 @@ class SupplierProposal extends CommonObject } global $action; $hookmanager->initHooks(array($this->element . 'dao')); - $parameters = array('id'=>$this->id, 'getnomurl' => &$result); + $parameters = array('id' => $this->id, 'getnomurl' => &$result); $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) { $result = $hookmanager->resPrint; @@ -2781,7 +2782,7 @@ class SupplierProposal extends CommonObject $return .= '
'.$langs->trans("DateEnd").' : '.dol_print_date($this->delivery_date).''; } if (property_exists($this, 'total_ttc')) { - $return .='
'.$langs->trans("AmountHT").' : '.price($this->total_ttc).''; + $return .= '
'.$langs->trans("AmountHT").' : '.price($this->total_ttc).''; } if (method_exists($this, 'getLibStatut')) { $return .= '
'.$this->getLibStatut(3).'
'; From 6eacf10d67f779c2fd45cdb0c2fe8ad2184ccbbc Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 18:15:38 +0100 Subject: [PATCH 02/36] Fix arg type to preg_match with cast to string --- htdocs/compta/facture/class/facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 17cc796ff97..7c1aabdf072 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -818,7 +818,7 @@ class Facture extends CommonInvoice // Complete vat rate with code $vatrate = $newinvoiceline->tva_tx; - if ($newinvoiceline->vat_src_code && ! preg_match('/\(.*\)/', $vatrate)) { + if ($newinvoiceline->vat_src_code && ! preg_match('/\(.*\)/', (string) $vatrate)) { $vatrate .= ' ('.$newinvoiceline->vat_src_code.')'; } From 9d7eeec786a56760292aa619711254ae689feb94 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 18:17:02 +0100 Subject: [PATCH 03/36] Fix arg type to abs() with cast to float --- htdocs/compta/paiement.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index f7a2026903d..ece32e1d3a5 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -820,8 +820,8 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie // Warning print ''; //print "xx".$amounts[$invoice->id]."-".$amountsresttopay[$invoice->id]."
"; - if (!empty($amounts[$invoice->id]) && (abs($amounts[$invoice->id]) > abs($amountsresttopay[$invoice->id])) - || !empty($multicurrency_amounts[$invoice->id]) && (abs($multicurrency_amounts[$invoice->id]) > abs($multicurrency_amountsresttopay[$invoice->id]))) { + if (!empty($amounts[$invoice->id]) && (abs((float) $amounts[$invoice->id]) > abs((float) $amountsresttopay[$invoice->id])) + || !empty($multicurrency_amounts[$invoice->id]) && (abs((float) $multicurrency_amounts[$invoice->id]) > abs((float) $multicurrency_amountsresttopay[$invoice->id]))) { print ' '.img_warning($langs->trans("PaymentHigherThanReminderToPay")); } print ''; From adf4805ff4445c1c8294653f1bc0a87aa9450ee7 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 18:23:00 +0100 Subject: [PATCH 04/36] Correct typing for tva_tx --- htdocs/core/class/commoninvoice.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index a4843eff0ba..632f8ccf796 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -1908,8 +1908,8 @@ abstract class CommonInvoiceLine extends CommonObjectLine public $vat_src_code; /** - * VAT % - * @var float + * VAT % Vat rate can be like "21.30 (CODE)" + * @var string */ public $tva_tx; From 267961d33b06639129466034c03dfd01321b69fb Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 18:24:42 +0100 Subject: [PATCH 05/36] fixup! Correct typing for tva_tx --- htdocs/core/class/commoninvoice.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 632f8ccf796..680e15fccfb 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -1909,7 +1909,7 @@ abstract class CommonInvoiceLine extends CommonObjectLine /** * VAT % Vat rate can be like "21.30 (CODE)" - * @var string + * @var string|float */ public $tva_tx; From f74273cdec40f129c0437667a69dffcfa4867b86 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 18:26:17 +0100 Subject: [PATCH 06/36] Fix arg type for trim by casting to string --- htdocs/contrat/class/contrat.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 1202e840bd7..36763b00e96 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -3473,7 +3473,7 @@ class ContratLigne extends CommonObjectLine $this->label = trim($this->label); $this->description = trim($this->description); $this->vat_src_code = trim($this->vat_src_code); - $this->tva_tx = trim($this->tva_tx); + $this->tva_tx = trim((string) $this->tva_tx); $this->localtax1_tx = trim($this->localtax1_tx); $this->localtax2_tx = trim($this->localtax2_tx); $this->qty = trim($this->qty); From 85e88990e95d317a1cc87949cb04245985e8c7f5 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 18:29:06 +0100 Subject: [PATCH 07/36] Fix arg type for preg_replace() by casting to string --- htdocs/core/actions_addupdatedelete.inc.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index ab0186f9e2f..64857afa535 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -195,7 +196,7 @@ if ($action == 'add' && !empty($permissiontoadd)) { } $urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist; - $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation + $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', (string) $object->id, $urltogo); // New method to autoselect project after a New on another form object creation $db->commit(); @@ -233,7 +234,7 @@ if ($action == 'update' && !empty($permissiontoadd)) { continue; } } else { - if (!GETPOSTISSET($key) && !preg_match('/^chkbxlst:/', $object->fields[$key]['type']) && $object->fields[$key]['type']!=='checkbox') { + if (!GETPOSTISSET($key) && !preg_match('/^chkbxlst:/', $object->fields[$key]['type']) && $object->fields[$key]['type'] !== 'checkbox') { continue; // The field was not submitted to be saved } } @@ -334,8 +335,8 @@ if ($action == 'update' && !empty($permissiontoadd)) { $result = $object->update($user); if ($result > 0) { $action = 'view'; - $urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist; - $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation + $urltogo = $backtopage ? str_replace('__ID__', (string) $result, $backtopage) : $backurlforlist; + $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', (string) $object->id, $urltogo); // New method to autoselect project after a New on another form object creation if ($urltogo && empty($noback)) { header("Location: " . $urltogo); exit; From 8ea06e9455eb61be9728a519760bc138137163d0 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 18:30:42 +0100 Subject: [PATCH 08/36] Fix arg type for preg_replace() by casting to string --- htdocs/core/class/antivir.class.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/antivir.class.php b/htdocs/core/class/antivir.class.php index f5c38a55820..df06707fe5b 100644 --- a/htdocs/core/class/antivir.class.php +++ b/htdocs/core/class/antivir.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2003 Jean-Louis Bergamo * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -137,11 +138,11 @@ class AntiVir $command = getDolGlobalString('MAIN_ANTIVIRUS_COMMAND'); $param = getDolGlobalString('MAIN_ANTIVIRUS_PARAM'); - $param = preg_replace('/%maxreclevel/', $maxreclevel, $param); - $param = preg_replace('/%maxfiles/', $maxfiles, $param); - $param = preg_replace('/%maxratio/', $maxratio, $param); - $param = preg_replace('/%bz2archivememlim/', $bz2archivememlim, $param); - $param = preg_replace('/%maxfilesize/', $maxfilesize, $param); + $param = preg_replace('/%maxreclevel/', (string) $maxreclevel, $param); + $param = preg_replace('/%maxfiles/', (string) $maxfiles, $param); + $param = preg_replace('/%maxratio/', (string) $maxratio, $param); + $param = preg_replace('/%bz2archivememlim/', (string) $bz2archivememlim, $param); + $param = preg_replace('/%maxfilesize/', (string) $maxfilesize, $param); $param = preg_replace('/%file/', trim($file), $param); if (!preg_match('/%file/', getDolGlobalString('MAIN_ANTIVIRUS_PARAM'))) { From 0975a31b05238399ed978ca16bf76e560a4d9a6c Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 18:31:56 +0100 Subject: [PATCH 09/36] Fix arg type for trim() by casting to string --- htdocs/core/class/comment.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php index 2acb44310aa..f60f5c44183 100644 --- a/htdocs/core/class/comment.class.php +++ b/htdocs/core/class/comment.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -239,7 +240,7 @@ class Comment extends CommonObject // Clean parameters if (isset($this->fk_element)) { - $this->fk_project = (int) trim($this->fk_element); + $this->fk_project = (int) trim((string) $this->fk_element); } if (isset($this->description)) { $this->description = trim($this->description); From dacf116d0762981ce7381c01781eebb43923ef82 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 18:35:08 +0100 Subject: [PATCH 10/36] Fix arg type for abs(), str_replace() with casts --- htdocs/core/class/commonobject.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 9bd531eb262..b826ea69205 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3864,7 +3864,7 @@ abstract class CommonObject $diff = price2num($total_tva_by_vats[$obj->vatrate] - $tmpvat, 'MT', 1); //print 'Line '.$i.' rowid='.$obj->rowid.' vat_rate='.$obj->vatrate.' total_ht='.$obj->total_ht.' total_tva='.$obj->total_tva.' total_ttc='.$obj->total_ttc.' total_ht_by_vats='.$total_ht_by_vats[$obj->vatrate].' total_tva_by_vats='.$total_tva_by_vats[$obj->vatrate].' (new calculation = '.$tmpvat.') total_ttc_by_vats='.$total_ttc_by_vats[$obj->vatrate].($diff?" => DIFF":"")."
\n"; if ($diff) { - if (abs($diff) > (10 * pow(10, -1 * getDolGlobalInt('MAIN_MAX_DECIMALS_TOT', 0)))) { + if (abs((float) $diff) > (10 * pow(10, -1 * getDolGlobalInt('MAIN_MAX_DECIMALS_TOT', 0)))) { // If error is more than 10 times the accuracy of rounding. This should not happen. $errmsg = 'A rounding difference was detected into TOTAL but is too high to be corrected. Some data in your lines may be corrupted. Try to edit each line manually to fix this before restarting.'; dol_syslog($errmsg, LOG_WARNING); @@ -7413,7 +7413,7 @@ abstract class CommonObject // current object id can be use into filter if (strpos($InfoFieldList[4], '$ID$') !== false && !empty($objectid)) { - $InfoFieldList[4] = str_replace('$ID$', $objectid, $InfoFieldList[4]); + $InfoFieldList[4] = str_replace('$ID$', (string) $objectid, $InfoFieldList[4]); } else { $InfoFieldList[4] = str_replace('$ID$', '0', $InfoFieldList[4]); } @@ -7592,7 +7592,7 @@ abstract class CommonObject // current object id can be use into filter if (strpos($InfoFieldList[4], '$ID$') !== false && !empty($objectid)) { - $InfoFieldList[4] = str_replace('$ID$', $objectid, $InfoFieldList[4]); + $InfoFieldList[4] = str_replace('$ID$', (string) $objectid, $InfoFieldList[4]); } else { $InfoFieldList[4] = str_replace('$ID$', '0', $InfoFieldList[4]); } From 2215fc748b689c1162f1c29716af7df115bdf2d0 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 18:37:26 +0100 Subject: [PATCH 11/36] Fix arg type for str_replace() with casts --- htdocs/core/class/extrafields.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 9f87c8bccc1..56fad852290 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1258,7 +1258,7 @@ class ExtraFields if (!empty($InfoFieldList[4])) { // can use current entity filter if (strpos($InfoFieldList[4], '$ENTITY$') !== false) { - $InfoFieldList[4] = str_replace('$ENTITY$', $conf->entity, $InfoFieldList[4]); + $InfoFieldList[4] = str_replace('$ENTITY$', (string) $conf->entity, $InfoFieldList[4]); } // can use SELECT request if (strpos($InfoFieldList[4], '$SEL$') !== false) { @@ -1267,7 +1267,7 @@ class ExtraFields // current object id can be use into filter if (strpos($InfoFieldList[4], '$ID$') !== false && !empty($objectid)) { - $InfoFieldList[4] = str_replace('$ID$', $objectid, $InfoFieldList[4]); + $InfoFieldList[4] = str_replace('$ID$', (string) $objectid, $InfoFieldList[4]); } else { $InfoFieldList[4] = str_replace('$ID$', '0', $InfoFieldList[4]); } @@ -1428,7 +1428,7 @@ class ExtraFields if (!empty($InfoFieldList[4])) { // can use current entity filter if (strpos($InfoFieldList[4], '$ENTITY$') !== false) { - $InfoFieldList[4] = str_replace('$ENTITY$', $conf->entity, $InfoFieldList[4]); + $InfoFieldList[4] = str_replace('$ENTITY$', (string) $conf->entity, $InfoFieldList[4]); } // can use SELECT request if (strpos($InfoFieldList[4], '$SEL$') !== false) { @@ -1437,7 +1437,7 @@ class ExtraFields // current object id can be use into filter if (strpos($InfoFieldList[4], '$ID$') !== false && !empty($objectid)) { - $InfoFieldList[4] = str_replace('$ID$', $objectid, $InfoFieldList[4]); + $InfoFieldList[4] = str_replace('$ID$', (string) $objectid, $InfoFieldList[4]); } elseif (preg_match("#^.*list.php$#", $_SERVER["PHP_SELF"])) { // Pattern for word=$ID$ $word = '\b[a-zA-Z0-9-\.-_]+\b=\$ID\$'; From 26ccab2fc3d0d0492169ec7ae443bc228bcc9fd7 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 18:42:38 +0100 Subject: [PATCH 12/36] Fix arg type for strlen() with algorithm, cast for preg_match() --- htdocs/core/class/html.form.class.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 019930cc28d..6850bdb80b8 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7057,10 +7057,8 @@ class Form $retstring .= ''; } for ($min = 0; $min < 60; $min += $stepminutes) { - if (strlen($min) < 2) { - $min = "0" . $min; - } - $retstring .= ''; + $min_str = sprintf("%02d", $min); + $retstring .= ''; } $retstring .= ''; @@ -8827,7 +8825,7 @@ class Form // submitted to nothing. $out .= ''; // Output select component - $out .= '' . "\n"; if (is_array($array) && !empty($array)) { if ($value_as_key) { $array = array_combine($array, $array); From f03e0f4cc9b417df5818b1b7c6e41ba5073248d7 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 18:45:15 +0100 Subject: [PATCH 13/36] Fix arg type for strcmp() with casts --- htdocs/core/class/utils.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 6b00c3bc17b..3b10ea563a1 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -1228,7 +1228,7 @@ class Utils } elseif (is_string($row[$j]) && $row[$j] == '') { // if it's an empty string, we set it as an empty string $row[$j] = "''"; - } elseif (is_numeric($row[$j]) && !strcmp($row[$j], $row[$j] + 0)) { // test if it's a numeric type and the numeric version ($nb+0) == string version (eg: if we have 01, it's probably not a number but rather a string, else it would not have any leading 0) + } elseif (is_numeric($row[$j]) && !strcmp((string) $row[$j], (string) ($row[$j] + 0))) { // test if it's a numeric type and the numeric version ($nb+0) == string version (eg: if we have 01, it's probably not a number but rather a string, else it would not have any leading 0) // if it's a number, we return it as-is // $row[$j] = $row[$j]; } else { // else for all other cases we escape the value and put quotes around From 23516ed5fa3b3f4cf66a96c39a2a23062d29ce6e Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 18:46:30 +0100 Subject: [PATCH 14/36] Fix arg type for str_replace() with cast --- htdocs/core/db/pgsql.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index ecb9b0f0df9..cba500c0a0e 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -8,6 +8,7 @@ * Copyright (C) 2012 Yann Droneaud * Copyright (C) 2012 Florian Henry * Copyright (C) 2015 Marcos García + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -416,7 +417,7 @@ class DoliDBPgsql extends DoliDB $login = str_replace(array("\\", "'"), array("\\\\", "\\'"), $login); $passwd = str_replace(array("\\", "'"), array("\\\\", "\\'"), $passwd); $name = str_replace(array("\\", "'"), array("\\\\", "\\'"), $name); - $port = str_replace(array("\\", "'"), array("\\\\", "\\'"), $port); + $port = str_replace(array("\\", "'"), array("\\\\", "\\'"), (string) $port); if (!$name) { $name = "postgres"; // When try to connect using admin user From 2a72e49e3586f68e747a36fa040a2feebfcba5aa Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 18:49:01 +0100 Subject: [PATCH 15/36] Fix arg type for str_replace() with change to getDolGlobalString --- htdocs/core/js/lib_head.js.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index 0bbe8499662..f50649ba55b 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005-2018 Laurent Destailleur * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1162,7 +1163,7 @@ function dolroundjs(number, decimals) { return +(Math.round(number + "e+" + deci * */ function pricejs(amount, mode = 'MT', currency_code = '', force_locale = '') { - var main_max_dec_shown = ; + var main_max_dec_shown = ; var main_rounding_unit = ; var main_rounding_tot = ; var main_decimal_separator = ; @@ -1240,7 +1241,7 @@ function price2numjs(amount) { var dec = ; var thousand = ; - var main_max_dec_shown = ; + var main_max_dec_shown = ; var main_rounding_unit = ; var main_rounding_tot = ; From e684b82a9b8abcf78037899e8867590766c50948 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 18:52:11 +0100 Subject: [PATCH 16/36] Fix arg type for substr with casts --- htdocs/core/lib/functions2.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 36cb26e4b6d..b290bb713eb 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1385,7 +1385,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ if (!empty($yearoffsettype) && !is_numeric($yearoffsettype) && $yearoffsettype != '=') { // yearoffsettype is - or +, so we don't want current year $numFinal = preg_replace('/\{yyyy\}/i', (string) ((int) date("Y", $date) + $yearoffset), $numFinal); $numFinal = preg_replace('/\{yy\}/i', (string) ((int) date("y", $date) + $yearoffset), $numFinal); - $numFinal = preg_replace('/\{y\}/i', substr(date("y", $date), 1, 1) + $yearoffset, $numFinal); + $numFinal = preg_replace('/\{y\}/i', (string) ((int) substr((string) date("y", $date), 1, 1) + $yearoffset), $numFinal); } else { // we want yyyy to be current year $numFinal = preg_replace('/\{yyyy\}/i', date("Y", $date), $numFinal); $numFinal = preg_replace('/\{yy\}/i', date("y", $date), $numFinal); From ee0ed791a52d5c0e6d4b54ac47e79dd3ad324f34 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 18:53:45 +0100 Subject: [PATCH 17/36] Fix arg type to strlen() with cast --- htdocs/core/lib/functionsnumtoword.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functionsnumtoword.lib.php b/htdocs/core/lib/functionsnumtoword.lib.php index 7e1f5f1ed31..7e16ff46de1 100644 --- a/htdocs/core/lib/functionsnumtoword.lib.php +++ b/htdocs/core/lib/functionsnumtoword.lib.php @@ -43,7 +43,7 @@ function dol_convertToWord($num, $langs, $currency = '', $centimes = false) return false; } - if ($centimes && strlen($num) == 1) { + if ($centimes && strlen((string) $num) == 1) { $num = $num * 10; } @@ -105,7 +105,7 @@ function dol_convertToWord($num, $langs, $currency = '', $centimes = false) $langs->transnoentitiesnoconv('quadrillion') ); - $num_length = strlen($num); + $num_length = strlen((string) $num); $levels = (int) (($num_length + 2) / 3); $max_length = $levels * 3; $num = substr('00'.$num, -$max_length); From 61bd47623dd3913b5f84f5b99ee75a2ae3616d27 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 18:55:10 +0100 Subject: [PATCH 18/36] Fix arg type to strlen() with cast --- htdocs/core/lib/profid.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/profid.lib.php b/htdocs/core/lib/profid.lib.php index 88c21d2f4d7..fa5a75aae7e 100644 --- a/htdocs/core/lib/profid.lib.php +++ b/htdocs/core/lib/profid.lib.php @@ -204,7 +204,7 @@ function isValidTinForES($str) for ($i = 1; $i < 8; $i += 2) { $sum += intval(substr((string) (2 * $num[$i]), 0, 1)) + intval(substr((string) (2 * $num[$i]), 1, 1)); } - $n = 10 - substr((string) $sum, strlen($sum) - 1, 1); + $n = 10 - substr((string) $sum, strlen((string) $sum) - 1, 1); //Check special NIF if (preg_match('/^[KLM]{1}/', $str)) { @@ -217,7 +217,7 @@ function isValidTinForES($str) //Check CIF if (preg_match('/^[ABCDEFGHJNPQRSUVW]{1}/', $str)) { - if ($num[8] == chr(64 + $n) || $num[8] == substr((string) $n, strlen($n) - 1, 1)) { + if ($num[8] == chr(64 + $n) || $num[8] == substr((string) $n, strlen((string) $n) - 1, 1)) { return 2; } else { return -2; From 834864a6fae2f1b2762797018ef64f71010ef5fe Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 18:57:52 +0100 Subject: [PATCH 19/36] FIX Title for project (bad logic) & arg type to strcmp() with cats --- htdocs/core/lib/project.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index f3c8910f646..10b86bc497c 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -1097,7 +1097,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t // Budget task if (count($arrayfields) > 0 && !empty($arrayfields['t.budget_amount']['checked'])) { print ''; - if (strcmp($total_budget_amount, '')) { + if (strcmp((string) $total_budget_amount, '')) { print price($total_budget_amount, 0, $langs, 1, 0, 0, $conf->currency); } print ''; @@ -2527,7 +2527,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks $project_year_filter = 0; $title = $langs->trans("Projects"); - if (strcmp($status, '') && $status >= 0) { + if (!strcmp((string) $status, '') && $status >= 0) { $title = $langs->trans("Projects").' '.$langs->trans($projectstatic->labelStatus[$status]); } From d61e3f077c6d2660b1ad26e397dc6e6016899bf5 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 18:59:14 +0100 Subject: [PATCH 20/36] Fix arg type to preg_replace with cast --- htdocs/core/lib/security.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 94efaf2864a..706ccde141f 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -376,7 +376,7 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', $objectid = 0; } if ($objectid) { - $objectid = preg_replace('/[^0-9\.\,]/', '', $objectid); // For the case value is coming from a non sanitized user input + $objectid = preg_replace('/[^0-9\.\,]/', '', (string) $objectid); // For the case value is coming from a non sanitized user input } //dol_syslog("functions.lib:restrictedArea $feature, $objectid, $dbtablename, $feature2, $dbt_socfield, $dbt_select, $isdraft"); From 8073d823b85eeb2e0bed594a91da5a730dcb363c Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 19:01:30 +0100 Subject: [PATCH 21/36] Ignore PhanTypeMismatchArgumentInternal for resource<->LDAP\Connection --- htdocs/core/login/functions_ldap.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/login/functions_ldap.php b/htdocs/core/login/functions_ldap.php index 593f050d4c7..fde4d4128f9 100644 --- a/htdocs/core/login/functions_ldap.php +++ b/htdocs/core/login/functions_ldap.php @@ -1,6 +1,7 @@ * Copyright (C) 2008-2021 Regis Houssin + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -247,7 +248,9 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest) */ dol_syslog("functions_ldap::check_user_password_ldap Authentication KO failed to connect to LDAP for '".$usertotest."'", LOG_NOTICE); if (is_resource($ldap->connection) || is_object($ldap->connection)) { // If connection ok but bind ko + // @phan-suppress-next-line PhanTypeMismatchArgumentInternal Expects LDAP\Connection, not 'resource' $ldap->ldapErrorCode = ldap_errno($ldap->connection); + // @phan-suppress-next-line PhanTypeMismatchArgumentInternal Expects LDAP\Connection, not 'resource' $ldap->ldapErrorText = ldap_error($ldap->connection); dol_syslog("functions_ldap::check_user_password_ldap ".$ldap->ldapErrorCode." ".$ldap->ldapErrorText); } From 4baba0a3e113dd171c925dddea2b2d3714c156a5 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 19:04:49 +0100 Subject: [PATCH 22/36] Fix typing on pdf_getInstance --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index d7bc551cd5c..62131255b72 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -123,7 +123,7 @@ function pdf_getFormat(Translate $outputlangs = null, $mode = 'setup') * @param string $format Array(width,height). Keep empty to use default setup. * @param string $metric Unit of format ('mm') * @param string $pagetype 'P' or 'l' - * @return TCPDF PDF object + * @return TCPDF|TCPDI PDF object */ function pdf_getInstance($format = '', $metric = 'mm', $pagetype = 'P') { From 045810e21989db3da333943f7425005d5e519ade Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 19:08:06 +0100 Subject: [PATCH 23/36] Fix $pdf typing on methods --- .../core/class/commondocgenerator.class.php | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 251442a9b72..ab8c695c143 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1044,13 +1044,13 @@ abstract class CommonDocGenerator /** * Rect pdf * - * @param TCPDF $pdf Object PDF - * @param float $x Abscissa of first point - * @param float $y Ordinate of first point - * @param float $l ?? - * @param float $h ?? - * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title - * @param int $hidebottom Hide bottom + * @param TCPDI|TCPDF $pdf Pdf object + * @param float $x Abscissa of first point + * @param float $y Ordinate of first point + * @param float $l ?? + * @param float $h ?? + * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title + * @param int $hidebottom Hide bottom * @return void */ public function printRect($pdf, $x, $y, $l, $h, $hidetop = 0, $hidebottom = 0) @@ -1248,7 +1248,7 @@ abstract class CommonDocGenerator /** * print standard column content * - * @param TCPDF $pdf pdf object + * @param TCPDI|TCPDF $pdf Pdf object * @param float $curY current Y position * @param string $colKey the column key * @param string $columnText column text @@ -1291,7 +1291,7 @@ abstract class CommonDocGenerator /** * print description column content * - * @param TCPDF $pdf pdf object + * @param TCPDI|TCPDF $pdf Pdf object * @param float $curY current Y position * @param string $colKey the column key * @param object $object CommonObject @@ -1600,12 +1600,12 @@ abstract class CommonDocGenerator /** * Print standard column content * - * @param TCPDI $pdf Pdf object - * @param float $tab_top Tab top position - * @param float $tab_height Default tab height - * @param Translate $outputlangs Output language - * @param int $hidetop Hide top - * @return float Height of col tab titles + * @param TCPDI|TCPDF $pdf Pdf object + * @param float $tab_top Tab top position + * @param float $tab_height Default tab height + * @param Translate $outputlangs Output language + * @param int $hidetop Hide top + * @return float Height of col tab titles */ public function pdfTabTitles(&$pdf, $tab_top, $tab_height, $outputlangs, $hidetop = 0) { From afff9695c3f6ebe713111a271f1fb5cb6b9d509a Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 19:10:38 +0100 Subject: [PATCH 24/36] Fix arg type to str_replace() and preg_match() with casts --- .../commande/doc/pdf_einstein.modules.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index fafec559fad..c4165030427 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -8,6 +8,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2017-2018 Ferran Marcet * Copyright (C) 2018-2020 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -723,7 +724,7 @@ class pdf_einstein extends ModelePDFCommandes $lib_condition_paiement = ($outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); if ($object->deposit_percent > 0) { - $lib_condition_paiement = str_replace('__DEPOSIT_PERCENT__', $object->deposit_percent, $lib_condition_paiement); + $lib_condition_paiement = str_replace('__DEPOSIT_PERCENT__', (string) $object->deposit_percent, $lib_condition_paiement); } $pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L'); @@ -938,8 +939,8 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $tvacompl = ''; - if (preg_match('/\*/', $tvakey)) { - $tvakey = str_replace('*', '', $tvakey); + if (preg_match('/\*/', (string) $tvakey)) { + $tvakey = str_replace('*', '', (string) $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : ''); @@ -970,8 +971,8 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $tvacompl = ''; - if (preg_match('/\*/', $tvakey)) { - $tvakey = str_replace('*', '', $tvakey); + if (preg_match('/\*/', (string) $tvakey)) { + $tvakey = str_replace('*', '', (string) $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : ''); @@ -1033,8 +1034,8 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $tvacompl = ''; - if (preg_match('/\*/', $tvakey)) { - $tvakey = str_replace('*', '', $tvakey); + if (preg_match('/\*/', (string) $tvakey)) { + $tvakey = str_replace('*', '', (string) $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : ''); @@ -1068,8 +1069,8 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $tvacompl = ''; - if (preg_match('/\*/', $tvakey)) { - $tvakey = str_replace('*', '', $tvakey); + if (preg_match('/\*/', (string) $tvakey)) { + $tvakey = str_replace('*', '', (string) $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : ''); From 20943dc8c214d58c423e17f7f402191228166932 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 19:12:41 +0100 Subject: [PATCH 25/36] Fix arg type to str_replace() and preg_match() with casts --- .../commande/doc/pdf_eratosthene.modules.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 4b9e85e2589..7eb01987cf1 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -8,6 +8,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2017 Ferran Marcet * Copyright (C) 2018-2020 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -930,7 +931,7 @@ class pdf_eratosthene extends ModelePDFCommandes $lib_condition_paiement = ($outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label); $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); if ($object->deposit_percent > 0) { - $lib_condition_paiement = str_replace('__DEPOSIT_PERCENT__', $object->deposit_percent, $lib_condition_paiement); + $lib_condition_paiement = str_replace('__DEPOSIT_PERCENT__', (string) $object->deposit_percent, $lib_condition_paiement); } $pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L'); @@ -1140,8 +1141,8 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $tvacompl = ''; - if (preg_match('/\*/', $tvakey)) { - $tvakey = str_replace('*', '', $tvakey); + if (preg_match('/\*/', (string) $tvakey)) { + $tvakey = str_replace('*', '', (string) $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : ''); @@ -1172,8 +1173,8 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $tvacompl = ''; - if (preg_match('/\*/', $tvakey)) { - $tvakey = str_replace('*', '', $tvakey); + if (preg_match('/\*/', (string) $tvakey)) { + $tvakey = str_replace('*', '', (string) $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : ''); @@ -1235,8 +1236,8 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $tvacompl = ''; - if (preg_match('/\*/', $tvakey)) { - $tvakey = str_replace('*', '', $tvakey); + if (preg_match('/\*/', (string) $tvakey)) { + $tvakey = str_replace('*', '', (string) $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : ''); @@ -1270,8 +1271,8 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $tvacompl = ''; - if (preg_match('/\*/', $tvakey)) { - $tvakey = str_replace('*', '', $tvakey); + if (preg_match('/\*/', (string) $tvakey)) { + $tvakey = str_replace('*', '', (string) $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : ''); From 4dc6b987660dedaf3e76d22d5d62d5adf8d4ab52 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 19:14:43 +0100 Subject: [PATCH 26/36] Fix arg type to str_replace() with casts --- htdocs/core/modules/dons/html_cerfafr.modules.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/dons/html_cerfafr.modules.php b/htdocs/core/modules/dons/html_cerfafr.modules.php index 73eac71322f..9173655e122 100644 --- a/htdocs/core/modules/dons/html_cerfafr.modules.php +++ b/htdocs/core/modules/dons/html_cerfafr.modules.php @@ -5,6 +5,7 @@ * Copyright (C) 2012 Marcos García * Copyright (C) 2014-2020 Alexandre Spangaro * Copyright (C) 2015 Benoit Bruchard + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -151,7 +152,7 @@ class html_cerfafr extends ModeleDon // Define contents $donmodel = DOL_DOCUMENT_ROOT."/core/modules/dons/html_cerfafr.html"; $form = implode('', file($donmodel)); - $form = str_replace('__REF__', $don->id, $form); + $form = str_replace('__REF__', (string) $don->id, $form); $form = str_replace('__DATE__', dol_print_date($don->date, 'day', false, $outputlangs), $form); //$form = str_replace('__IP__',$user->ip,$form); // TODO $user->ip not exist $form = str_replace('__AMOUNT__', price($don->amount), $form); @@ -166,7 +167,7 @@ class html_cerfafr extends ModeleDon $form = str_replace('__DONATOR_FIRSTNAME__', $don->firstname, $form); $form = str_replace('__DONATOR_LASTNAME__', $don->lastname, $form); $form = str_replace('__DONATOR_SOCIETE__', $don->societe, $form); - $form = str_replace('__DONATOR_STATUT__', $don->statut, $form); + $form = str_replace('__DONATOR_STATUT__', (string) $don->statut, $form); $form = str_replace('__DONATOR_ADDRESS__', $don->address, $form); $form = str_replace('__DONATOR_ZIP__', $don->zip, $form); $form = str_replace('__DONATOR_TOWN__', $don->town, $form); From bd2f8e0255d56a389d636d018c053e4c6e7d7d90 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 19:15:40 +0100 Subject: [PATCH 27/36] Fix arg type to str_replace() with casts --- htdocs/core/modules/dons/html_generic.modules.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/dons/html_generic.modules.php b/htdocs/core/modules/dons/html_generic.modules.php index 49bd1a7a29a..2f3b8ae30cd 100644 --- a/htdocs/core/modules/dons/html_generic.modules.php +++ b/htdocs/core/modules/dons/html_generic.modules.php @@ -6,6 +6,7 @@ * Copyright (C) 2014-2020 Alexandre Spangaro * Copyright (C) 2015 Benoit Bruchard * Copyright (C) 2015 Benjamin Neumann + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -123,7 +124,7 @@ class html_generic extends ModeleDon $donmodel = DOL_DOCUMENT_ROOT."/core/modules/dons/html_generic.html"; $form = implode('', file($donmodel)); $form = str_replace('__NOW__', dol_print_date($now, 'day', false, $outputlangs), $form); - $form = str_replace('__REF__', $don->id, $form); + $form = str_replace('__REF__', (string) $don->id, $form); $form = str_replace('__DATE__', dol_print_date($don->date, 'day', false, $outputlangs), $form); $form = str_replace('__BENEFICIARY_NAME__', $mysoc->name, $form); @@ -227,7 +228,7 @@ class html_generic extends ModeleDon if (file_exists($dir)) { $this->saveFile($file, $this->getContents($don, $outputlangs, $currency)); - $this->result = array('fullpath'=>$file); + $this->result = array('fullpath' => $file); return 1; } else { From b9f03d77049b7e15d94ca92163709d49bb8c24e6 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 19:18:39 +0100 Subject: [PATCH 28/36] Fix arg type to strlen() with cast, improve conversion to int --- htdocs/core/modules/expensereport/mod_expensereport_jade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/expensereport/mod_expensereport_jade.php b/htdocs/core/modules/expensereport/mod_expensereport_jade.php index afbd1664e96..63938b77da2 100644 --- a/htdocs/core/modules/expensereport/mod_expensereport_jade.php +++ b/htdocs/core/modules/expensereport/mod_expensereport_jade.php @@ -152,12 +152,12 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport } } else { $newref = 1; - while (strlen($newref) < $num_car) { + while (strlen((string) $newref) < $num_car) { $newref = "0".$newref; } } - $ref_number_int = ($newref + 1) - 1; + $ref_number_int = (int) $newref; $user_author_infos = dolGetFirstLastname($fuser->firstname, $fuser->lastname); From 873db9b4770424b965bf22660d0fc29a2fa232d6 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 19:20:36 +0100 Subject: [PATCH 29/36] Fix arg type to preg_match(),str_replace() with casts --- .../modules/facture/doc/pdf_crabe.modules.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 4be06d41f7d..2af6846e4e4 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -11,6 +11,7 @@ * Copyright (C) 2018-2020 Frédéric France * Copyright (C) 2022 Anthony Berton * Copyright (C) 2022 Charlene Benke + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1413,8 +1414,8 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $tvacompl = ''; - if (preg_match('/\*/', $tvakey)) { - $tvakey = str_replace('*', '', $tvakey); + if (preg_match('/\*/', (string) $tvakey)) { + $tvakey = str_replace('*', '', (string) $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } @@ -1447,8 +1448,8 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $tvacompl = ''; - if (preg_match('/\*/', $tvakey)) { - $tvakey = str_replace('*', '', $tvakey); + if (preg_match('/\*/', (string) $tvakey)) { + $tvakey = str_replace('*', '', (string) $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : ''); @@ -1511,8 +1512,8 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $tvacompl = ''; - if (preg_match('/\*/', $tvakey)) { - $tvakey = str_replace('*', '', $tvakey); + if (preg_match('/\*/', (string) $tvakey)) { + $tvakey = str_replace('*', '', (string) $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; @@ -1543,8 +1544,8 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $tvacompl = ''; - if (preg_match('/\*/', $tvakey)) { - $tvakey = str_replace('*', '', $tvakey); + if (preg_match('/\*/', (string) $tvakey)) { + $tvakey = str_replace('*', '', (string) $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; From b8fca809530a9fed5c562832621a72d71f9100a4 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 19:22:02 +0100 Subject: [PATCH 30/36] Fix arg type to preg_match(),str_replace() with casts --- .../modules/facture/doc/pdf_sponge.modules.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index b4e95f3fa18..24888f2b052 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1675,8 +1675,8 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $tvacompl = ''; - if (preg_match('/\*/', $tvakey)) { - $tvakey = str_replace('*', '', $tvakey); + if (preg_match('/\*/', (string) $tvakey)) { + $tvakey = str_replace('*', '', (string) $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } @@ -1709,8 +1709,8 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $tvacompl = ''; - if (preg_match('/\*/', $tvakey)) { - $tvakey = str_replace('*', '', $tvakey); + if (preg_match('/\*/', (string) $tvakey)) { + $tvakey = str_replace('*', '', (string) $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : ''); @@ -1796,8 +1796,8 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $tvacompl = ''; - if (preg_match('/\*/', $tvakey)) { - $tvakey = str_replace('*', '', $tvakey); + if (preg_match('/\*/', (string) $tvakey)) { + $tvakey = str_replace('*', '', (string) $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : ''); @@ -1831,8 +1831,8 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $tvacompl = ''; - if (preg_match('/\*/', $tvakey)) { - $tvakey = str_replace('*', '', $tvakey); + if (preg_match('/\*/', (string) $tvakey)) { + $tvakey = str_replace('*', '', (string) $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : ''); From 72e3522ac5ba295ff6bebcd907d8c92fef0a6663 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 19:23:30 +0100 Subject: [PATCH 31/36] Fix arg type to abs() with casts --- htdocs/core/modules/mrp/doc/pdf_vinci.modules.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php index 81e910d4e19..5d6e29c13d1 100644 --- a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php +++ b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php @@ -6,6 +6,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2017 Ferran Marcet * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -847,7 +848,7 @@ class pdf_vinci extends ModelePDFMo $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; - $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $totalvat .= vatrate(abs((float) $tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); @@ -877,7 +878,7 @@ class pdf_vinci extends ModelePDFMo $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; - $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $totalvat .= vatrate(abs((float) $tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); From 059039511903b12047661143490f3d742b9d7689 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 19:24:55 +0100 Subject: [PATCH 32/36] Fix arg type to preg_match() with cast --- htdocs/core/modules/product_batch/mod_lot_standard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/product_batch/mod_lot_standard.php b/htdocs/core/modules/product_batch/mod_lot_standard.php index b09f6bc3ff5..c3e3aa36648 100644 --- a/htdocs/core/modules/product_batch/mod_lot_standard.php +++ b/htdocs/core/modules/product_batch/mod_lot_standard.php @@ -104,7 +104,7 @@ class mod_lot_standard extends ModeleNumRefBatch $max = 0; } } - if ($max && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $max)) { + if ($max && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', (string) $max)) { $langs->load("errors"); $this->error = $langs->trans('ErrorNumRefModel', $max); return false; From 439c32237c30fe0b6ed2ed087c041b452c08fa79 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 19:26:19 +0100 Subject: [PATCH 33/36] Fix arg type to preg_match() with cast --- htdocs/core/modules/product_batch/mod_sn_standard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/product_batch/mod_sn_standard.php b/htdocs/core/modules/product_batch/mod_sn_standard.php index 6f5f673562e..4354bb57328 100644 --- a/htdocs/core/modules/product_batch/mod_sn_standard.php +++ b/htdocs/core/modules/product_batch/mod_sn_standard.php @@ -104,7 +104,7 @@ class mod_sn_standard extends ModeleNumRefBatch $max = 0; } } - if ($max && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $max)) { + if ($max && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', (string) $max)) { $langs->load("errors"); $this->error = $langs->trans('ErrorNumRefModel', $max); return false; From e74c473e725162051428de2986e8c7e89ed9855d Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 19:28:03 +0100 Subject: [PATCH 34/36] Fix arg type to preg_match(),str_replace() with casts --- .../modules/supplier_invoice/doc/pdf_canelle.modules.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php index 7ff56fc4a2c..3327e63506d 100644 --- a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php @@ -3,6 +3,7 @@ * Copyright (C) 2010-2014 Laurent Destailleur * Copyright (C) 2015 Marcos García * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -714,8 +715,8 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $tvacompl = ''; - if (preg_match('/\*/', $tvakey)) { - $tvakey = str_replace('*', '', $tvakey); + if (preg_match('/\*/', (string) $tvakey)) { + $tvakey = str_replace('*', '', (string) $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; @@ -739,8 +740,8 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $tvacompl = ''; - if (preg_match('/\*/', $tvakey)) { - $tvakey = str_replace('*', '', $tvakey); + if (preg_match('/\*/', (string) $tvakey)) { + $tvakey = str_replace('*', '', (string) $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; From 4262637a5e8a8626f3da1721c84aee0620a8cf14 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 19:29:08 +0100 Subject: [PATCH 35/36] Fix arg type to preg_match(),str_replace() with casts --- .../modules/supplier_order/doc/pdf_cornas.modules.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index f46c832db98..1861620567d 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -7,6 +7,7 @@ * Copyright (C) 2017 Ferran Marcet * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2023 William Mead + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1015,8 +1016,8 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $tvacompl = ''; - if (preg_match('/\*/', $tvakey)) { - $tvakey = str_replace('*', '', $tvakey); + if (preg_match('/\*/', (string) $tvakey)) { + $tvakey = str_replace('*', '', (string) $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; @@ -1045,8 +1046,8 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $tvacompl = ''; - if (preg_match('/\*/', $tvakey)) { - $tvakey = str_replace('*', '', $tvakey); + if (preg_match('/\*/', (string) $tvakey)) { + $tvakey = str_replace('*', '', (string) $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; From de13b93e43a58180d7c018cbedce2e60506ed632 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Mar 2024 19:30:19 +0100 Subject: [PATCH 36/36] Fix arg type to preg_match(),str_replace() with casts --- .../modules/supplier_order/doc/pdf_muscadet.modules.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php index 8b735fd88e3..405ab5933b4 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -6,6 +6,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2017 Ferran Marcet * Copyright (C) 2018-2023 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -891,8 +892,8 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $tvacompl = ''; - if (preg_match('/\*/', $tvakey)) { - $tvakey = str_replace('*', '', $tvakey); + if (preg_match('/\*/', (string) $tvakey)) { + $tvakey = str_replace('*', '', (string) $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; @@ -921,8 +922,8 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $tvacompl = ''; - if (preg_match('/\*/', $tvakey)) { - $tvakey = str_replace('*', '', $tvakey); + if (preg_match('/\*/', (string) $tvakey)) { + $tvakey = str_replace('*', '', (string) $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';