From e771bbfbe1cc29f9a299b0fea4af32b90795bdfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 28 Oct 2024 00:40:01 +0100 Subject: [PATCH] fix phpstan phpdoc (#31587) * fix phpstan phpdoc * fix phpstan phpdoc * fix phpstan phpdoc * fix phpstan phpdoc * fix phpstan phpdoc * fix phpstan phpdoc --- .../sociales/class/chargesociales.class.php | 36 +++++-- htdocs/loan/card.php | 16 ++-- htdocs/loan/class/loan.class.php | 93 ++++++++++++++++--- htdocs/loan/payment/payment.php | 4 +- 4 files changed, 116 insertions(+), 33 deletions(-) diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index cb464d87482..7aa08227626 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -1,10 +1,10 @@ - * Copyright (C) 2004-2007 Laurent Destailleur - * Copyright (C) 2016-2024 Frédéric France - * Copyright (C) 2017 Alexandre Spangaro - * Copyright (C) 2021 Gauthier VERDOL - * Copyright (C) 2024 MDW +/* Copyright (C) 2002 Rodolphe Quiedeville + * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2016-2024 Frédéric France + * Copyright (C) 2017 Alexandre Spangaro + * Copyright (C) 2021 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 @@ -39,6 +39,11 @@ class ChargeSociales extends CommonObject */ public $element = 'chargesociales'; + /** + * @var string Name of table without prefix where object is stored + * @deprecated Use $table_element + * @see $table_element + */ public $table = 'chargesociales'; /** @@ -65,18 +70,22 @@ class ChargeSociales extends CommonObject * @var string label */ public $label; + /** * @var int */ public $type; + /** * @var string */ public $type_label; + /** * @var string */ public $type_code; + /** * @var string */ @@ -86,15 +95,18 @@ class ChargeSociales extends CommonObject * @var int|string */ public $amount; + /** * @var int<0,1> */ public $paye; + /** * @deprecated Use $period * @var int|string */ public $periode; + /** * @var int|string */ @@ -102,7 +114,7 @@ class ChargeSociales extends CommonObject /** * @var string - * @deprecated Use label instead + * @deprecated Use $label instead */ public $lib; @@ -125,10 +137,12 @@ class ChargeSociales extends CommonObject * @var int ID */ public $mode_reglement_id; + /** * @var string */ public $mode_reglement_code; + /** * @var string */ @@ -154,8 +168,14 @@ class ChargeSociales extends CommonObject */ public $totalpaid; - + /** + * @var int + */ const STATUS_UNPAID = 0; + + /** + * @var int + */ const STATUS_PAID = 1; diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 2d8b5f89b2f..83e7d7b052a 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2015 Frederic France + * Copyright (C) 2015-2024 Frédéric France * Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2020 Maxime DEMAREST * Copyright (C) 2024 MDW @@ -108,8 +108,8 @@ if (empty($reshook)) { if (!$cancel) { $datestart = dol_mktime(12, 0, 0, GETPOSTINT('startmonth'), GETPOSTINT('startday'), GETPOSTINT('startyear')); $dateend = dol_mktime(12, 0, 0, GETPOSTINT('endmonth'), GETPOSTINT('endday'), GETPOSTINT('endyear')); - $capital = price2num(GETPOST('capital')); - $rate = price2num(GETPOST('rate')); + $capital = (float) price2num(GETPOST('capital')); + $rate = (float) price2num(GETPOST('rate')); if (!$capital) { $error++; @@ -138,7 +138,7 @@ if (empty($reshook)) { $object->capital = $capital; $object->datestart = $datestart; $object->dateend = $dateend; - $object->nbterm = GETPOST('nbterm'); + $object->nbterm = (float) price2num(GETPOST('nbterm')); $object->rate = $rate; $object->note_private = GETPOST('note_private', 'restricthtml'); $object->note_public = GETPOST('note_public', 'restricthtml'); @@ -183,7 +183,7 @@ if (empty($reshook)) { $datestart = dol_mktime(12, 0, 0, GETPOSTINT('startmonth'), GETPOSTINT('startday'), GETPOSTINT('startyear')); $dateend = dol_mktime(12, 0, 0, GETPOSTINT('endmonth'), GETPOSTINT('endday'), GETPOSTINT('endyear')); - $capital = price2num(GETPOST('capital')); + $capital = (float) price2num(GETPOST('capital')); if (!$capital) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors'); @@ -192,9 +192,9 @@ if (empty($reshook)) { $object->datestart = $datestart; $object->dateend = $dateend; $object->capital = $capital; - $object->nbterm = GETPOSTINT("nbterm"); - $object->rate = price2num(GETPOST("rate", 'alpha')); - $object->insurance_amount = price2num(GETPOSTINT('insurance_amount')); + $object->nbterm = (float) price2num(GETPOSTINT("nbterm")); + $object->rate = (float) price2num(GETPOST("rate", 'alpha')); + $object->insurance_amount = (float) price2num(GETPOSTINT('insurance_amount')); $accountancy_account_capital = GETPOST('accountancy_account_capital'); $accountancy_account_insurance = GETPOST('accountancy_account_insurance'); diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index cd1b9311166..86e236ffc92 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -1,7 +1,7 @@ - * Copyright (C) 2015-2024 Frédéric France - * Copyright (C) 2024 MDW +/* Copyright (C) 2014-2018 Alexandre Spangaro + * Copyright (C) 2015-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 @@ -35,6 +35,11 @@ class Loan extends CommonObject */ public $element = 'loan'; + /** + * @var string Name of table without prefix where object is stored + * @deprecated Use $table_element + * @see $table_element + */ public $table = 'loan'; /** @@ -52,7 +57,14 @@ class Loan extends CommonObject */ public $rowid; + /** + * @var int|'' date start + */ public $datestart; + + /** + * @var int|'' + */ public $dateend; /** @@ -60,17 +72,59 @@ class Loan extends CommonObject */ public $label; + /** + * @var float capital + */ public $capital; + + /** + * @var float nb terms + */ public $nbterm; + + /** + * @var float rate + */ public $rate; + + /** + * @var int<0,1> paid + */ public $paid; + + /** + * @var string account_capital + */ public $account_capital; + + /** + * @var string account_insurance + */ public $account_insurance; + + /** + * @var string account_interest + */ public $account_interest; + + /** + * @var string accountancy_account_capital + */ public $accountancy_account_capital; + + /** + * @var string accountancy_account_insurance + */ public $accountancy_account_insurance; + + /** + * @var string accountancy_account_interest + */ public $accountancy_account_interest; + /** + * @var float insurance amount + */ public $insurance_amount; /** @@ -98,8 +152,19 @@ class Loan extends CommonObject */ public $totalpaid; + /** + * @var int + */ const STATUS_UNPAID = 0; + + /** + * @var int + */ const STATUS_PAID = 1; + + /** + * @var int + */ const STATUS_STARTED = 2; @@ -135,11 +200,11 @@ class Loan extends CommonObject $this->id = $obj->rowid; $this->ref = $obj->rowid; $this->datestart = $this->db->jdate($obj->datestart); - $this->dateend = $this->db->jdate($obj->dateend); - $this->label = $obj->label; - $this->capital = $obj->capital; + $this->dateend = $this->db->jdate($obj->dateend); + $this->label = $obj->label; + $this->capital = $obj->capital; $this->nbterm = $obj->nbterm; - $this->rate = $obj->rate; + $this->rate = $obj->rate; $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->insurance_amount = $obj->insurance_amount; @@ -147,8 +212,8 @@ class Loan extends CommonObject $this->fk_bank = $obj->fk_bank; $this->account_capital = $obj->accountancy_account_capital; - $this->account_insurance = $obj->accountancy_account_insurance; - $this->account_interest = $obj->accountancy_account_interest; + $this->account_insurance = $obj->accountancy_account_insurance; + $this->account_interest = $obj->accountancy_account_interest; $this->fk_project = $obj->fk_project; $this->db->free($resql); @@ -601,8 +666,6 @@ class Loan extends CommonObject */ public function initAsSpecimen() { - global $user, $langs, $conf; - $now = dol_now(); // Initialise parameters @@ -610,13 +673,13 @@ class Loan extends CommonObject $this->fk_bank = 1; $this->label = 'SPECIMEN'; $this->specimen = 1; - $this->account_capital = 16; - $this->account_insurance = 616; - $this->account_interest = 518; + $this->account_capital = '16'; + $this->account_insurance = '616'; + $this->account_interest = '518'; $this->datestart = $now; $this->dateend = $now + (3600 * 24 * 365); $this->note_public = 'SPECIMEN'; - $this->capital = 20000; + $this->capital = 20000.80; $this->nbterm = 48; $this->rate = 4.3; diff --git a/htdocs/loan/payment/payment.php b/htdocs/loan/payment/payment.php index cbb1c84fce4..647198d9b5e 100644 --- a/htdocs/loan/payment/payment.php +++ b/htdocs/loan/payment/payment.php @@ -1,6 +1,6 @@ - * Copyright (C) 2015-2018 Frédéric France + * Copyright (C) 2015-2024 Frédéric France * Copyright (C) 2020 Maxime DEMAREST * * This program is free software; you can redistribute it and/or modify @@ -183,7 +183,7 @@ if ($action == 'add_payment' && $permissiontoadd) { if (!$error && !empty($line)) { // If payment values are modified, recalculate schedule if (($line->amount_capital != $pay_amount_capital) || ($line->amount_insurance != $pay_amount_insurance) || ($line->amount_interest != $pay_amount_interest)) { - $arr_term = loanCalcMonthlyPayment(($pay_amount_capital + $pay_amount_interest), $remaindertopay, ($loan->rate / 100), $echance, $loan->nbterm); + $arr_term = loanCalcMonthlyPayment(($pay_amount_capital + $pay_amount_interest), $remaindertopay, ($loan->rate / 100), $echance, (int) $loan->nbterm); foreach ($arr_term as $k => $v) { // Update fk_bank for current line if ($k == $echance) {