From 0b4e02821fe6291de66ef28dfa156f590d437955 Mon Sep 17 00:00:00 2001 From: mohamed daoud Date: Tue, 23 Jan 2024 16:07:59 +0100 Subject: [PATCH] Fix some warnings -Technical debts- --- htdocs/bom/class/bom.class.php | 38 +++++++++---------- htdocs/commande/class/commande.class.php | 16 ++++---- htdocs/compta/facture/class/facture.class.php | 12 +++--- htdocs/core/class/commonobject.class.php | 6 +-- 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 41bb5881d47..3faa8146ab4 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -217,7 +217,7 @@ class BOM extends CommonObject // If this object has a subtable with lines /** - * @var int Name of subtable line + * @var string Name of subtable line */ public $table_element_line = 'bom_bomline'; @@ -247,12 +247,12 @@ class BOM extends CommonObject public $lines = array(); /** - * @var int Calculated cost for the BOM + * @var float Calculated cost for the BOM */ public $total_cost = 0; /** - * @var int Calculated cost for 1 unit of the product in BOM + * @var float Calculated cost for 1 unit of the product in BOM */ public $unit_cost = 0; @@ -597,7 +597,7 @@ class BOM extends CommonObject * @param int $position Position of BOM-Line in BOM-Lines * @param int $fk_bom_child Id of BOM Child * @param string $import_key Import Key - * @param string $fk_unit Unit + * @param int $fk_unit Unit * @param array $array_options extrafields array * @param int $fk_default_workstation Default workstation * @return int Return integer <0 if KO, Id of created object if OK @@ -636,9 +636,9 @@ class BOM extends CommonObject $position = -1; } - $qty = price2num($qty); - $efficiency = price2num($efficiency); - $position = price2num($position); + $qty = (float) price2num($qty); + $efficiency = (float) price2num($efficiency); + $position = (float) price2num($position); $this->db->begin(); @@ -741,9 +741,9 @@ class BOM extends CommonObject $position = -1; } - $qty = price2num($qty); - $efficiency = price2num($efficiency); - $position = price2num($position); + $qty = (float) price2num($qty); + $efficiency = (float) price2num($efficiency); + $position = (float) price2num($position); $this->db->begin(); @@ -1475,7 +1475,7 @@ class BOM extends CommonObject $this->error = $tmpproduct->error; return -1; } - $line->unit_cost = price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp); + $line->unit_cost = price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : (float) $tmpproduct->pmp); if (empty($line->unit_cost)) { if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product) > 0) { if ($productFournisseur->fourn_remise_percent != "0") { @@ -1486,7 +1486,7 @@ class BOM extends CommonObject } } - $line->total_cost = price2num($line->qty * $line->unit_cost, 'MT'); + $line->total_cost = (float) price2num($line->qty * $line->unit_cost, 'MT'); $this->total_cost += $line->total_cost; } else { @@ -1495,7 +1495,7 @@ class BOM extends CommonObject if ($res > 0) { $bom_child->calculateCosts(); $line->childBom[] = $bom_child; - $this->total_cost += price2num($bom_child->total_cost * $line->qty, 'MT'); + $this->total_cost += (float) price2num($bom_child->total_cost * $line->qty, 'MT'); $this->total_cost += $line->total_cost; } else { $this->error = $bom_child->error; @@ -1512,7 +1512,7 @@ class BOM extends CommonObject $res = $workstation->fetch($line->fk_default_workstation); if ($res > 0) { - $line->total_cost = price2num($qtyhourforline * ($workstation->thm_operator_estimated + $workstation->thm_machine_estimated), 'MT'); + $line->total_cost = (float) price2num($qtyhourforline * ($workstation->thm_operator_estimated + $workstation->thm_machine_estimated), 'MT'); } else { $this->error = $workstation->error; return -3; @@ -1526,9 +1526,9 @@ class BOM extends CommonObject } if ($qtyhourservice) { - $line->total_cost = price2num($qtyhourforline / $qtyhourservice * $tmpproduct->cost_price, 'MT'); + $line->total_cost = (float) price2num($qtyhourforline / $qtyhourservice * $tmpproduct->cost_price, 'MT'); } else { - $line->total_cost = price2num($line->qty * $tmpproduct->cost_price, 'MT'); + $line->total_cost = (float) price2num($line->qty * $tmpproduct->cost_price, 'MT'); } } @@ -1536,12 +1536,12 @@ class BOM extends CommonObject } } - $this->total_cost = price2num($this->total_cost, 'MT'); + $this->total_cost = (float) price2num($this->total_cost, 'MT'); if ($this->qty > 0) { - $this->unit_cost = price2num($this->total_cost / $this->qty, 'MU'); + $this->unit_cost = (float) price2num($this->total_cost / $this->qty, 'MU'); } elseif ($this->qty < 0) { - $this->unit_cost = price2num($this->total_cost * $this->qty, 'MU'); + $this->unit_cost = (float) price2num($this->total_cost * $this->qty, 'MU'); } } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 8e94ee5e645..f8226634cf0 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1553,12 +1553,12 @@ class Commande extends CommonOrder $ref_ext = ''; } - $remise_percent = price2num($remise_percent); - $qty = price2num($qty); + $remise_percent = (float) price2num($remise_percent); + $qty = (float) price2num($qty); $pu_ht = price2num($pu_ht); $pu_ht_devise = price2num($pu_ht_devise); $pu_ttc = price2num($pu_ttc); - $pa_ht = price2num($pa_ht); + $pa_ht = (float) price2num($pa_ht); if (!preg_match('/\((.*)\)/', $txtva)) { $txtva = price2num($txtva); // $txtva can have format '5,1' or '5.1' or '5.1(XXX)', we must clean only if '5,1' } @@ -3149,16 +3149,16 @@ class Commande extends CommonOrder return -1; } - $remise_percent = price2num($remise_percent); - $qty = price2num($qty); + $remise_percent = (float) price2num($remise_percent); + $qty = (float) price2num($qty); $pu = price2num($pu); - $pa_ht = price2num($pa_ht); + $pa_ht = (float) price2num($pa_ht); $pu_ht_devise = price2num($pu_ht_devise); if (!preg_match('/\((.*)\)/', $txtva)) { $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' } - $txlocaltax1 = price2num($txlocaltax1); - $txlocaltax2 = price2num($txlocaltax2); + $txlocaltax1 = (float) price2num($txlocaltax1); + $txlocaltax2 = (float) price2num($txlocaltax2); $this->db->begin(); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index d1242027585..e9eb5ec753e 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -129,7 +129,7 @@ class Facture extends CommonInvoice public $user_valid; /** - * @var int ID + * @var int|null ID */ public $fk_user_valid; @@ -2452,7 +2452,7 @@ class Facture extends CommonInvoice $this->type = self::TYPE_STANDARD; } if (isset($this->subtype)) { - $this->subtype = trim($this->subtype); + $this->subtype = (int) trim($this->subtype); } if (isset($this->ref)) { $this->ref = trim($this->ref); @@ -3856,7 +3856,7 @@ class Facture extends CommonInvoice $ref_ext = ''; } - $remise_percent = price2num($remise_percent); + $remise_percent = (float) price2num($remise_percent); $qty = price2num($qty); $pu_ht = price2num($pu_ht); $pu_ht_devise = price2num($pu_ht_devise); @@ -4117,7 +4117,7 @@ class Facture extends CommonInvoice $ref_ext = ''; } - $remise_percent = price2num($remise_percent); + $remise_percent = (float) price2num($remise_percent); $qty = price2num($qty); $pu = price2num($pu); $pu_ht_devise = price2num($pu_ht_devise); @@ -4125,8 +4125,8 @@ class Facture extends CommonInvoice if (!preg_match('/\((.*)\)/', $txtva)) { $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' } - $txlocaltax1 = price2num($txlocaltax1); - $txlocaltax2 = price2num($txlocaltax2); + $txlocaltax1 = (float) price2num($txlocaltax1); + $txlocaltax2 = (float) price2num($txlocaltax2); // Check parameters if ($type < 0) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 754c3390e08..3d7796b8a35 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -201,7 +201,7 @@ abstract class CommonObject public $canvas; /** - * @var Project The related project object + * @var Project|null The related project object * @see fetch_projet() */ public $project; @@ -238,7 +238,7 @@ abstract class CommonObject public $contact_id; /** - * @var Societe A related thirdparty object + * @var Societe|null A related thirdparty object * @see fetch_thirdparty() */ public $thirdparty; @@ -642,7 +642,7 @@ abstract class CommonObject public $user_validation; /** - * @var int User id of validation + * @var int|null User id of validation */ public $user_validation_id;