From dcf7f91f71a4168912aa2b46b20e1e89b9ab2f04 Mon Sep 17 00:00:00 2001 From: lamrani abdelwadoud Date: Fri, 25 Oct 2024 20:45:12 +0200 Subject: [PATCH 01/13] NEW Add badge for generate invoice client tab (#31559) * Add badge for generate invoice client tab * urlencode for add to url --- htdocs/compta/facture/list.php | 7 +++++-- htdocs/core/lib/invoice.lib.php | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index c00a01717ac..d60f5fdc9d5 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -1251,8 +1251,11 @@ $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $newcardbutton = ''; if ($contextpage != 'poslist') { $url = DOL_URL_ROOT.'/compta/facture/card.php?action=create'; - if (!empty($socid)) { - $url .= '&socid='.$socid; + if (!empty($object->socid)) { + $url .= '&socid='.urlencode((string) $object->socid); + } + if (!empty($object->id)) { + $url .= '&fac_rec='.urlencode((string) $object->id); } $newcardbutton = ''; $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition')); diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index fcaeb49505d..e7b5b101828 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -264,6 +264,21 @@ function invoice_rec_prepare_head($object) $head[$h][0] = DOL_URL_ROOT . '/compta/facture/list.php?search_fk_fac_rec_source=' . $object->id; $head[$h][1] = $langs->trans('InvoicesGeneratedFromRec'); + //count facture rec + $nbFacture = 0; + $sql = "SELECT COUNT(rowid) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture"; + $sql .= " WHERE fk_fac_rec_source = ".((int) $object->id); + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + $nbFacture = $obj->nb; + } else { + dol_syslog('Failed to count facture with facture_rec '.$db->lasterror(), LOG_ERR); + } + if ($nbFacture > 0) { + $head[$h][1] .= ''.$nbFacture.''; + } $head[$h][2] = 'generated'; $h++; From 43e3dff51034a5ac4b55bdaad5b24c42f8c77180 Mon Sep 17 00:00:00 2001 From: lamrani abdelwadoud Date: Fri, 25 Oct 2024 20:45:53 +0200 Subject: [PATCH 02/13] add badge for section fourn generated invoices (#31560) --- htdocs/core/lib/invoice.lib.php | 16 ++++++++++++++++ htdocs/fourn/facture/list.php | 11 +++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index e7b5b101828..aa5a656b64f 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -380,6 +380,22 @@ function supplier_invoice_rec_prepare_head($object) } $head[$h][0] = DOL_URL_ROOT . '/fourn/facture/list.php?search_fk_fac_rec_source=' . $object->id; $head[$h][1] = $langs->trans('InvoicesGeneratedFromRec'); + + //count facture rec + $nbFactureFourn = 0; + $sql = "SELECT COUNT(rowid) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn"; + $sql .= " WHERE fk_fac_rec_source = ".((int) $object->id); + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + $nbFactureFourn = $obj->nb; + } else { + dol_syslog('Failed to count facture with facture fournisseur model '.$db->lasterror(), LOG_ERR); + } + if ($nbFactureFourn > 0) { + $head[$h][1] .= ''.$nbFactureFourn.''; + } $head[$h][2] = 'generated'; $h++; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 48734fde218..5d709756255 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -825,7 +825,8 @@ if ($search_fk_fac_rec_source) { require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture-rec.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/invoice.lib.php'; $object = new FactureFournisseurRec($db); - $object->id = (int) $search_fk_fac_rec_source; + $object->fetch((int) $search_fk_fac_rec_source); + $head = supplier_invoice_rec_prepare_head($object); print dol_get_fiche_head($head, 'generated', $langs->trans('InvoicesGeneratedFromRec'), -1, 'bill'); // Add a div } @@ -994,10 +995,12 @@ if (GETPOSTINT('nomassaction') || in_array($massaction, array('presend', 'predel $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $url = DOL_URL_ROOT.'/fourn/facture/card.php?action=create'; -if (!empty($socid)) { - $url .= '&socid='.urlencode((string) ($socid)); +if (!empty($object->socid)) { + $url .= '&socid='.urlencode((string) ($object->socid)); +} +if (!empty($object->id)) { + $url .= '&fac_rec='.urlencode((string) $object->id); } - $i = 0; print '
'."\n"; if ($optioncss != '') { From 213b0e4d4bb57efe7cb9d5c794401a2e92556869 Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller <45882981+Hystepik@users.noreply.github.com> Date: Fri, 25 Oct 2024 20:46:24 +0200 Subject: [PATCH 03/13] Fix statut filter for evaluation object (#31554) Co-authored-by: Hystepik --- htdocs/hrm/class/evaluation.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/hrm/class/evaluation.class.php b/htdocs/hrm/class/evaluation.class.php index 9c9fad5b2de..4843d7edb9b 100644 --- a/htdocs/hrm/class/evaluation.class.php +++ b/htdocs/hrm/class/evaluation.class.php @@ -108,7 +108,7 @@ class Evaluation extends CommonObject 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'position' => 1000, 'notnull' => -1, 'visible' => -2,), 'status' => array('type' => 'smallint', 'label' => 'Status', 'enabled' => 1, 'position' => 1000, 'notnull' => 1, 'default' => '0', 'visible' => 5, 'index' => 1, 'arrayofkeyval' => array('0' => 'Draft', '1' => 'Validated', '6' => 'Closed'),), 'date_eval' => array('type' => 'date', 'label' => 'DateEval', 'enabled' => 1, 'position' => 502, 'notnull' => 1, 'visible' => 1,), - 'fk_user' => array('type' => 'integer:User:user/class/user.class.php:0', 'label' => 'Employee', 'enabled' => 1, 'position' => 504, 'notnull' => 1, 'visible' => 1, 'picto' => 'user', 'css' => 'maxwidth300 widthcentpercentminusxx', 'csslist' => 'tdoverflowmax150'), + 'fk_user' => array('type' => 'integer:User:user/class/user.class.php:0:(t.statut:!=:0)', 'label' => 'Employee', 'enabled' => 1, 'position' => 504, 'notnull' => 1, 'visible' => 1, 'picto' => 'user', 'css' => 'maxwidth300 widthcentpercentminusxx', 'csslist' => 'tdoverflowmax150'), 'fk_job' => array('type' => 'integer:Job:/hrm/class/job.class.php', 'label' => 'JobProfile', 'enabled' => 1, 'position' => 505, 'notnull' => 1, 'visible' => 1, 'picto' => 'jobprofile', 'css' => 'maxwidth300 widthcentpercentminusxx', 'csslist' => 'tdoverflowmax150'), ); /** From 0ac595364bcff45c438849a18892ef47c699c1e7 Mon Sep 17 00:00:00 2001 From: MDW Date: Fri, 25 Oct 2024 21:00:02 +0200 Subject: [PATCH 04/13] Qual: Fix phan/phpstan notices in class files (part 1) (#31501) * Ignore phpstan configuration for spelling * Qual: Fix phan notices in class files --- dev/tools/phan/baseline.txt | 63 +++++++------------ dev/tools/phan/config.php | 1 + htdocs/accountancy/journal/bankjournal.php | 18 +++--- .../class/assetaccountancycodes.class.php | 7 ++- .../class/assetdepreciationoptions.class.php | 8 +-- htdocs/asset/class/assetmodel.class.php | 2 +- .../tpl/depreciation_options_view.tpl.php | 3 +- htdocs/asset/tpl/depreciation_view.tpl.php | 4 +- htdocs/bom/class/bom.class.php | 6 +- .../comm/action/class/cactioncomm.class.php | 17 ++--- htdocs/comm/action/class/ical.class.php | 35 ++++++----- .../mailing/class/advtargetemailing.class.php | 29 ++++----- .../html.formadvtargetemailing.class.php | 16 ++--- htdocs/comm/mailing/class/mailing.class.php | 6 +- htdocs/comm/propal/class/propal.class.php | 34 +++++----- htdocs/comm/propal/list.php | 2 +- htdocs/compta/bank/bankentries_list.php | 18 +++--- htdocs/compta/bank/class/account.class.php | 45 +++++++++---- htdocs/compta/bank/class/bankcateg.class.php | 4 +- .../deplacement/class/deplacement.class.php | 11 +++- .../facture/class/facturestats.class.php | 18 ++++++ .../facture/class/paymentterm.class.php | 28 +++++++++ .../compta/localtax/class/localtax.class.php | 17 ++++- .../cheque/class/remisecheque.class.php | 35 ++++++++++- .../compta/paiement/class/cpaiement.class.php | 21 +++++-- .../compta/paiement/class/paiement.class.php | 22 ++++--- .../class/rejetprelevement.class.php | 21 +++++-- .../sociales/class/cchargesociales.class.php | 35 ++++++++--- .../class/paymentsocialcontribution.class.php | 2 +- htdocs/compta/tva/class/paymentvat.class.php | 2 +- htdocs/compta/tva/class/tva.class.php | 4 +- .../actions_contactcard_common.class.php | 34 +++++++--- htdocs/contact/class/contact.class.php | 48 ++++++++++---- htdocs/core/class/ccountry.class.php | 15 ++++- htdocs/core/class/cgenericdic.class.php | 6 ++ htdocs/core/class/commonhookactions.class.php | 4 +- .../class/commonstickergenerator.class.php | 14 +++-- htdocs/core/class/html.formactions.class.php | 13 ++-- htdocs/core/lib/format_cards.lib.php | 2 +- .../modules/cheque/modules_chequereceipts.php | 12 ++++ .../member/doc/pdf_standard_member.class.php | 5 +- .../doc/pdf_standardlabel.class.php | 8 ++- .../printsheet/doc/pdf_tcpdflabel.class.php | 8 ++- phpstan.neon.dist | 2 + pyproject.toml | 2 +- 45 files changed, 481 insertions(+), 226 deletions(-) diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 581e6260bed..c9506b8fe39 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -14,39 +14,40 @@ return [ // PhanPossiblyUndeclaredGlobalVariable : 580+ occurrences // PhanTypeMismatchArgumentProbablyReal : 400+ occurrences // PhanUndeclaredGlobalVariable : 350+ occurrences - // PhanPluginUnknownArrayMethodReturnType : 300+ occurrences - // PhanPluginUnknownArrayMethodParamType : 240+ occurrences + // PhanPluginUnknownArrayMethodReturnType : 290+ occurrences + // PhanPluginUnknownArrayMethodParamType : 220+ occurrences // PhanPossiblyUndeclaredVariable : 200+ occurrences - // PhanTypeMismatchProperty : 160+ occurrences + // PhanTypeMismatchProperty : 170+ occurrences // PhanPluginUnknownArrayFunctionParamType : 95+ occurrences // PhanPluginUndeclaredVariableIsset : 65+ occurrences // PhanTypeMismatchArgumentNullableInternal : 65+ occurrences - // PhanPluginUnknownArrayPropertyType : 55+ occurrences // PhanPluginUnknownArrayFunctionReturnType : 50+ occurrences // PhanRedefineFunction : 50+ occurrences // PhanPluginEmptyStatementIf : 45+ occurrences + // PhanPluginUnknownArrayPropertyType : 40+ occurrences // PhanTypeExpectedObjectPropAccess : 40+ occurrences // PhanTypeInvalidDimOffset : 35+ occurrences // PhanTypeMismatchDimFetch : 30+ occurrences // PhanPluginUnknownObjectMethodCall : 15+ occurrences // PhanUndeclaredConstant : 15+ occurrences - // PhanUndeclaredMethod : 15+ occurrences // PhanEmptyForeach : 10+ occurrences // PhanPluginConstantVariableNull : 10+ occurrences // PhanPossiblyNullTypeMismatchProperty : 10+ occurrences // PhanTypeArraySuspiciousNull : 10+ occurrences // PhanTypeComparisonFromArray : 10+ occurrences // PhanTypeMismatchDimFetchNullable : 10+ occurrences + // PhanUndeclaredMethod : 10+ occurrences + // PhanPluginSuspiciousParamPosition : 9 occurrences // PhanPluginBothLiteralsBinaryOp : 8 occurrences - // PhanPluginSuspiciousParamPosition : 8 occurrences // PhanPluginDuplicateExpressionBinaryOp : 7 occurrences - // PhanPossiblyNullTypeMismatchProperty : 6 occurrences + // PhanPossiblyNullTypeMismatchProperty : 7 occurrences // PhanParamTooMany : 5 occurrences // PhanPluginDuplicateArrayKey : 4 occurrences // PhanEmptyFQSENInClasslike : 3 occurrences // PhanInvalidFQSENInClasslike : 3 occurrences // PhanTypeExpectedObjectPropAccessButGotNull : 2 occurrences // PhanAccessMethodProtected : 1 occurrence + // PhanParamTooFew : 1 occurrence // PhanTypeConversionFromArray : 1 occurrence // Currently, file_suppressions and directory_suppressions are the only supported suppressions @@ -62,8 +63,7 @@ return [ 'htdocs/api/class/api_status.class.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/asset/admin/setup.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/asset/class/asset.class.php' => ['PhanPluginUndeclaredVariableIsset'], - 'htdocs/asset/class/assetaccountancycodes.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownArrayPropertyType'], - 'htdocs/asset/class/assetdepreciationoptions.class.php' => ['PhanPluginUnknownArrayPropertyType', 'PhanTypeInvalidDimOffset'], + 'htdocs/asset/class/assetdepreciationoptions.class.php' => ['PhanTypeInvalidDimOffset'], 'htdocs/asset/class/assetmodel.class.php' => ['PhanUndeclaredProperty'], 'htdocs/asset/depreciation.php' => ['PhanPluginEmptyStatementIf'], 'htdocs/asset/disposal.php' => ['PhanPluginEmptyStatementIf'], @@ -78,7 +78,6 @@ return [ 'htdocs/bom/bom_card.php' => ['PhanUndeclaredProperty'], 'htdocs/bom/bom_list.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/bom/class/api_boms.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'], - 'htdocs/bom/class/bom.class.php' => ['PhanPluginUnknownArrayMethodParamType'], 'htdocs/bom/tpl/objectline_edit.tpl.php' => ['PhanUndeclaredProperty'], 'htdocs/bom/tpl/objectline_view.tpl.php' => ['PhanUndeclaredProperty'], 'htdocs/bookcal/availabilities_card.php' => ['PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], @@ -99,7 +98,6 @@ return [ 'htdocs/comm/action/card.php' => ['PhanPluginBothLiteralsBinaryOp', 'PhanPluginEmptyStatementIf', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty'], 'htdocs/comm/action/class/api_agendaevents.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownArrayPropertyType', 'PhanTypeMismatchProperty'], 'htdocs/comm/action/class/cactioncomm.class.php' => ['PhanPluginUnknownArrayPropertyType'], - 'htdocs/comm/action/class/ical.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownArrayPropertyType'], 'htdocs/comm/action/document.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/comm/action/index.php' => ['PhanPluginEmptyStatementIf', 'PhanPluginUnknownArrayFunctionParamType', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty'], 'htdocs/comm/action/info.php' => ['PhanUndeclaredProperty'], @@ -108,14 +106,10 @@ return [ 'htdocs/comm/action/peruser.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanTypeComparisonFromArray'], 'htdocs/comm/mailing/card.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/comm/mailing/cibles.php' => ['PhanUndeclaredGlobalVariable', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty'], - 'htdocs/comm/mailing/class/advtargetemailing.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayPropertyType'], - 'htdocs/comm/mailing/class/html.formadvtargetemailing.class.php' => ['PhanPluginUnknownArrayMethodParamType'], - 'htdocs/comm/mailing/class/mailing.class.php' => ['PhanPluginUnknownArrayPropertyType'], 'htdocs/comm/mailing/index.php' => ['PhanUndeclaredProperty'], 'htdocs/comm/propal/card.php' => ['PhanTypeMismatchProperty'], 'htdocs/comm/propal/class/api_proposals.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'], - 'htdocs/comm/propal/class/propal.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType'], - 'htdocs/comm/propal/list.php' => ['PhanTypeMismatchArgumentProbablyReal'], + 'htdocs/comm/propal/list.php' => ['PhanUndeclaredProperty'], 'htdocs/comm/propal/tpl/linkedobjectblock.tpl.php' => ['PhanUndeclaredProperty'], 'htdocs/commande/class/api_orders.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'], 'htdocs/commande/class/commande.class.php' => ['PhanUndeclaredProperty'], @@ -128,9 +122,8 @@ return [ 'htdocs/compta/bank/annuel.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/compta/bank/bankentries_list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/compta/bank/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/compta/bank/class/account.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownArrayPropertyType', 'PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'], + 'htdocs/compta/bank/class/account.class.php' => ['PhanUndeclaredProperty'], 'htdocs/compta/bank/class/api_bankaccounts.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/compta/bank/class/bankcateg.class.php' => ['PhanPluginUnknownArrayPropertyType'], 'htdocs/compta/bank/graph.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/compta/bank/line.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'], 'htdocs/compta/bank/releve.php' => ['PhanPossiblyUndeclaredGlobalVariable'], @@ -144,15 +137,12 @@ return [ 'htdocs/compta/cashcontrol/cashcontrol_list.php' => ['PhanTypeMismatchProperty'], 'htdocs/compta/charges/index.php' => ['PhanTypeMismatchArgumentNullableInternal'], 'htdocs/compta/clients.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable'], - 'htdocs/compta/deplacement/class/deplacement.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType'], 'htdocs/compta/deplacement/stats/index.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/compta/facture/agenda-rec.php' => ['PhanPluginEmptyStatementIf'], 'htdocs/compta/facture/card.php' => ['PhanUndeclaredProperty'], 'htdocs/compta/facture/class/api_invoices.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeComparisonFromArray', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/compta/facture/class/facture-rec.class.php' => ['PhanUndeclaredProperty'], 'htdocs/compta/facture/class/facture.class.php' => ['PhanUndeclaredProperty'], - 'htdocs/compta/facture/class/facturestats.class.php' => ['PhanPluginUnknownPropertyType'], - 'htdocs/compta/facture/class/paymentterm.class.php' => ['PhanPluginUnknownPropertyType'], 'htdocs/compta/facture/contact.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/compta/facture/invoicetemplate_list.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/compta/facture/list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], @@ -164,23 +154,19 @@ return [ 'htdocs/compta/journal/purchasesjournal.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/compta/journal/sellsjournal.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/compta/localtax/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable'], - 'htdocs/compta/localtax/class/localtax.class.php' => ['PhanPluginUnknownPropertyType', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/compta/localtax/clients.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredGlobalVariable'], 'htdocs/compta/localtax/index.php' => ['PhanRedefineFunction'], 'htdocs/compta/localtax/list.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/compta/paiement.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchDimFetch'], 'htdocs/compta/paiement/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/compta/paiement/cheque/card.php' => ['PhanUndeclaredGlobalVariable'], - 'htdocs/compta/paiement/cheque/class/remisecheque.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType', 'PhanUndeclaredMethod'], - 'htdocs/compta/paiement/cheque/list.php' => ['PhanUndeclaredGlobalVariable'], - 'htdocs/compta/paiement/class/cpaiement.class.php' => ['PhanPluginUnknownPropertyType'], - 'htdocs/compta/paiement/class/paiement.class.php' => ['PhanPluginEmptyStatementIf', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal'], + 'htdocs/compta/paiement/cheque/list.php' => ['PhanTypeMismatchProperty', 'PhanUndeclaredGlobalVariable'], + 'htdocs/compta/paiement/class/paiement.class.php' => ['PhanPossiblyUndeclaredVariable'], 'htdocs/compta/paiement/list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredGlobalVariable'], 'htdocs/compta/paiement_charge.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/compta/paiement_vat.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/compta/payment_vat/card.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/compta/prelevement/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/compta/prelevement/class/rejetprelevement.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchProperty'], 'htdocs/compta/prelevement/demandes.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/compta/prelevement/factures.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/compta/prelevement/line.php' => ['PhanPossiblyUndeclaredGlobalVariable'], @@ -190,8 +176,6 @@ return [ 'htdocs/compta/resultat/index.php' => ['PhanPluginEmptyStatementIf', 'PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/compta/resultat/result.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/compta/sociales/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredProperty'], - 'htdocs/compta/sociales/class/cchargesociales.class.php' => ['PhanPluginUnknownArrayPropertyType', 'PhanPluginUnknownPropertyType'], - 'htdocs/compta/sociales/class/paymentsocialcontribution.class.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/compta/sociales/list.php' => ['PhanPluginUndeclaredVariableIsset'], 'htdocs/compta/sociales/payments.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/compta/stats/byratecountry.php' => ['PhanPluginEmptyStatementIf'], @@ -203,15 +187,12 @@ return [ 'htdocs/compta/stats/supplier_turnover_by_prodserv.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/compta/stats/supplier_turnover_by_thirdparty.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/compta/tva/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal'], - 'htdocs/compta/tva/class/paymentvat.class.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], - 'htdocs/compta/tva/class/tva.class.php' => ['PhanTypeMismatchArgumentProbablyReal'], + 'htdocs/compta/tva/class/paymentvat.class.php' => ['PhanUndeclaredProperty'], 'htdocs/compta/tva/clients.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeArraySuspiciousNull', 'PhanTypeInvalidDimOffset', 'PhanTypeMismatchDimFetchNullable', 'PhanTypeMismatchProperty', 'PhanUndeclaredGlobalVariable'], 'htdocs/compta/tva/index.php' => ['PhanRedefineFunction', 'PhanUndeclaredGlobalVariable'], 'htdocs/compta/tva/payments.php' => ['PhanTypeMismatchArgumentNullableInternal'], 'htdocs/compta/tva/quadri_detail.php' => ['PhanTypeArraySuspiciousNull', 'PhanTypeInvalidDimOffset', 'PhanTypeMismatchProperty'], - 'htdocs/contact/canvas/actions_contactcard_common.class.php' => ['PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchProperty'], 'htdocs/contact/card.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty'], - 'htdocs/contact/class/contact.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownArrayPropertyType', 'PhanPluginUnknownPropertyType'], 'htdocs/contact/consumption.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/contact/list.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/contact/perso.php' => ['PhanTypeMismatchProperty'], @@ -258,14 +239,13 @@ return [ 'htdocs/core/boxes/box_task.php' => ['PhanPluginUnknownPropertyType'], 'htdocs/core/boxes/box_validated_projects.php' => ['PhanPluginUnknownPropertyType'], 'htdocs/core/class/canvas.class.php' => ['PhanParamTooMany', 'PhanUndeclaredMethod'], - 'htdocs/core/class/ccountry.class.php' => ['PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'], - 'htdocs/core/class/cgenericdic.class.php' => ['PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'], - 'htdocs/core/class/commonhookactions.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayPropertyType'], + 'htdocs/core/class/ccountry.class.php' => ['PhanUndeclaredProperty'], + 'htdocs/core/class/cgenericdic.class.php' => ['PhanUndeclaredProperty'], + 'htdocs/core/class/commonhookactions.class.php' => ['PhanPluginUnknownArrayPropertyType'], 'htdocs/core/class/commonobject.class.php' => ['PhanParamTooMany', 'PhanUndeclaredProperty'], 'htdocs/core/class/commonorder.class.php' => ['PhanPluginUnknownPropertyType'], 'htdocs/core/class/commonpeople.class.php' => ['PhanUndeclaredProperty'], 'htdocs/core/class/commonsocialnetworks.class.php' => ['PhanUndeclaredProperty'], - 'htdocs/core/class/commonstickergenerator.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayPropertyType', 'PhanPluginUnknownPropertyType'], 'htdocs/core/class/conf.class.php' => ['PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchProperty'], 'htdocs/core/class/ctypent.class.php' => ['PhanPluginUnknownPropertyType'], 'htdocs/core/class/ctyperesource.class.php' => ['PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'], @@ -354,7 +334,7 @@ return [ 'htdocs/core/modules/barcode/modules_barcode.class.php' => ['PhanPluginUnknownPropertyType'], 'htdocs/core/modules/bom/mod_bom_advanced.php' => ['PhanUndeclaredProperty'], 'htdocs/core/modules/cheque/doc/pdf_blochet.class.php' => ['PhanPluginUnknownPropertyType', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/core/modules/cheque/modules_chequereceipts.php' => ['PhanUndeclaredMethod'], + 'htdocs/core/modules/cheque/modules_chequereceipts.php' => ['PhanParamTooFew', 'PhanPluginSuspiciousParamPosition'], 'htdocs/core/modules/commande/doc/pdf_einstein.modules.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], 'htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], 'htdocs/core/modules/commande/modules_commande.php' => ['PhanPluginUnknownPropertyType'], @@ -377,7 +357,7 @@ return [ 'htdocs/core/modules/mailings/modules_mailings.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownArrayPropertyType'], 'htdocs/core/modules/mailings/thirdparties.modules.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/core/modules/member/doc/doc_generic_member_odt.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable'], - 'htdocs/core/modules/member/doc/pdf_standard_member.class.php' => ['PhanPluginUnknownArrayMethodParamType'], + 'htdocs/core/modules/member/doc/pdf_standard_member.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanTypeMismatchProperty'], 'htdocs/core/modules/member/modules_cards.php' => ['PhanPluginUnknownArrayFunctionParamType'], 'htdocs/core/modules/movement/doc/pdf_standard_movementstock.modules.php' => ['PhanPluginDuplicateExpressionBinaryOp', 'PhanPluginEmptyStatementIf', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable'], 'htdocs/core/modules/mrp/doc/pdf_vinci.modules.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], @@ -385,8 +365,8 @@ return [ 'htdocs/core/modules/oauth/github_oauthcallback.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/core/modules/printing/modules_printing.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/core/modules/printing/printgcp.modules.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownArrayPropertyType'], - 'htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php' => ['PhanPluginUnknownArrayMethodParamType'], - 'htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php' => ['PhanPluginUnknownArrayMethodParamType'], + 'htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanTypeMismatchProperty'], + 'htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanTypeMismatchProperty'], 'htdocs/core/modules/printsheet/modules_labels.php' => ['PhanParamTooMany'], 'htdocs/core/modules/product/doc/pdf_standard.modules.php' => ['PhanPluginEmptyStatementIf', 'PhanPossiblyUndeclaredVariable'], 'htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php' => ['PhanUndeclaredProperty'], @@ -781,6 +761,7 @@ return [ 'htdocs/societe/class/api_contacts.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty'], 'htdocs/societe/class/api_thirdparties.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], 'htdocs/societe/class/client.class.php' => ['PhanPluginUnknownArrayPropertyType'], + 'htdocs/societe/class/societe.class.php' => ['PhanTypeMismatchProperty'], 'htdocs/societe/class/societeaccount.class.php' => ['PhanPluginUnknownPropertyType'], 'htdocs/societe/consumption.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/societe/list.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], diff --git a/dev/tools/phan/config.php b/dev/tools/phan/config.php index 712e14e87b7..476b3a85580 100644 --- a/dev/tools/phan/config.php +++ b/dev/tools/phan/config.php @@ -223,6 +223,7 @@ return [ 'simplify_ast' => true, 'analyzed_file_extensions' => ['php','inc'], 'globals_type_map' => [ + '_Avery_Labels' => 'array', 'action' => 'string', 'actioncode' => 'string', 'badgeStatus0' => 'string', diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index b80276bb527..3b782f92c90 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -400,12 +400,12 @@ if ($result) { if ($links[$key]['type'] == 'payment') { $paymentstatic->id = $links[$key]['url_id']; - $paymentstatic->ref = $links[$key]['url_id']; + $paymentstatic->ref = (string) $links[$key]['url_id']; $tabpay[$obj->rowid]["lib"] .= ' '.$paymentstatic->getNomUrl(2, '', ''); // TODO Do not include list of invoice in tooltip, the dol_string_nohtmltag is ko with this $tabpay[$obj->rowid]["paymentid"] = $paymentstatic->id; } elseif ($links[$key]['type'] == 'payment_supplier') { $paymentsupplierstatic->id = $links[$key]['url_id']; - $paymentsupplierstatic->ref = $links[$key]['url_id']; + $paymentsupplierstatic->ref = (string) $links[$key]['url_id']; $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsupplierstatic->getNomUrl(2); $tabpay[$obj->rowid]["paymentsupplierid"] = $paymentsupplierstatic->id; } elseif ($links[$key]['type'] == 'company') { @@ -451,7 +451,7 @@ if ($result) { } } elseif ($links[$key]['type'] == 'sc') { $chargestatic->id = $links[$key]['url_id']; - $chargestatic->ref = $links[$key]['url_id']; + $chargestatic->ref = (string) $links[$key]['url_id']; $tabpay[$obj->rowid]["lib"] .= ' '.$chargestatic->getNomUrl(2); $reg = array(); @@ -486,14 +486,14 @@ if ($result) { } } elseif ($links[$key]['type'] == 'payment_donation') { $paymentdonstatic->id = $links[$key]['url_id']; - $paymentdonstatic->ref = $links[$key]['url_id']; + $paymentdonstatic->ref = (string) $links[$key]['url_id']; $paymentdonstatic->fk_donation = $links[$key]['url_id']; $tabpay[$obj->rowid]["lib"] .= ' '.$paymentdonstatic->getNomUrl(2); $tabpay[$obj->rowid]["paymentdonationid"] = $paymentdonstatic->id; $tabtp[$obj->rowid][$account_pay_donation] = isset($tabtp[$obj->rowid][$account_pay_donation]) ? $tabtp[$obj->rowid][$account_pay_donation] + $amounttouse : $amounttouse; } elseif ($links[$key]['type'] == 'member') { $paymentsubscriptionstatic->id = $links[$key]['url_id']; - $paymentsubscriptionstatic->ref = $links[$key]['url_id']; + $paymentsubscriptionstatic->ref = (string) $links[$key]['url_id']; $paymentsubscriptionstatic->label = $links[$key]['label']; $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsubscriptionstatic->getNomUrl(2); $tabpay[$obj->rowid]["paymentsubscriptionid"] = $paymentsubscriptionstatic->id; @@ -501,14 +501,14 @@ if ($result) { $tabtp[$obj->rowid][$account_pay_subscription] = isset($tabtp[$obj->rowid][$account_pay_subscription]) ? $tabtp[$obj->rowid][$account_pay_subscription] + $amounttouse : $amounttouse; } elseif ($links[$key]['type'] == 'payment_vat') { // Payment VAT $paymentvatstatic->id = $links[$key]['url_id']; - $paymentvatstatic->ref = $links[$key]['url_id']; + $paymentvatstatic->ref = (string) $links[$key]['url_id']; $paymentvatstatic->label = $links[$key]['label']; $tabpay[$obj->rowid]["lib"] .= ' '.$paymentvatstatic->getNomUrl(2); $tabpay[$obj->rowid]["paymentvatid"] = $paymentvatstatic->id; $tabtp[$obj->rowid][$account_pay_vat] = isset($tabtp[$obj->rowid][$account_pay_vat]) ? $tabtp[$obj->rowid][$account_pay_vat] + $amounttouse : $amounttouse; } elseif ($links[$key]['type'] == 'payment_salary') { $paymentsalstatic->id = $links[$key]['url_id']; - $paymentsalstatic->ref = $links[$key]['url_id']; + $paymentsalstatic->ref = (string) $links[$key]['url_id']; $paymentsalstatic->label = $links[$key]['label']; $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsalstatic->getNomUrl(2); $tabpay[$obj->rowid]["paymentsalid"] = $paymentsalstatic->id; @@ -556,7 +556,7 @@ if ($result) { $tabpay[$obj->rowid]["paymentexpensereport"] = $paymentexpensereportstatic->id; } elseif ($links[$key]['type'] == 'payment_various') { $paymentvariousstatic->id = $links[$key]['url_id']; - $paymentvariousstatic->ref = $links[$key]['url_id']; + $paymentvariousstatic->ref = (string) $links[$key]['url_id']; $paymentvariousstatic->label = $links[$key]['label']; $tabpay[$obj->rowid]["lib"] .= ' '.$paymentvariousstatic->getNomUrl(2); $tabpay[$obj->rowid]["paymentvariousid"] = $paymentvariousstatic->id; @@ -567,7 +567,7 @@ if ($result) { $tabtp[$obj->rowid][$account_subledger] = isset($tabtp[$obj->rowid][$account_subledger]) ? $tabtp[$obj->rowid][$account_subledger] + $amounttouse : $amounttouse; } elseif ($links[$key]['type'] == 'payment_loan') { $paymentloanstatic->id = $links[$key]['url_id']; - $paymentloanstatic->ref = $links[$key]['url_id']; + $paymentloanstatic->ref = (string) $links[$key]['url_id']; $paymentloanstatic->fk_loan = $links[$key]['url_id']; $tabpay[$obj->rowid]["lib"] .= ' '.$paymentloanstatic->getNomUrl(2); $tabpay[$obj->rowid]["paymentloanid"] = $paymentloanstatic->id; diff --git a/htdocs/asset/class/assetaccountancycodes.class.php b/htdocs/asset/class/assetaccountancycodes.class.php index 88c71d86889..7dd2ad2ef80 100644 --- a/htdocs/asset/class/assetaccountancycodes.class.php +++ b/htdocs/asset/class/assetaccountancycodes.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 @@ -29,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; class AssetAccountancyCodes extends CommonObject { /** - * @var array Array with all accountancy codes info by mode. + * @var array>> Array with all accountancy codes info by mode. * Note : 'economic' mode is mandatory and is the primary accountancy codes * 'depreciation_asset' and 'depreciation_expense' is mandatory and is used for write depreciation in bookkeeping */ @@ -64,7 +65,7 @@ class AssetAccountancyCodes extends CommonObject ); /** - * @var array Array with all accountancy codes by mode. + * @var array> Array with all accountancy codes by mode. */ public $accountancy_codes = array(); @@ -81,7 +82,7 @@ class AssetAccountancyCodes extends CommonObject /** * Fill accountancy_codes property of object (using for data sent by forms) * - * @return array Array of values + * @return array> Array of values */ public function setAccountancyCodesFromPost() { diff --git a/htdocs/asset/class/assetdepreciationoptions.class.php b/htdocs/asset/class/assetdepreciationoptions.class.php index eefaf8e3a2b..6a6bfed6ef2 100644 --- a/htdocs/asset/class/assetdepreciationoptions.class.php +++ b/htdocs/asset/class/assetdepreciationoptions.class.php @@ -70,8 +70,8 @@ class AssetDepreciationOptions extends CommonObject public $fields = array(); /** - * @var array Array with all deprecation options info by mode. - * Note : economic mode is mandatory and is the primary options + * @var array|string,position:int,notnull?:int,visible:int<-2,5>|string,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,2>,disabled?:int<0,1>,arrayofkeyval?:array,comment?:string,validate?:int<0,1>}>}> + * Note : economic mode is mandatory and is the primary option */ public $deprecation_options_fields = array( 'economic' => array( @@ -119,7 +119,7 @@ class AssetDepreciationOptions extends CommonObject public $fk_user_modif; /** - * @var array Array with all deprecation options by mode. + * @var array> Array with all deprecation options by mode. */ public $deprecation_options = array(); @@ -174,7 +174,7 @@ class AssetDepreciationOptions extends CommonObject * Set object infos for a mode * * @param string $mode Depreciation mode (economic, accelerated_depreciation, ...) - * @param int $class_type Type (0:asset, 1:asset model) + * @param int<0,1> $class_type Type (0:asset, 1:asset model) * @param bool $all_field Get all fields * @return int Return integer <0 if KO, >0 if OK */ diff --git a/htdocs/asset/class/assetmodel.class.php b/htdocs/asset/class/assetmodel.class.php index 5e9e32e7fa5..ac9dc8c778c 100644 --- a/htdocs/asset/class/assetmodel.class.php +++ b/htdocs/asset/class/assetmodel.class.php @@ -383,7 +383,7 @@ class AssetModel extends CommonObject * @param string $filter Filter as an Universal Search string. * Example: '((client:=:1) OR ((client:>=:2) AND (client:<=:3))) AND (client:!=:8) AND (nom:like:'a%')' * @param string $filtermode No more used - * @return array|int int <0 if KO, array of pages if OK + * @return AssetModel[]|int int <0 if KO, array of pages if OK */ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND') { diff --git a/htdocs/asset/tpl/depreciation_options_view.tpl.php b/htdocs/asset/tpl/depreciation_options_view.tpl.php index a99d0ec3090..e065f7890e0 100644 --- a/htdocs/asset/tpl/depreciation_options_view.tpl.php +++ b/htdocs/asset/tpl/depreciation_options_view.tpl.php @@ -77,7 +77,8 @@ if (empty($reshook)) { } } // Discard if extrafield is a hidden field on form - if (abs($field_info['visible']) != 1 && abs($field_info['visible']) != 3 && abs($field_info['visible']) != 4 && abs($field_info['visible']) != 5) { + $isVisibleAbs = array_key_exists('visible', $field_info) ? abs((int) $field_info['visible']) : 0; + if (!in_array($isVisibleAbs, array(1, 3, 4, 5))) { continue; } if (array_key_exists('enabled', $field_info) && isset($field_info['enabled']) && !verifCond($field_info['enabled'])) { diff --git a/htdocs/asset/tpl/depreciation_view.tpl.php b/htdocs/asset/tpl/depreciation_view.tpl.php index 3480a91b0b5..1c5ebdfcba4 100644 --- a/htdocs/asset/tpl/depreciation_view.tpl.php +++ b/htdocs/asset/tpl/depreciation_view.tpl.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 @@ -77,7 +78,8 @@ if (empty($reshook)) { } } // Discard if extrafield is a hidden field on form - if (abs($field_info['visible']) != 1 && abs($field_info['visible']) != 3 && abs($field_info['visible']) != 4 && abs($field_info['visible']) != 5) { + $isVisibleAbs = array_key_exists('visible', $field_info) ? abs((int) $field_info['visible']) : 0; + if (!in_array($isVisibleAbs, array(1, 3, 4, 5))) { continue; } if (array_key_exists('enabled', $field_info) && isset($field_info['enabled']) && !verifCond($field_info['enabled'])) { diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index ac615c78751..30de29d295b 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -590,7 +590,7 @@ class BOM extends CommonObject * @param ?int $fk_bom_child Id of BOM Child * @param ?string $import_key Import Key * @param int $fk_unit Unit - * @param array $array_options extrafields array + * @param array $array_options extrafields array * @param ?int $fk_default_workstation Default workstation * @return int<-3,max> Return integer <0 if KO, Id of created object if OK */ @@ -698,7 +698,7 @@ class BOM extends CommonObject * @param int<-1,max> $position Position of BOM-Line in BOM-Lines * @param ?string $import_key Import Key * @param int $fk_unit Unit of line - * @param array $array_options extrafields array + * @param array $array_options extrafields array * @param ?int $fk_default_workstation Default workstation * @return int<-3,max> Return integer <0 if KO, Id of updated BOM-Line if OK */ @@ -1299,7 +1299,7 @@ class BOM extends CommonObject * @param int<0,1> $hidedetails Hide details of lines * @param int<0,1> $hidedesc Hide description * @param int<0,1> $hideref Hide ref - * @param null|array $moreparams Array to provide more information + * @param ?array $moreparams Array to provide more information * @return int<0,1> 0 if KO, 1 if OK */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) diff --git a/htdocs/comm/action/class/cactioncomm.class.php b/htdocs/comm/action/class/cactioncomm.class.php index 7054b13febe..57d266226bd 100644 --- a/htdocs/comm/action/class/cactioncomm.class.php +++ b/htdocs/comm/action/class/cactioncomm.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2004-2014 Laurent Destailleur + * 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 @@ -55,7 +56,7 @@ class CActionComm /** * @var string label - * @deprecated + * @deprecated Use $label * @see $label */ public $libelle; @@ -87,7 +88,7 @@ class CActionComm /** - * @var array Used to return value by some methods + * @var array{id:array,code:array,all:array} Used to return value by some methods */ public $liste_array; @@ -148,13 +149,13 @@ class CActionComm /** * Return list of event types: array(id=>label) or array(code=>label) * - * @param string|int $active 1 or 0 to filter on event state active or not ('' by default = no filter) - * @param string $idorcode 'id' or 'code' or 'all' - * @param string $excludetype Type to exclude ('system' or 'systemauto') - * @param int $onlyautoornot 1=Group all type AC_XXX into 1 line AC_MANUAL. 0=Keep details of type, -1 or -2=Keep details and add a combined line per calendar (Default, Auto, BoothConf, ...) + * @param ''|int<0,1> $active 1 or 0 to filter on event state active or not ('' by default = no filter) + * @param 'id'|'code'|'all' $idorcode 'id' or 'code' or 'all' + * @param string $excludetype Type to exclude ('system' or 'systemauto') + * @param int<-2,1> $onlyautoornot 1=Group all type AC_XXX into 1 line AC_MANUAL. 0=Keep details of type, -1 or -2=Keep details and add a combined line per calendar (Default, Auto, BoothConf, ...) * @param string $morefilter Add more SQL filter - * @param int $shortlabel 1=Get short label instead of long label - * @return array|int Array of all event types if OK, <0 if KO. Key of array is id or code depending on parameter $idorcode. + * @param int<0,1> $shortlabel 1=Get short label instead of long label + * @return int<-1,-1>|array{id:array,code:array,all:array,AC_OTH_AUTO?:mixed} Array of all event types if OK, <0 if KO. Key of array is id or code depending on parameter $idorcode. */ public function liste_array($active = '', $idorcode = 'id', $excludetype = '', $onlyautoornot = 0, $morefilter = '', $shortlabel = 0) { diff --git a/htdocs/comm/action/class/ical.class.php b/htdocs/comm/action/class/ical.class.php index c6ee7f79086..da003149657 100644 --- a/htdocs/comm/action/class/ical.class.php +++ b/htdocs/comm/action/class/ical.class.php @@ -45,7 +45,7 @@ class ICal public $file_text; /** - * @var array Array to save iCalendar parse data + * @var array>>>|array>>>|array>>|array>> Array to save iCalendar parse data */ public $cal; @@ -138,7 +138,7 @@ class ICal * @param string $uri Url * @param string $usecachefile Full path of a cache file to use a cache file * @param int $delaycache Delay in seconds for cache (by default 3600 secondes) - * @return array|string + * @return string|array>>>|array>>>|array>>|array>> */ public function parse($uri, $usecachefile = '', $delaycache = 3600) { @@ -277,12 +277,15 @@ class ICal $key = $this->last_key; switch ($type) { case 'VEVENT': + // @phan-suppress-next-line PhanTypeMismatchDimFetch $value = $this->cal[$type][$this->event_count][$key].$value; break; case 'VFREEBUSY': + // @phan-suppress-next-line PhanTypeMismatchDimFetch $value = $this->cal[$type][$this->freebusy_count][$key].$value; break; case 'VTODO': + // @phan-suppress-next-line PhanTypeMismatchDimFetch $value = $this->cal[$type][$this->todo_count][$key].$value; break; } @@ -303,18 +306,22 @@ class ICal switch ($type) { case "VTODO": + // @phan-suppress-next-line PhanTypeMismatchReturn $this->cal[$type][$this->todo_count][$key] = $value; break; case "VEVENT": + // @phan-suppress-next-line PhanTypeMismatchReturn $this->cal[$type][$this->event_count][$key] = $value; break; case "VFREEBUSY": + // @phan-suppress-next-line PhanTypeMismatchReturn $this->cal[$type][$this->freebusy_count][$key] = $value; break; default: + // @phan-suppress-next-line PhanTypeMismatchProperty $this->cal[$type][$key] = $value; break; } @@ -326,7 +333,7 @@ class ICal * Parse text "XXXX:value text some with : " and return array($key = "XXXX", $value="value"); * * @param string $text Text - * @return array + * @return array{0:string,1:string} */ public function retun_key_value($text) { @@ -351,7 +358,7 @@ class ICal * Parse RRULE return array * * @param string $value string - * @return array + * @return array */ public function ical_rrule($value) { @@ -425,14 +432,14 @@ class ICal /** * Return sorted eventlist as array or false if calendar is empty * - * @return array|false + * @return array>|false */ public function get_sort_event_list() { // phpcs:enable $temp = $this->get_event_list(); if (!empty($temp)) { - usort($temp, array(&$this, "ical_dtstart_compare")); + usort($temp, array($this, "ical_dtstart_compare")); // false-positive @phpstan-ignore-line return $temp; } else { return false; @@ -443,9 +450,9 @@ class ICal /** * Compare two unix timestamp * - * @param array $a Operand a - * @param array $b Operand b - * @return integer + * @param array{DTSTART:array{unixtime:string}} $a Operand a + * @param array{DTSTART:array{unixtime:string}} $b Operand b + * @return int */ public function ical_dtstart_compare($a, $b) { @@ -457,7 +464,7 @@ class ICal /** * Return eventlist array (not sorted eventlist array) * - * @return array + * @return array> */ public function get_event_list() { @@ -469,7 +476,7 @@ class ICal /** * Return freebusy array (not sort eventlist array) * - * @return array + * @return array> */ public function get_freebusy_list() { @@ -481,7 +488,7 @@ class ICal /** * Return to do array (not sorted todo array) * - * @return array + * @return array> */ public function get_todo_list() { @@ -493,7 +500,7 @@ class ICal /** * Return base calendar data * - * @return array + * @return array> */ public function get_calender_data() { @@ -505,7 +512,7 @@ class ICal /** * Return array with all data * - * @return array + * @return array>>>|array>>>|array>>|array>> */ public function get_all_data() { diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index 47f23fac914..cb7ea75452b 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -2,6 +2,7 @@ /* Advance Targeting Emailing for mass emailing module * Copyright (C) 2013 Florian Henry * 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 @@ -85,12 +86,12 @@ class AdvanceTargetingMailing extends CommonObject public $fk_user_mod; /** - * @var array select target type + * @var array select target type */ public $select_target_type = array(); /** - * @var array type status comm prospect + * @var array type status comm prospect */ public $type_statuscommprospect = array(); @@ -129,7 +130,7 @@ class AdvanceTargetingMailing extends CommonObject $customerStatic->loadCacheOfProspStatus(); if (!empty($customerStatic->cacheprospectstatus)) { foreach ($customerStatic->cacheprospectstatus as $dataProspectSt) { - $this->type_statuscommprospect[$dataProspectSt['id']]=$dataProspectSt['label']; + $this->type_statuscommprospect[$dataProspectSt['id']] = $dataProspectSt['label']; } } else { $this->type_statuscommprospect = array( @@ -398,9 +399,9 @@ class AdvanceTargetingMailing extends CommonObject /** * Update object into database * - * @param User $user User that modifies - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int Return integer <0 if KO, >0 if OK + * @param User $user User that modifies + * @param int<0,1> $notrigger 0=launch triggers after, 1=disable triggers + * @return int Return integer <0 if KO, >0 if OK */ public function update($user, $notrigger = 0) { @@ -461,9 +462,9 @@ class AdvanceTargetingMailing extends CommonObject /** * Delete object in database * - * @param User $user User that deletes - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int Return integer <0 if KO, >0 if OK + * @param User $user User that deletes + * @param int<0,1> $notrigger 0=launch triggers after, 1=disable triggers + * @return int Return integer <0 if KO, >0 if OK */ public function delete($user, $notrigger = 0) { @@ -503,7 +504,7 @@ class AdvanceTargetingMailing extends CommonObject * Save query in database to retrieve it * * @param User $user User that deletes - * @param array $arrayquery All element to Query + * @param array $arrayquery All element to Query * @return int Return integer <0 if KO, >0 if OK */ public function savequery($user, $arrayquery) @@ -531,7 +532,7 @@ class AdvanceTargetingMailing extends CommonObject /** * Load object in memory from database * - * @param array $arrayquery All element to Query + * @param array $arrayquery All element to Query * @return int Return integer <0 if KO, >0 if OK */ public function query_thirdparty($arrayquery) @@ -638,7 +639,7 @@ class AdvanceTargetingMailing extends CommonObject } } elseif ($extrafields->attributes[$elementtype]['type'][$key] == 'link') { if ($arrayquery['options_'.$key] > 0) { - $sqlwhere[]= " (te.".$key." = ".((int) $arrayquery["options_".$key]).")"; + $sqlwhere[] = " (te.".$key." = ".((int) $arrayquery["options_".$key]).")"; } } else { if (is_array($arrayquery['options_'.$key])) { @@ -685,8 +686,8 @@ class AdvanceTargetingMailing extends CommonObject /** * Load object in memory from database * - * @param array $arrayquery All element to Query - * @param int $withThirdpartyFilter add contact with tridparty filter + * @param array $arrayquery All element to Query + * @param int $withThirdpartyFilter add contact with third party filter * @return int Return integer <0 if KO, >0 if OK */ public function query_contact($arrayquery, $withThirdpartyFilter = 0) diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php index b66f0314490..8061c973877 100644 --- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php +++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php @@ -53,7 +53,7 @@ class FormAdvTargetEmailing extends Form /** * Affiche un champs select contenant une liste * - * @param array $selected_array à preselectionner + * @param string[] $selected_array à preselectionner * @param string $htmlname select field * @return string select field */ @@ -92,7 +92,7 @@ class FormAdvTargetEmailing extends Form * Return combo list of activated countries, into language of user * * @param string $htmlname of html select object - * @param array $selected_array or Code or Label of preselected country + * @param string[] $selected_array or Code or Label of preselected country * @return string HTML string with select */ public function multiselectState($htmlname = 'state_id', $selected_array = array()) @@ -153,7 +153,7 @@ class FormAdvTargetEmailing extends Form * Return combo list of activated countries, into language of user * * @param string $htmlname of html select object - * @param array $selected_array or Code or Label of preselected country + * @param string[] $selected_array or Code or Label of preselected country * @return string HTML string with select */ public function multiselectCountry($htmlname = 'country_id', $selected_array = array()) @@ -213,7 +213,7 @@ class FormAdvTargetEmailing extends Form * Return select list for categories (to use in form search selectors) * * @param string $htmlname control name - * @param array $selected_array array of data + * @param string[] $selected_array array of data * @param User $user User action * @return string combo list code */ @@ -259,7 +259,7 @@ class FormAdvTargetEmailing extends Form * Return select list for categories (to use in form search selectors) * * @param string $htmlname of combo list (example: 'search_sale') - * @param array $selected_array selected array + * @param string[] $selected_array selected array * @return string combo list code */ public function multiselectselectLanguage($htmlname = '', $selected_array = array()) @@ -351,7 +351,7 @@ class FormAdvTargetEmailing extends Form * Return combo list with people title * * @param string $htmlname Name of HTML select combo field - * @param array $selected_array Array + * @param string[] $selected_array Array * @return string HTML combo */ public function multiselectCivility($htmlname = 'civilite_id', $selected_array = array()) @@ -391,8 +391,8 @@ class FormAdvTargetEmailing extends Form * Return multiselect list of entities. * * @param string $htmlname select - * @param array $options_array to manage - * @param array $selected_array to manage + * @param array $options_array to manage + * @param string[] $selected_array to manage * @param int $showempty show empty * @return string HTML combo */ diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 70d219562f1..320aac575a4 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -150,17 +150,17 @@ class Mailing extends CommonObject public $extraparams = array(); /** - * @var array statut dest + * @var array statut dest */ public $statut_dest = array(); /** - * @var array substitutionarray + * @var array substitutionarray */ public $substitutionarray; /** - * @var array substitutionarrayfortest + * @var array substitutionarrayfortest */ public $substitutionarrayfortest; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 8a5c4eecf01..a39c207144c 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -205,18 +205,21 @@ class Propal extends CommonObject public $author; /** - * @deprecated + * @var float + * @deprecated See $total_ht * @see $total_ht */ public $price; /** - * @deprecated + * @var float + * @deprecated See $total_tva * @see $total_tva */ public $tva; /** - * @deprecated + * @var float + * @deprecated See $total_ttc * @see $total_ttc */ public $total; @@ -293,6 +296,9 @@ class Propal extends CommonObject */ public $availability; + /** + * @var int|string + */ public $duree_validite; /** @@ -619,11 +625,11 @@ class Propal extends CommonObject * @param string $label ??? * @param int|string $date_start Start date of the line * @param int|string $date_end End date of the line - * @param array $array_options extrafields array + * @param array $array_options extrafields array * @param int|null $fk_unit Code of the unit to use. Null to use the default one * @param string $origin Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be 'orderdet', 'propaldet'..., else 'order','propal,'.... * @param int $origin_id Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be Id of origin object (aka line id), else object id - * @param double $pu_ht_devise Unit price in currency + * @param float $pu_ht_devise Unit price in currency * @param int $fk_remise_except Id discount if line is from a discount * @param int $noupdateafterinsertline No update after insert of line * @return int >0 if OK, <0 if KO @@ -868,11 +874,11 @@ class Propal extends CommonObject * @param int $type 0/1=Product/service * @param int|string $date_start Start date of the line * @param int|string $date_end End date of the line - * @param array $array_options extrafields array + * @param array $array_options extrafields array * @param int|null $fk_unit Code of the unit to use. Null to use the default one - * @param double $pu_ht_devise Unit price in currency + * @param float $pu_ht_devise Unit price in currency * @param int $notrigger disable line update trigger - * @param integer $rang line rank + * @param int $rang line rank * @return int 0 if OK, <0 if KO */ public function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $desc = '', $price_base_type = 'HT', $info_bits = 0, $special_code = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $type = 0, $date_start = '', $date_end = '', $array_options = array(), $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $rang = 0) @@ -2975,7 +2981,7 @@ class Propal extends CommonObject /** * Returns an array with the numbers of related invoices * - * @return array Array of invoices + * @return CommonInvoice[] Array of invoices */ public function getInvoiceArrayList() { @@ -2987,7 +2993,7 @@ class Propal extends CommonObject * Returns an array with id and ref of related invoices * * @param int $id Id propal - * @return array|int Array of invoices id + * @return CommonInvoice[]|int Array of invoices id */ public function InvoiceArrayList($id) { @@ -3917,10 +3923,10 @@ class Propal extends CommonObject * * @param string $modele Force model to use ('' to not force) * @param Translate $outputlangs Object langs to use for output - * @param int $hidedetails Hide details of lines - * @param int $hidedesc Hide description - * @param int $hideref Hide ref - * @param null|array $moreparams Array to provide more information + * @param int<0,1> $hidedetails Hide details of lines + * @param int<0,1> $hidedesc Hide description + * @param int<0,1> $hideref Hide ref + * @param ?array $moreparams Array to provide more information * @return int 0 if KO, 1 if OK */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 78b69f13082..e609fc20995 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -2027,7 +2027,7 @@ while ($i < $imaxinloop) { // Availability if (!empty($arrayfields['ava.rowid']['checked'])) { print ''; - $form->form_availability('', $obj->availability, 'none', 1); + $form->form_availability(0, $obj->availability, 'none', 1); print ''; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index cb23d053bf1..8a131436eff 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -1494,7 +1494,7 @@ if ($resql) { } $banklinestatic->id = $objp->rowid; - $banklinestatic->ref = $objp->rowid; + $banklinestatic->ref = (string) $objp->rowid; print ''; @@ -1551,25 +1551,25 @@ if ($resql) { print $banktransferstatic->getNomUrl(0).($labeltoshow ? ' ' : ''); } elseif ($links[$key]['type'] == 'payment') { $paymentstatic->id = $links[$key]['url_id']; - $paymentstatic->ref = $links[$key]['url_id']; // FIXME This is id, not ref of payment + $paymentstatic->ref = (string) $links[$key]['url_id']; // FIXME This is id, not ref of payment $paymentstatic->date = $db->jdate($objp->do); print $paymentstatic->getNomUrl(2).($labeltoshow ? ' ' : ''); } elseif ($links[$key]['type'] == 'payment_supplier') { $paymentsupplierstatic->id = $links[$key]['url_id']; - $paymentsupplierstatic->ref = $links[$key]['url_id']; // FIXME This is id, not ref of payment + $paymentsupplierstatic->ref = (string) $links[$key]['url_id']; // FIXME This is id, not ref of payment print $paymentsupplierstatic->getNomUrl(2).($labeltoshow ? ' ' : ''); } elseif ($links[$key]['type'] == 'payment_sc') { $paymentscstatic->id = $links[$key]['url_id']; - $paymentscstatic->ref = $links[$key]['url_id']; + $paymentscstatic->ref = (string) $links[$key]['url_id']; $paymentscstatic->label = $links[$key]['label']; print $paymentscstatic->getNomUrl(2).($labeltoshow ? ' ' : ''); } elseif ($links[$key]['type'] == 'payment_vat') { $paymentvatstatic->id = $links[$key]['url_id']; - $paymentvatstatic->ref = $links[$key]['url_id']; + $paymentvatstatic->ref = (string) $links[$key]['url_id']; print $paymentvatstatic->getNomUrl(2).($labeltoshow ? ' ' : ''); } elseif ($links[$key]['type'] == 'payment_salary') { $paymentsalstatic->id = $links[$key]['url_id']; - $paymentsalstatic->ref = $links[$key]['url_id']; + $paymentsalstatic->ref = (string) $links[$key]['url_id']; $paymentsalstatic->label = $links[$key]['label']; print $paymentsalstatic->getNomUrl(2).($labeltoshow ? ' ' : ''); } elseif ($links[$key]['type'] == 'payment_loan') { @@ -1578,15 +1578,15 @@ if ($resql) { print ''.($labeltoshow ? ' ' : ''); } elseif ($links[$key]['type'] == 'payment_donation') { $paymentdonationstatic->id = $links[$key]['url_id']; - $paymentdonationstatic->ref = $links[$key]['url_id']; + $paymentdonationstatic->ref = (string) $links[$key]['url_id']; print $paymentdonationstatic->getNomUrl(2).($labeltoshow ? ' ' : ''); } elseif ($links[$key]['type'] == 'payment_expensereport') { $paymentexpensereportstatic->id = $links[$key]['url_id']; - $paymentexpensereportstatic->ref = $links[$key]['url_id']; + $paymentexpensereportstatic->ref = (string) $links[$key]['url_id']; print $paymentexpensereportstatic->getNomUrl(2).($labeltoshow ? ' ' : ''); } elseif ($links[$key]['type'] == 'payment_various') { $paymentvariousstatic->id = $links[$key]['url_id']; - $paymentvariousstatic->ref = $links[$key]['url_id']; + $paymentvariousstatic->ref = (string) $links[$key]['url_id']; print $paymentvariousstatic->getNomUrl(2).($labeltoshow ? ' ' : ''); } elseif ($links[$key]['type'] == 'banktransfert') { // Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail. diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 91f1a0644cd..17971d298ba 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -56,8 +56,8 @@ class Account extends CommonObject public $picto = 'account'; /** - * @var int Use id instead of rowid - * @deprecated + * @var int + * @deprecated Use $id instead of $rowid * @see $id */ public $rowid; @@ -71,7 +71,7 @@ class Account extends CommonObject /** * Bank account type. Check TYPE_ constants * @var int - * @deprecated + * @deprecated Use $type * @see $type */ public $courant; @@ -149,7 +149,7 @@ class Account extends CommonObject * IBAN number * * @var string - * @deprecated see $iban + * @deprecated See $iban */ public $iban_prefix; @@ -162,7 +162,7 @@ class Account extends CommonObject /** * Name of account holder * @var string - * @deprecated + * @deprecated Use $owner_name * @see $owner_name */ public $proprio; @@ -190,13 +190,19 @@ class Account extends CommonObject * @var string */ public $owner_town; + /** + * @var int + */ public $owner_country_id; + /** + * @var string + */ public $owner_country_code; /** * Address of the bank account * @var string - * @deprecated + * @deprecated See $address * @see $address */ public $domiciliation; @@ -206,15 +212,27 @@ class Account extends CommonObject * @var string */ public $address; + /** + * @var int + */ public $state_id; + /** + * @var string + */ public $state_code; + /** + * @var string + */ public $state; + /** + * @var int + */ public $country_id; /** * Variable containing all account types with their respective translated label. * Defined in __construct - * @var array + * @var array */ public $type_lib = array(); @@ -517,7 +535,7 @@ class Account extends CommonObject * @param int $fk_bank To search using bank transaction id * @param int $url_id To search using link to * @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 + * @return int<-1,-1>|array Array of links array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> ) or -1 on error */ public function get_url($fk_bank = 0, $url_id = 0, $type = '') { @@ -1850,8 +1868,8 @@ class Account extends CommonObject * * Some countries show less or more bank account properties to the user * - * @param int $includeibanbic 1=Return also key for IBAN and BIC - * @return array Array of fields to show + * @param int<0,1> $includeibanbic 1=Return also key for IBAN and BIC + * @return string[] Array of fields to show * @see useDetailedBBAN() */ public function getFieldsToShow($includeibanbic = 0) @@ -1891,7 +1909,7 @@ class Account extends CommonObject * - BankAccountNumberKey * - DeskCode * - * @return array + * @return string[] */ public static function getAccountNumberOrder() { @@ -1957,14 +1975,14 @@ class Account extends CommonObject $this->owner_address = 'Owner address'; $this->owner_zip = 'Owner zip'; $this->owner_town = 'Owner town'; - $this->owner_country_id = 'Owner country_id'; + $this->owner_country_id = 1; $this->country_id = 1; return 1; } /** - * Function used to replace a thirdparty id with another one. + * Function used to replace a third party id with another one. * * @param DoliDB $dbs Database handler * @param int $origin_id Old thirdparty id @@ -2171,6 +2189,7 @@ class AccountLine extends CommonObjectLine /** * User author of the reconciliation * TODO: variable used only by method info() => is it the same as $fk_user_rappro ? + * @var int */ public $user_rappro; diff --git a/htdocs/compta/bank/class/bankcateg.class.php b/htdocs/compta/bank/class/bankcateg.class.php index 1e28275239c..c97fb2e4416 100644 --- a/htdocs/compta/bank/class/bankcateg.class.php +++ b/htdocs/compta/bank/class/bankcateg.class.php @@ -58,12 +58,12 @@ class BankCateg // extends CommonObject public $error; /** - * @var array errors + * @var string[] errors */ public $errors; /** - * @var array context + * @var array context */ public $context; diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index e61d302f6be..d976c63c5f5 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -53,8 +53,17 @@ class Deplacement extends CommonObject */ public $fk_element = ''; + /** + * @var int + */ public $fk_soc; + /** + * @var int|string + */ public $date; + /** + * @var string + */ public $type; /** @@ -408,7 +417,7 @@ class Deplacement extends CommonObject * List of types * * @param int $active Active or not - * @return array + * @return array */ public function listOfTypes($active = 1) { diff --git a/htdocs/compta/facture/class/facturestats.class.php b/htdocs/compta/facture/class/facturestats.class.php index 9750fff5f5b..e6d8b689ac2 100644 --- a/htdocs/compta/facture/class/facturestats.class.php +++ b/htdocs/compta/facture/class/facturestats.class.php @@ -34,7 +34,13 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; */ class FactureStats extends Stats { + /** + * @var int + */ public $socid; + /** + * @var int + */ public $userid; /** @@ -42,9 +48,21 @@ class FactureStats extends Stats */ public $table_element; + /** + * @var string + */ public $from; + /** + * @var string + */ public $field; + /** + * @var string + */ public $where = ''; + /** + * @var string + */ public $join; diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php index c79e400db93..7cd3648e771 100644 --- a/htdocs/compta/facture/class/paymentterm.class.php +++ b/htdocs/compta/facture/class/paymentterm.class.php @@ -1,6 +1,7 @@ * 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 @@ -45,6 +46,9 @@ class PaymentTerm // extends CommonObject //public $element='c_payment_term'; //!< Id that identify managed objects //public $table_element='c_payment_term'; //!< Name of table without prefix where object is stored + /** + * @var array + */ public $context = array(); /** @@ -58,13 +62,37 @@ class PaymentTerm // extends CommonObject */ public $entity; + /** + * @var string + */ public $code; + /** + * @var string + */ public $sortorder; + /** + * @var string + */ public $active; + /** + * @var string + */ public $libelle; + /** + * @var string + */ public $libelle_facture; + /** + * @var string + */ public $type_cdr; + /** + * @var string + */ public $nbjour; + /** + * @var string + */ public $decalage; diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php index 18d443d596f..398c7f443cc 100644 --- a/htdocs/compta/localtax/class/localtax.class.php +++ b/htdocs/compta/localtax/class/localtax.class.php @@ -45,10 +45,22 @@ class Localtax extends CommonObject */ public $picto = 'payment'; + /** + * @var int + */ public $ltt; + /** + * @var int|string + */ public $datep; + /** + * @var int|string + */ public $datev; + /** + * @var string + */ public $amount; /** @@ -61,6 +73,9 @@ class Localtax extends CommonObject */ public $fk_type; + /** + * @var string + */ public $paymenttype; /** @@ -535,7 +550,7 @@ class Localtax extends CommonObject dol_print_error($this->db); } - $bank_line_id = $acc->addline($this->datep, $this->paymenttype, $this->label, -abs((float) $this->amount), '', '', $user); + $bank_line_id = $acc->addline($this->datep, $this->paymenttype, $this->label, -abs((float) $this->amount), '', 0, $user); // Update fk_bank into llx_localtax so we know the line of localtax used to generate the bank entry. if ($bank_line_id > 0) { diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 0eb1559c2c6..17527a26591 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -50,18 +50,47 @@ class RemiseCheque extends CommonObject */ public $picto = 'payment'; + /** + * @var string + */ public $num; + /** + * @var string + */ public $intitule; - //! Numero d'erreur Plage 1024-1279 + /** + * @var int<-1033,-1024>|int<-18,-18>|int<-2,0> Error number from 1024 to 1279 + */ public $errno; + /** + * @var string + */ public $type = 'CHQ'; // 'CHQ', 'TRA', ... + /** + * @var float + */ public $amount; + /** + * @var int|string + */ public $date_bordereau; + /** + * @var int + */ public $account_id; + /** + * @var string + */ public $account_label; + /** + * @var int + */ public $author_id; + /** + * @var int + */ public $nbcheque; /** @@ -143,7 +172,7 @@ class RemiseCheque extends CommonObject * @param User $user User making creation * @param int $account_id Bank account for cheque receipt * @param int $limit Limit ref of cheque to this - * @param array $toRemise array with cheques to remise + * @param int[] $toRemise array with cheques to remise * @return int Return integer <0 if KO, >0 if OK */ public function create($user, $account_id, $limit, $toRemise) @@ -268,7 +297,7 @@ class RemiseCheque extends CommonObject } else { $this->errno = -1; $this->error = $this->db->lasterror(); - $this->errno = $this->db->lasterrno(); + // $this->errno = $this->db->lasterrno(); } if (!$this->errno && (getDolGlobalString('MAIN_DISABLEDRAFTSTATUS') || getDolGlobalString('MAIN_DISABLEDRAFTSTATUS_CHEQUE'))) { diff --git a/htdocs/compta/paiement/class/cpaiement.class.php b/htdocs/compta/paiement/class/cpaiement.class.php index a8a49ca43d3..ad4cb13dfdb 100644 --- a/htdocs/compta/paiement/class/cpaiement.class.php +++ b/htdocs/compta/paiement/class/cpaiement.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2023-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 @@ -46,14 +47,26 @@ class Cpaiement extends CommonDict /** * @var string - * @deprecated + * @deprecated Use $label * @see $label */ public $libelle; + /** + * @var string + */ public $type; + /** + * @var int<0,1> + */ public $active; + /** + * @var string + */ public $accountancy_code; + /** + * @var string + */ public $module; @@ -225,9 +238,9 @@ class Cpaiement extends CommonDict /** * Update object into database * - * @param User $user User that modifies - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int Return integer <0 if KO, >0 if OK + * @param User $user User that modifies + * @param int<0,1> $notrigger 0=launch triggers after, 1=disable triggers + * @return int Return integer <0 if KO, >0 if OK */ public function update(User $user, $notrigger = 0) { diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 03512da69a3..3230ce19918 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -79,14 +79,16 @@ class Paiement extends CommonObject public $date; /** - * @deprecated + * @deprecated Use $amount, $amounts * @see $amount, $amounts + * @var float */ public $total; /** - * @deprecated + * @deprecated Use $amount, $amounts * @see $amount, $amounts + * @var float */ public $montant; @@ -101,7 +103,7 @@ class Paiement extends CommonObject public $multicurrency_amount; /** - * @var float[] array: invoice ID => amount for that invoice (in the main currency) + * @var array array: invoice ID => amount for that invoice (in the main currency) */ public $amounts = array(); @@ -125,6 +127,9 @@ class Paiement extends CommonObject */ public $pos_change = 0.0; + /** + * @var int + */ public $author; /** @@ -774,12 +779,12 @@ class Paiement extends CommonObject $label, $totalamount, // Sign must be positive when we receive money (customer payment), negative when you give money (supplier invoice or credit note) $this->num_payment, - '', + 0, $user, $emetteur_nom, $emetteur_banque, $accountancycode, - null, + 0, '', $totalamount_main_currency ); @@ -969,9 +974,6 @@ class Paiement extends CommonObject $this->error = 'Error -1 '.$this->db->error(); } - if (!$error) { - } - if (!$error) { $this->datepaye = $date; $this->date = $date; @@ -1104,7 +1106,7 @@ class Paiement extends CommonObject * Return list of invoices the payment is related to. * * @param string $filter Filter - * @return int|array Return integer <0 if KO or array of invoice id + * @return int|int[] Return integer <0 if KO or array of invoice id * @see getAmountsArray() */ public function getBillsArray($filter = '') @@ -1138,7 +1140,7 @@ class Paiement extends CommonObject /** * Return list of amounts of payments. * - * @return int|array Array of amount of payments + * @return int|array Array of amount of payments * @see getBillsArray() */ public function getAmountsArray() diff --git a/htdocs/compta/prelevement/class/rejetprelevement.class.php b/htdocs/compta/prelevement/class/rejetprelevement.class.php index 0db8f92ffef..41c80211eb0 100644 --- a/htdocs/compta/prelevement/class/rejetprelevement.class.php +++ b/htdocs/compta/prelevement/class/rejetprelevement.class.php @@ -42,9 +42,21 @@ class RejetPrelevement */ public $db; + /** + * @var 'direct-debit'|'bank-transfer' + */ public $type; //prelevement or bank transfer + /** + * @var int + */ public $bon_id; + /** + * @var User + */ public $user; + /** + * @var int|string + */ public $date_rejet; /** @@ -70,7 +82,7 @@ class RejetPrelevement * * @param DoliDB $db Database handler * @param User $user Object user - * @param string $type Type ('direct-debit' for direct debit or 'bank-transfer' for credit transfer) + * @param 'direct-debit'|'bank-transfer' $type Type ('direct-debit' for direct debit or 'bank-transfer' for credit transfer) */ public function __construct($db, $user, $type) { @@ -105,7 +117,7 @@ class RejetPrelevement * @param string $motif Motif * @param int $date_rejet Date reject * @param int $bonid Bon id - * @param int $facturation 1=Bill the reject + * @param int<0,1> $facturation 1=Bill the reject * @return int Return >=0 if OK, <0 if KO */ public function create($user, $id, $motif, $date_rejet, $bonid, $facturation = 0) @@ -304,8 +316,9 @@ class RejetPrelevement /** * Retrieve the list of invoices * - * @param int $amounts If you want to get the amount of the order for each invoice - * @return array Array List of invoices related to the withdrawal line + * @param int<0,1> $amounts If you want to get the amount of the order for each invoice + + * @return array Array List of invoices related to the withdrawal line * @todo A withdrawal line is today linked to one and only one invoice. So the function should return only one object ? */ private function getListInvoices($amounts = 0) diff --git a/htdocs/compta/sociales/class/cchargesociales.class.php b/htdocs/compta/sociales/class/cchargesociales.class.php index b532bf42095..d6cb25828ce 100644 --- a/htdocs/compta/sociales/class/cchargesociales.class.php +++ b/htdocs/compta/sociales/class/cchargesociales.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 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 @@ -35,8 +36,14 @@ */ class Cchargesociales { + /** + * @var DoliDB + */ public $db; + /** + * @var int + */ public $id; /** @@ -51,7 +58,7 @@ class Cchargesociales /** * @var string Label - * @deprecated + * @deprecated Use $label */ public $libelle; @@ -60,8 +67,17 @@ class Cchargesociales */ public $label; + /** + * @var string + */ public $deductible; + /** + * @var string + */ public $active; + /** + * @var string + */ public $code; /** @@ -73,10 +89,13 @@ class Cchargesociales * @var string module */ public $module; + /** + * @var string + */ public $accountancy_code; /** - * @var array array of errors + * @var string[] array of errors */ public $errors = array(); @@ -151,13 +170,13 @@ class Cchargesociales $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); //if (!$notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action to call a trigger. + // Uncomment this and change MYOBJECT to your own tag if you + // want this action to call a trigger. - //// Call triggers - //$result=$this->call_trigger('MYOBJECT_CREATE',$user); - //if ($result < 0) $error++; - //// End call triggers + //// Call triggers + //$result=$this->call_trigger('MYOBJECT_CREATE',$user); + //if ($result < 0) $error++; + //// End call triggers //} } diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 712175abb4a..1d9910fec7d 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -598,7 +598,7 @@ class PaymentSocialContribution extends CommonObject $label, $total, $this->num_payment, - '', + 0, $user, $emetteur_nom, $emetteur_banque diff --git a/htdocs/compta/tva/class/paymentvat.class.php b/htdocs/compta/tva/class/paymentvat.class.php index 5f2098ce80e..f6cee6a5784 100644 --- a/htdocs/compta/tva/class/paymentvat.class.php +++ b/htdocs/compta/tva/class/paymentvat.class.php @@ -597,7 +597,7 @@ class PaymentVAT extends CommonObject $label, $total, $this->num_payment, - '', + 0, $user, $emetteur_nom, $emetteur_banque diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index f8a06cf0837..9ed504b6a13 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -679,9 +679,9 @@ class Tva extends CommonObject } if ($this->amount > 0) { - $bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, -abs((float) $this->amount), $this->num_payment, '', $user); + $bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, -abs((float) $this->amount), $this->num_payment, 0, $user); } else { - $bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, abs((float) $this->amount), $this->num_payment, '', $user); + $bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, abs((float) $this->amount), $this->num_payment, 0, $user); } // Update fk_bank into llx_tva. So we know vat line used to generate bank transaction diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php index 7aac94c5ba6..28a9186b4e6 100644 --- a/htdocs/contact/canvas/actions_contactcard_common.class.php +++ b/htdocs/contact/canvas/actions_contactcard_common.class.php @@ -33,14 +33,31 @@ abstract class ActionsContactCardCommon */ public $db; + /** + * @var string + */ public $dirmodule; + /** + * @var string + */ public $targetmodule; + /** + * @var string + */ public $canvas; + /** + * @var string + */ public $card; - //! Template container + /** + * @var array Template container + */ public $tpl = array(); - //! Object container + //! + /** + * @var Contact Object container + */ public $object; /** @@ -295,13 +312,13 @@ abstract class ActionsContactCardCommon $this->object->zip = GETPOST("zipcode"); $this->object->town = GETPOST("town"); $this->object->country_id = GETPOST("country_id") ? GETPOST("country_id") : $mysoc->country_id; - $this->object->state_id = GETPOST("state_id"); + $this->object->state_id = GETPOSTINT("state_id"); $this->object->phone_pro = GETPOST("phone_pro"); $this->object->phone_perso = GETPOST("phone_perso"); $this->object->phone_mobile = GETPOST("phone_mobile"); $this->object->fax = GETPOST("fax"); $this->object->email = GETPOST("email"); - $this->object->priv = GETPOST("priv"); + $this->object->priv = GETPOSTINT("priv"); $this->object->note = GETPOST("note", "restricthtml"); $this->object->canvas = GETPOST("canvas"); @@ -309,14 +326,17 @@ abstract class ActionsContactCardCommon if ($this->object->country_id) { $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".((int) $this->object->country_id); $resql = $this->db->query($sql); + $obj = null; if ($resql) { $obj = $this->db->fetch_object($resql); } else { dol_print_error($this->db); } - $this->object->country_id = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label; - $this->object->country_code = $obj->code; - $this->object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label; + if ($obj !== null) { + $this->object->country_id = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label; + $this->object->country_code = $obj->code; + $this->object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label; + } } } } diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 553cd49ddf5..08041134de3 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -129,8 +129,17 @@ class Contact extends CommonObject 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'visible' => -1, 'position' => 1000), ); + /** + * @var string + */ public $civility_id; // In fact we store civility_code + /** + * @var string + */ public $civility_code; + /** + * @var string + */ public $civility; /** @@ -150,7 +159,7 @@ class Contact extends CommonObject /** * @var string The civilite code, not an integer - * @deprecated + * @deprecated Use $civility_code * @see $civility_code */ public $civilite; @@ -204,6 +213,9 @@ class Contact extends CommonObject * @var int Thirdparty ID */ public $socid; // both socid and fk_soc are used + /** + * @var int + */ public $fk_soc; // both socid and fk_soc are used /** @@ -216,6 +228,9 @@ class Contact extends CommonObject */ public $statut; + /** + * @var string + */ public $code; /** @@ -227,7 +242,7 @@ class Contact extends CommonObject /** * Email * @var string - * @deprecated + * @deprecated Use $email * @see $email */ public $mail; @@ -247,7 +262,7 @@ class Contact extends CommonObject /** * Array of social-networks - * @var array + * @var array */ public $socialnetworks; @@ -333,13 +348,16 @@ class Contact extends CommonObject * Old copy * @var static */ - public $oldcopy; // To contains a clone of this when we need to save old properties of object + public $oldcopy; // To contain a clone of this when we need to save old properties of object /** - * @var array roles + * @var array roles */ public $roles; + /** + * @var array + */ public $cacheprospectstatus = array(); /** @@ -347,8 +365,14 @@ class Contact extends CommonObject */ public $fk_prospectlevel; + /** + * @var int + */ public $stcomm_id; + /** + * @var string + */ public $statut_commercial; /** @@ -755,11 +779,11 @@ class Contact extends CommonObject /** * Return DN string complete in the LDAP directory for the object * - * @param array $info Info string loaded by _load_ldap_info - * @param int $mode 0=Return full DN (uid=qqq,ou=xxx,dc=aaa,dc=bbb) - * 1=Return DN without key inside (ou=xxx,dc=aaa,dc=bbb) - * 2=Return key only (uid=qqq) - * @return string DN + * @param array $info Info array loaded by _load_ldap_info + * @param int<0,2> $mode 0=Return full DN (uid=qqq,ou=xxx,dc=aaa,dc=bbb) + * 1=Return DN without key inside (ou=xxx,dc=aaa,dc=bbb) + * 2=Return key only (uid=qqq) + * @return string DN */ public function _load_ldap_dn($info, $mode = 0) { @@ -782,7 +806,7 @@ class Contact extends CommonObject /** * Initialize info table (LDAP attributes table) * - * @return array Attributes info table + * @return array Attributes info table */ public function _load_ldap_info() { @@ -1867,7 +1891,7 @@ class Contact extends CommonObject * Get thirdparty contact roles of a given contact * * @param string $element Element type - * @return array|int Array of contact roles or -1 + * @return array|int<-1,-1> Array of contact roles or -1 * @throws Exception */ public function getContactRoles($element = '') diff --git a/htdocs/core/class/ccountry.class.php b/htdocs/core/class/ccountry.class.php index 179eaaf2edb..43a4bee56b9 100644 --- a/htdocs/core/class/ccountry.class.php +++ b/htdocs/core/class/ccountry.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 @@ -30,13 +31,25 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondict.class.php'; */ class Ccountry extends CommonDict { + /** + * @var string + */ public $element = 'ccountry'; //!< Id that identify managed objects + /** + * @var string + */ public $table_element = 'c_country'; //!< Name of table without prefix where object is stored + /** + * @var string + */ public $code_iso; + /** + * @var array|string,position:int,notnull?:int,visible:int<-2,5>|string,alwayseditable?:int<0,1>,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,2>,disabled?:int<0,1>,arrayofkeyval?:array,comment?:string,validate?:int<0,1>}> + */ public $fields = array( - 'label' => array('type'=>'varchar(250)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>15, 'notnull'=>-1, 'showoncombobox'=>'1') + 'label' => array('type' => 'varchar(250)', 'label' => 'Label', 'enabled' => 1, 'visible' => 1, 'position' => 15, 'notnull' => -1, 'showoncombobox' => 1) ); diff --git a/htdocs/core/class/cgenericdic.class.php b/htdocs/core/class/cgenericdic.class.php index c39f8cbbf23..fd4016f4dc5 100644 --- a/htdocs/core/class/cgenericdic.class.php +++ b/htdocs/core/class/cgenericdic.class.php @@ -48,6 +48,9 @@ class CGenericDic extends CommonDict */ public $lines = array(); + /** + * @var string + */ public $code; /** @@ -55,6 +58,9 @@ class CGenericDic extends CommonDict */ public $label; + /** + * @var int<0,1> + */ public $active; diff --git a/htdocs/core/class/commonhookactions.class.php b/htdocs/core/class/commonhookactions.class.php index 8b5067f03cf..dc22ca652fe 100644 --- a/htdocs/core/class/commonhookactions.class.php +++ b/htdocs/core/class/commonhookactions.class.php @@ -50,8 +50,8 @@ abstract class CommonHookActions /** * Check context of hook - * @param array $parameters Hook parameters. - * @param array|string $allContexts Context to check + * @param array $parameters Hook parameters. + * @param string[]|string $allContexts Context to check * @return bool */ protected function isContext($parameters, $allContexts) diff --git a/htdocs/core/class/commonstickergenerator.class.php b/htdocs/core/class/commonstickergenerator.class.php index bb7330e6ecc..4e722c21dc3 100644 --- a/htdocs/core/class/commonstickergenerator.class.php +++ b/htdocs/core/class/commonstickergenerator.class.php @@ -68,6 +68,9 @@ abstract class CommonStickerGenerator extends CommonDocGenerator */ public $db; + /** + * @var string + */ public $code; // Code of format // phpcs:disable PEAR.NamingConventions.ValidVariableName.PublicUnderscore @@ -103,10 +106,13 @@ abstract class CommonStickerGenerator extends CommonDocGenerator protected $_COUNTX = 1; protected $_COUNTY = 1; protected $_First = 1; + /** + * @var array{name:string,paper-size:string,orientation:string,metric:string,marginLeft:float,marginTop:float,NX:int,NY:int,SpaceX:float,SpaceY:float,width:float,height:float,font-size:float,custom_x:float,custom_y:float} + */ public $Tformat; /** - * @var array + * @var array */ public $_Avery_Labels; // phpcs:enable @@ -125,7 +131,7 @@ abstract class CommonStickerGenerator extends CommonDocGenerator /** * Function to build PDF on disk, then output on HTTP stream. * - * @param array $arrayofrecords Array of record information (array('textleft'=>,'textheader'=>, ..., 'id'=>,'photo'=>) + * @param array $arrayofrecords Array of record information (array('textleft'=>,'textheader'=>, ..., 'id'=>,'photo'=>) * @param Translate $outputlangs Lang object for output language * @param string $srctemplatepath Full path of source filename for generator using a template file * @param string $outputdir Output directory for pdf file @@ -137,9 +143,9 @@ abstract class CommonStickerGenerator extends CommonDocGenerator /** * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0) * - * @param TCPDF $pdf PDF reference + * @param TCPDF $pdf PDF reference * @param Translate $outputlangs Output langs - * @param array $param Associative array containing label content and optional parameters + * @param array $param Associative array containing label content and optional parameters * @return void */ abstract public function addSticker(&$pdf, $outputlangs, $param); diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 9a213d994a6..c8238d4770c 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2010-2012 Regis Houssin * Copyright (C) 2010-2018 Juanjo Menent * 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 @@ -357,13 +358,13 @@ class FormActions /** * Output html select list of type of event * - * @param array|string $selected Type pre-selected (can be 'manual', 'auto' or 'AC_xxx'). Can be an array too. + * @param string[]|string $selected Type pre-selected (can be 'manual', 'auto' or 'AC_xxx'). Can be an array too. * @param string $htmlname Name of select field * @param string $excludetype A type to exclude ('systemauto', 'system', '') - * @param integer $onlyautoornot 1=Group all type AC_XXX into 1 line AC_MANUAL. 0=Keep details of type, -1=Keep details and add a combined line "All manual", -2=Combined line is disabled (not implemented yet) - * @param int $hideinfohelp 1=Do not show info help, 0=Show, -1=Show+Add info to tell how to set default value - * @param int $multiselect 1=Allow multiselect of action type - * @param int $nooutput 1=No output + * @param int<-2,1> $onlyautoornot 1=Group all type AC_XXX into 1 line AC_MANUAL. 0=Keep details of type, -1=Keep details and add a combined line "All manual", -2=Combined line is disabled (not implemented yet) + * @param int<-1,1> $hideinfohelp 1=Do not show info help, 0=Show, -1=Show+Add info to tell how to set default value + * @param int<0,1> $multiselect 1=Allow multiselect of action type + * @param int<0,1> $nooutput 1=No output * @param string $morecss More css to add to SELECT component. * @param int<0,1>|string $showempty 0 or 1 or 'Placeholder string' * @return string @@ -391,7 +392,7 @@ class FormActions $selected = 'AC_OTH_AUTO'; } - if (getDolGlobalString('AGENDA_ALWAYS_HIDE_AUTO')) { + if (array_key_exists('AC_OTH_AUTO', $arraylist) && getDolGlobalString('AGENDA_ALWAYS_HIDE_AUTO')) { unset($arraylist['AC_OTH_AUTO']); } diff --git a/htdocs/core/lib/format_cards.lib.php b/htdocs/core/lib/format_cards.lib.php index 89a6a33126a..2f3e48f8b83 100644 --- a/htdocs/core/lib/format_cards.lib.php +++ b/htdocs/core/lib/format_cards.lib.php @@ -2,6 +2,7 @@ /* Copyright (C) 2006-2012 Laurent Destailleur * Copyright (C) 2006 Rodolphe Quiedeville * Copyright (C) 2007 Patrick Raguin + * 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 @@ -42,7 +43,6 @@ if ($resql) { $_Avery_Labels[$row['code']]['metric'] = $row['metric']; $_Avery_Labels[$row['code']]['marginLeft'] = $row['leftmargin']; $_Avery_Labels[$row['code']]['marginTop'] = $row['topmargin']; - $_Avery_Labels[$row['code']]['marginTop'] = $row['topmargin']; $_Avery_Labels[$row['code']]['NX'] = $row['nx']; $_Avery_Labels[$row['code']]['NY'] = $row['ny']; $_Avery_Labels[$row['code']]['SpaceX'] = $row['spacex']; diff --git a/htdocs/core/modules/cheque/modules_chequereceipts.php b/htdocs/core/modules/cheque/modules_chequereceipts.php index d75805a1174..bf701ac64d4 100644 --- a/htdocs/core/modules/cheque/modules_chequereceipts.php +++ b/htdocs/core/modules/cheque/modules_chequereceipts.php @@ -111,6 +111,18 @@ abstract class ModeleChequeReceipts extends CommonDocGenerator return $list; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Fonction to generate document on disk + * + * @param RemiseCheque $object Object RemiseCheque + * @param string $_dir Directory + * @param string $number Number + * @param Translate $outputlangs Lang output object + * @return int<-1,1> 1=ok, 0=ko + */ + abstract public function write_file($object, $_dir, $number, $outputlangs); + // phpcs:enable } diff --git a/htdocs/core/modules/member/doc/pdf_standard_member.class.php b/htdocs/core/modules/member/doc/pdf_standard_member.class.php index 7664273c542..1842964ea5f 100644 --- a/htdocs/core/modules/member/doc/pdf_standard_member.class.php +++ b/htdocs/core/modules/member/doc/pdf_standard_member.class.php @@ -353,8 +353,9 @@ class pdf_standard_member extends CommonStickerGenerator $filename .= '.pdf'; // standard format or custom - if ($this->Tformat['paper-size'] != 'custom') { - $this->format = $this->Tformat['paper-size']; + $paper_size = $this->Tformat['paper-size']; + if (!is_string($paper_size) || $paper_size != 'custom') { + $this->format = $paper_size; } else { //custom $resolution = array($this->Tformat['custom_x'], $this->Tformat['custom_y']); diff --git a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php index c87e770b5eb..01064493aad 100644 --- a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php +++ b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php @@ -5,6 +5,7 @@ * Copyright (C) 2002-2003 Jean-Louis Bergamo * Copyright (C) 2006-2013 Laurent Destailleur * Copyright (C) 2015 Francis Appels + * 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,8 +248,9 @@ class pdf_standardlabel extends CommonStickerGenerator } $this->type = 'pdf'; // standard format or custom - if ($this->Tformat['paper-size'] != 'custom') { - $this->format = $this->Tformat['paper-size']; + $paper_size = $this->Tformat['paper-size']; + if (!is_string($paper_size) || $paper_size != 'custom') { + $this->format = $paper_size; } else { //custom $resolution = array($this->Tformat['custom_x'], $this->Tformat['custom_y']); @@ -337,7 +339,7 @@ class pdf_standardlabel extends CommonStickerGenerator dolChmod($file); - $this->result = array('fullpath'=>$file); + $this->result = array('fullpath' => $file); return 1; } diff --git a/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php b/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php index e133a2309c4..5caf4e4e2b3 100644 --- a/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php +++ b/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php @@ -5,6 +5,7 @@ * Copyright (C) 2002-2003 Jean-Louis Bergamo * Copyright (C) 2006-2013 Laurent Destailleur * Copyright (C) 2015 Francis Appels + * 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 @@ -270,8 +271,9 @@ class pdf_tcpdflabel extends CommonStickerGenerator } $this->type = 'pdf'; // standard format or custom - if ($this->Tformat['paper-size'] != 'custom') { - $this->format = $this->Tformat['paper-size']; + $paper_size = $this->Tformat['paper-size']; + if (!is_string($paper_size) || $paper_size != 'custom') { + $this->format = $paper_size; } else { //custom $resolution = array($this->Tformat['custom_x'], $this->Tformat['custom_y']); @@ -360,7 +362,7 @@ class pdf_tcpdflabel extends CommonStickerGenerator dolChmod($file); - $this->result = array('fullpath'=>$file); + $this->result = array('fullpath' => $file); return 1; } diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 38cbbbd496b..3eeba57f01d 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -117,6 +117,8 @@ parameters: - '#function dolGetButtonAction expects array\{confirm\?: array.*confirm: true} given.#' - '#(?:make_substitutions expects array,) string given\.#' - '# (DolibarrApiAccess|Documents|Login|Setup|Status|Boms|Categories|AgendaEvents|Proposals|Orders|BankAccounts|Invoices|Contracts|Donations|Shipments|KnowledgeManagement|Mos|MultiCurrencies|Partnerships|Products|Tasks|Warehouses|Tickets|Workstation|WorkstationResource|WorkstationUserGroup|Zapier)::.* no value type specified in iterable type array\.#' + - '#Property RemiseCheque::\$account_id \(int\) does not accept string\.#' + - '#Property Contact::\$roles \(array\) does not accept non-empty-array\.#' internalErrorsCountLimit: 50 cache: diff --git a/pyproject.toml b/pyproject.toml index 198bd29465c..a14e7614a89 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta" # `codespell` can be run as a standalone program from the CLI # with the appropriate default options. -skip = "*/.*/*,*/langs/*,*/build/exe/*,**.log,*.pdf,*.PDF,*dev/resources/*,*.phar,*.z,*.gz,*.sql,*.svg,*htdocs/includes/*,*/textiso.txt,*.js,*README-*,*build/rpm/*spec,*build/pad/*ml,*htdocs/includes/phpoffice/*,*htdocs/includes/tecnickcom/*,*dev/initdemo/removeconfdemo.sh,*dev/tools/codespell/*,*dev/trans*/ignore_translation_keys.lst,*pyproject.toml,*build/exe/*,*fontawe*,*htdocs/theme/*/flags-sprite.inc.php,*dev/setup/codetemplates/codetemplates.xml,*/php.ini,*/html_cerfafr.*,*/lessc.class.php,*.asciidoc,*.xml,*opensurvey/css/style.css,*dev/tools/phan/stubs/*,*/documents" +skip = "*/.*/*,*/langs/*,*/build/exe/*,**.log,*.pdf,*.PDF,*dev/resources/*,*.phar,*.z,*.gz,*.sql,*.svg,*htdocs/includes/*,*/textiso.txt,*.js,*README-*,*build/rpm/*spec,*build/pad/*ml,*htdocs/includes/phpoffice/*,*htdocs/includes/tecnickcom/*,*dev/initdemo/removeconfdemo.sh,*dev/tools/codespell/*,*dev/trans*/ignore_translation_keys.lst,*pyproject.toml,*build/exe/*,*fontawe*,*htdocs/theme/*/flags-sprite.inc.php,*dev/setup/codetemplates/codetemplates.xml,*/php.ini,*/html_cerfafr.*,*/lessc.class.php,*.asciidoc,*.xml,*opensurvey/css/style.css,*dev/tools/phan/stubs/*,*/documents,phpstan.*" check-hidden = true quiet-level=2 From 701fbcc15a152956315b90b6300dd05d21a23523 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 26 Oct 2024 13:01:38 +0200 Subject: [PATCH 05/13] Update phpstan.neon.dist for level 6 (#31561) --- phpstan.neon.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 3eeba57f01d..8f96fbcae87 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -116,7 +116,7 @@ parameters: - '#Call to function array_key_exists.. with .error. .* will always evaluate to false.#' - '#function dolGetButtonAction expects array\{confirm\?: array.*confirm: true} given.#' - '#(?:make_substitutions expects array,) string given\.#' - - '# (DolibarrApiAccess|Documents|Login|Setup|Status|Boms|Categories|AgendaEvents|Proposals|Orders|BankAccounts|Invoices|Contracts|Donations|Shipments|KnowledgeManagement|Mos|MultiCurrencies|Partnerships|Products|Tasks|Warehouses|Tickets|Workstation|WorkstationResource|WorkstationUserGroup|Zapier)::.* no value type specified in iterable type array\.#' + - '# (DolibarrApiAccess|Documents|Login|Setup|Status|Boms|Categories|ExpenseReports|Interventions|AgendaEvents|Proposals|Orders|BankAccounts|Invoices|Contracts|Donations|Shipments|SupplierInvoices|SupplierOrders|KnowledgeManagement|Mos|MultiCurrencies|Partnerships|Products|Tasks|Warehouses|Tickets|Workstation|WorkstationResource|WorkstationUserGroup|Zapier)::.* no value type specified in iterable type array\.#' - '#Property RemiseCheque::\$account_id \(int\) does not accept string\.#' - '#Property Contact::\$roles \(array\) does not accept non-empty-array\.#' From e0c1b067d80e0d80c0d6d483cfbd2debaf3bac5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 26 Oct 2024 13:02:00 +0200 Subject: [PATCH 06/13] add phpdoc (#31562) * add phpdoc * add phpdoc * add phpdoc * add phpdoc * add phpdoc --- htdocs/core/lib/invoice.lib.php | 4 +-- htdocs/user/class/usergroup.class.php | 41 ++++++++++++++++++--------- htdocs/webservices/server_user.php | 10 +++---- 3 files changed, 34 insertions(+), 21 deletions(-) diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index aa5a656b64f..fd21d5462b2 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -274,7 +274,7 @@ function invoice_rec_prepare_head($object) $obj = $db->fetch_object($resql); $nbFacture = $obj->nb; } else { - dol_syslog('Failed to count facture with facture_rec '.$db->lasterror(), LOG_ERR); + dol_syslog('Failed to count invoices with invoice model '.$db->lasterror(), LOG_ERR); } if ($nbFacture > 0) { $head[$h][1] .= ''.$nbFacture.''; @@ -391,7 +391,7 @@ function supplier_invoice_rec_prepare_head($object) $obj = $db->fetch_object($resql); $nbFactureFourn = $obj->nb; } else { - dol_syslog('Failed to count facture with facture fournisseur model '.$db->lasterror(), LOG_ERR); + dol_syslog('Failed to count invoices with supplier invoice model '.$db->lasterror(), LOG_ERR); } if ($nbFactureFourn > 0) { $head[$h][1] .= ''.$nbFactureFourn.''; diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 399eef86db3..275b2290320 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -1,14 +1,14 @@ - * Copyright (c) 2005-2018 Laurent Destailleur - * Copyright (c) 2005-2018 Regis Houssin - * Copyright (C) 2012 Florian Henry - * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2014 Alexis Algoud - * Copyright (C) 2018 Nicolas ZABOURI +/* Copyright (c) 2005 Rodolphe Quiedeville + * Copyright (c) 2005-2018 Laurent Destailleur + * Copyright (c) 2005-2018 Regis Houssin + * Copyright (C) 2012 Florian Henry + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2014 Alexis Algoud + * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2019 Abbes Bahfir - * Copyright (C) 2023-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2023-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 @@ -93,15 +93,28 @@ class UserGroup extends CommonObject public $note; /** - * @var User[] + * @var User[] Array of users */ - public $members = array(); // Array of users + public $members = array(); - public $nb_rights; // Number of rights granted to the user - public $nb_users; // Number of users in the group + /** + * @var int Number of rights granted to the user + */ + public $nb_rights; - public $rights; // Permissions of the group + /** + * @var int Number of users in the group + */ + public $nb_users; + /** + * @var stdClass Permissions of the group + */ + public $rights; + + /** + * @var array Cache array of already loaded permissions + */ private $_tab_loaded = array(); // Array of cache of already loaded permissions /** diff --git a/htdocs/webservices/server_user.php b/htdocs/webservices/server_user.php index 6d6bd486fd4..e066bf36cca 100644 --- a/htdocs/webservices/server_user.php +++ b/htdocs/webservices/server_user.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2006-2016 Laurent Destailleur * Copyright (C) 2024 MDW * Copyright (C) 2024 Frédéric France * @@ -324,7 +324,7 @@ $server->register( /** * Get produt or service * - * @param array $authentication Array of authentication information + * @param array{login:string,password:string,entity:?int,dolibarrkey:string} $authentication Array of authentication information * @param int $id Id of object * @param string $ref Ref of object * @param string $ref_ext Ref external of object @@ -417,7 +417,7 @@ function getUser($authentication, $id, $ref = '', $ref_ext = '') /** * getListOfGroups * - * @param array $authentication Array of authentication information + * @param array{login:string,password:string,entity:?int,dolibarrkey:string} $authentication Array of authentication information * @return array Array result */ function getListOfGroups($authentication) @@ -485,7 +485,7 @@ function getListOfGroups($authentication) /** * Create an external user with thirdparty and contact * - * @param array $authentication Array of authentication information + * @param array{login:string,password:string,entity:?int,dolibarrkey:string} $authentication Array of authentication information * @param array $thirdpartywithuser Datas * @return mixed */ @@ -684,7 +684,7 @@ function createUserFromThirdparty($authentication, $thirdpartywithuser) /** * Set password of an user * - * @param array $authentication Array of authentication information + * @param array{login:string,password:string,entity:?int,dolibarrkey:string} $authentication Array of authentication information * @param array $shortuser Array of login/password info * @return mixed */ From 19b653a599f1471e1785a0fc2d97b19d4b57a200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 26 Oct 2024 13:03:04 +0200 Subject: [PATCH 07/13] fix phpstan (#31564) * fix phpstan * fix phpstan --- htdocs/core/lib/functionsnumtoword.lib.php | 9 +++++---- .../doc/pdf_standard_supplierpayment.modules.php | 2 +- phpstan.neon.dist | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/functionsnumtoword.lib.php b/htdocs/core/lib/functionsnumtoword.lib.php index 50b0dacbe92..7c7ace312da 100644 --- a/htdocs/core/lib/functionsnumtoword.lib.php +++ b/htdocs/core/lib/functionsnumtoword.lib.php @@ -1,7 +1,8 @@ - * Copyright (C) 2015 Víctor Ortiz Pérez - * Copyright (C) 2024 MDW +/* Copyright (C) 2015 Laurent Destailleur + * Copyright (C) 2015 Víctor Ortiz Pérez + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France * * 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 @@ -139,7 +140,7 @@ function dol_convertToWord($num, $langs, $currency = '', $centimes = false) $concatWords .= ' '.$langs->transnoentities('and'); } - $concatWords .= ' '.dol_convertToWord($decimalpart, $langs, '', true); + $concatWords .= ' '.dol_convertToWord((float) $decimalpart, $langs, '', true); if (!empty($currency)) { $concatWords .= ' '.$langs->transnoentities('centimes'); } diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard_supplierpayment.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard_supplierpayment.modules.php index 27b79ba5c41..57ac5692220 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard_supplierpayment.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard_supplierpayment.modules.php @@ -524,7 +524,7 @@ class pdf_standard_supplierpayment extends ModelePDFSuppliersPayments // translate amount $currency = $conf->currency; - $translateinletter = strtoupper(dol_convertToWord(price2num($object->amount, 'MT'), $outputlangs, $currency)); + $translateinletter = strtoupper(dol_convertToWord((float) price2num($object->amount, 'MT'), $outputlangs, $currency)); $pdf->SetXY($this->marge_gauche + 50, $posy); $pdf->SetFont('', '', $default_font_size - 3); $pdf->MultiCell(90, 8, $translateinletter, 0, 'L', 1); diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 8f96fbcae87..483e829b74e 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -88,7 +88,7 @@ parameters: - '#(?:dol_(?:mktime|remove_file_process)|print_actions_filter) expects int, array\|string given\.#' - '# (CSMSFile) constructor expects int, array\|string given.#' - '#(?:ProductFournisseur::logPrice\(\)) expects float\|null#' - - '#(?:(?:Asset::addDepreciationL|Facture(?:(?:(?:Fournisseur)?::add|Fournisseur::update)l))ine\(\)|calcul_price_total|dol_convertToWord|(?:loanCalcMonthlyPaymen|print_paypal_redirec)t) expects float, string given.#' + - '#(?:(?:Asset::addDepreciationL|Facture(?:(?:(?:Fournisseur)?::add|Fournisseur::update)l))ine\(\)|calcul_price_total|(?:loanCalcMonthlyPaymen|print_paypal_redirec)t) expects float, string given.#' - '#EvalMath::trigger\(\) expects string\|null,#' - '#(?:F(?:acture(?:(?:Fournisseur)?Rec::addline\(\))|ichinterRec::addLineRec\(\))|dolMd2Html|setEventMessages) expects string\|null,#' - '#::printStdColumnContent\(\) expects string, float(\|(int|array)(\<.*\>)?)* given.#' From 17e69f8a2142f161087cf89106c567ac99ab7f3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 26 Oct 2024 13:03:52 +0200 Subject: [PATCH 08/13] fix phpstan (#31565) * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan * fix phpstan --- htdocs/admin/debugbar.php | 3 +- htdocs/admin/fckeditor.php | 2 +- htdocs/core/actions_extrafields.inc.php | 71 ++++++++++--------- htdocs/expedition/dispatch.php | 23 +++--- htdocs/fourn/commande/dispatch.php | 24 +++---- .../commande/tpl/linkedobjectblock.tpl.php | 9 ++- htdocs/reception/dispatch.php | 4 +- phpstan.neon.dist | 2 +- 8 files changed, 73 insertions(+), 65 deletions(-) diff --git a/htdocs/admin/debugbar.php b/htdocs/admin/debugbar.php index 1f0ae7679ca..ce41dd01334 100644 --- a/htdocs/admin/debugbar.php +++ b/htdocs/admin/debugbar.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2007 Rodolphe Quiedeville * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2024 Frédéric France * * 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 @@ -60,7 +61,7 @@ if ($action == 'set') { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { $db->rollback(); - setEventMessages($error, null, 'errors'); + setEventMessages($langs->trans("Error"), null, 'errors'); } } diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php index db18b396bcb..4f2d66f1dc4 100644 --- a/htdocs/admin/fckeditor.php +++ b/htdocs/admin/fckeditor.php @@ -152,7 +152,7 @@ print load_fiche_titre($langs->trans("AdvancedEditor"), $linkback, 'title_setup' print '
'; if (empty($conf->use_javascript_ajax)) { - setEventMessages(array($langs->trans("NotAvailable"), $langs->trans("JavascriptDisabled")), null, 'errors'); + setEventMessages(null, array($langs->trans("NotAvailable"), $langs->trans("JavascriptDisabled")), 'errors'); } else { print ''; print ''; diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index 816699e8989..1cbe46885d7 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -24,9 +24,11 @@ * \brief Code for actions on extrafields admin pages */ + /** @var ExtraFields $extrafields */ $maxsizestring = 255; $maxsizeint = 10; -$mesg = array(); +$mesg = ''; +$mesgs = array(); $extrasize = GETPOST('size', 'intcomma'); $type = GETPOST('type', 'alphanohtml'); @@ -69,61 +71,61 @@ if ($action == 'add') { if (!$type) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); + $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); $action = 'create'; } if ($type == 'varchar' && $extrasize <= 0) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); + $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); $action = 'edit'; } if ($type == 'varchar' && $extrasize > $maxsizestring) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); + $mesgs[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); $action = 'create'; } if ($type == 'int' && $extrasize > $maxsizeint) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); + $mesgs[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); $action = 'create'; } if ($type == 'stars' && ($extrasize < 1 || $extrasize > 10)) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorSizeForStarsType"); + $mesgs[] = $langs->trans("ErrorSizeForStarsType"); $action = 'create'; } if ($type == 'select' && !$param) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForSelectType"); + $mesgs[] = $langs->trans("ErrorNoValueForSelectType"); $action = 'create'; } if ($type == 'sellist' && !$param) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForSelectListType"); + $mesgs[] = $langs->trans("ErrorNoValueForSelectListType"); $action = 'create'; } if ($type == 'checkbox' && !$param) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForCheckBoxType"); + $mesgs[] = $langs->trans("ErrorNoValueForCheckBoxType"); $action = 'create'; } if ($type == 'link' && !$param) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForLinkType"); + $mesgs[] = $langs->trans("ErrorNoValueForLinkType"); $action = 'create'; } if ($type == 'radio' && !$param) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForRadioType"); + $mesgs[] = $langs->trans("ErrorNoValueForRadioType"); $action = 'create'; } if ((($type == 'radio') || ($type == 'checkbox')) && $param) { @@ -136,13 +138,13 @@ if ($action == 'add') { if (count($matches[0]) > 1) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); + $mesgs[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); $action = 'create'; } } else { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); + $mesgs[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); $action = 'create'; } } @@ -153,7 +155,7 @@ if ($action == 'add') { if (strlen(GETPOST('attrname', 'aZ09')) < 3) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorValueLength", $langs->transnoentitiesnoconv("AttributeCode"), 3); + $mesgs[] = $langs->trans("ErrorValueLength", $langs->transnoentitiesnoconv("AttributeCode"), 3); $action = 'create'; } } @@ -163,7 +165,7 @@ if ($action == 'add') { if (in_array(strtoupper(GETPOST('attrname', 'aZ09')), $listofreservedwords)) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorReservedKeyword", GETPOST('attrname', 'aZ09')); + $mesgs[] = $langs->trans("ErrorReservedKeyword", GETPOST('attrname', 'aZ09')); $action = 'create'; } } @@ -233,17 +235,18 @@ if ($action == 'add') { } else { $error++; $mesg = $extrafields->error; - setEventMessages($mesg, null, 'errors'); + $mesgs = array_merge($mesgs, $extrafields->errors); + setEventMessages($mesg, $mesgs, 'errors'); } } else { $error++; $langs->load("errors"); $mesg = $langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters", $langs->transnoentities("AttributeCode")); - setEventMessages($mesg, null, 'errors'); + setEventMessages($mesg, $mesgs, 'errors'); $action = 'create'; } } else { - setEventMessages($mesg, null, 'errors'); + setEventMessages($mesg, $mesgs, 'errors'); } } } @@ -255,55 +258,55 @@ if ($action == 'update') { if (!$type) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); + $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); $action = 'edit'; } if ($type == 'varchar' && $extrasize <= 0) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); + $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); $action = 'edit'; } if ($type == 'varchar' && $extrasize > $maxsizestring) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); + $mesgs[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); $action = 'edit'; } if ($type == 'int' && $extrasize > $maxsizeint) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); + $mesgs[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); $action = 'edit'; } if ($type == 'select' && !$param) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForSelectType"); + $mesgs[] = $langs->trans("ErrorNoValueForSelectType"); $action = 'edit'; } if ($type == 'sellist' && !$param) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForSelectListType"); + $mesgs[] = $langs->trans("ErrorNoValueForSelectListType"); $action = 'edit'; } if ($type == 'stars' && ($extrasize < 1|| $extrasize > 10)) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorSizeForStarsType"); + $mesgs[] = $langs->trans("ErrorSizeForStarsType"); $action = 'edit'; } if ($type == 'checkbox' && !$param) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForCheckBoxType"); + $mesgs[] = $langs->trans("ErrorNoValueForCheckBoxType"); $action = 'edit'; } if ($type == 'radio' && !$param) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForRadioType"); + $mesgs[] = $langs->trans("ErrorNoValueForRadioType"); $action = 'edit'; } if ((($type == 'radio') || ($type == 'checkbox')) && $param) { @@ -316,13 +319,13 @@ if ($action == 'update') { if (count($matches[0]) > 1) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); + $mesgs[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); $action = 'edit'; } } else { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); + $mesgs[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); $action = 'edit'; } } @@ -333,7 +336,7 @@ if ($action == 'update') { if (strlen(GETPOST('attrname', 'aZ09')) < 3 && !getDolGlobalString('MAIN_DISABLE_EXTRAFIELDS_CHECK_FOR_UPDATE')) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorValueLength", $langs->transnoentitiesnoconv("AttributeCode"), 3); + $mesgs[] = $langs->trans("ErrorValueLength", $langs->transnoentitiesnoconv("AttributeCode"), 3); $action = 'edit'; } } @@ -343,7 +346,7 @@ if ($action == 'update') { if (in_array(strtoupper(GETPOST('attrname', 'aZ09')), $listofreservedwords) && !getDolGlobalString('MAIN_DISABLE_EXTRAFIELDS_CHECK_FOR_UPDATE')) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorReservedKeyword", GETPOST('attrname', 'aZ09')); + $mesgs[] = $langs->trans("ErrorReservedKeyword", GETPOST('attrname', 'aZ09')); $action = 'edit'; } } @@ -416,7 +419,8 @@ if ($action == 'update') { } else { $error++; $mesg = $extrafields->error; - setEventMessages($mesg, null, 'errors'); + $mesgs = array_merge($mesgs, $extrafields->errors); + setEventMessages($mesg, $mesgs, 'errors'); } } else { $error++; @@ -425,7 +429,7 @@ if ($action == 'update') { setEventMessages($mesg, null, 'errors'); } } else { - setEventMessages($mesg, null, 'errors'); + setEventMessages($mesg, $mesgs, 'errors'); } } } @@ -443,6 +447,7 @@ if ($action == 'confirm_delete' && $confirm == "yes") { exit; } else { $mesg = $extrafields->error; + $mesgs = array_merge($mesgs, $extrafields->errors); } } else { $error++; diff --git a/htdocs/expedition/dispatch.php b/htdocs/expedition/dispatch.php index 83961579dd8..696e220e9b5 100644 --- a/htdocs/expedition/dispatch.php +++ b/htdocs/expedition/dispatch.php @@ -1,14 +1,14 @@ - * Copyright (C) 2004-2016 Laurent Destailleur - * Copyright (C) 2005 Eric Seigne - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2010-2021 Juanjo Menent - * Copyright (C) 2014 Cedric Gross - * Copyright (C) 2016 Florian Henry - * Copyright (C) 2017-2022 Ferran Marcet - * Copyright (C) 2018-2022 Frédéric France - * Copyright (C) 2019-2020 Christophe Battarel +/* Copyright (C) 2004-2006 Rodolphe Quiedeville + * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2005 Eric Seigne + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2010-2021 Juanjo Menent + * Copyright (C) 2014 Cedric Gross + * Copyright (C) 2016 Florian Henry + * Copyright (C) 2017-2022 Ferran Marcet + * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2019-2020 Christophe Battarel * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify @@ -202,7 +202,6 @@ if ($action == 'updatelines' && $usercancreate) { } } } - //var_dump($key.' '.$newqty.' '.$idline.' '.$error); if (!$error) { $qtystart = 0; @@ -345,7 +344,7 @@ if ($action == 'updatelines' && $usercancreate) { if ($error > 0) { $db->rollback(); - setEventMessages($error, $errors, 'errors'); + setEventMessages($langs->trans("Error"), $errors, 'errors'); } else { $db->commit(); setEventMessages($langs->trans("ReceptionUpdated"), null); diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index a9e7e846779..7007b5f8430 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -1,15 +1,15 @@ - * Copyright (C) 2004-2023 Laurent Destailleur - * Copyright (C) 2005 Eric Seigne - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2010-2021 Juanjo Menent - * Copyright (C) 2014 Cedric Gross - * Copyright (C) 2016 Florian Henry - * Copyright (C) 2017-2022 Ferran Marcet - * Copyright (C) 2018-2022 Frédéric France - * Copyright (C) 2019-2020 Christophe Battarel - * Copyright (C) 2024 MDW +/* Copyright (C) 2004-2006 Rodolphe Quiedeville + * Copyright (C) 2004-2023 Laurent Destailleur + * Copyright (C) 2005 Eric Seigne + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2010-2021 Juanjo Menent + * Copyright (C) 2014 Cedric Gross + * Copyright (C) 2016 Florian Henry + * Copyright (C) 2017-2022 Ferran Marcet + * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2019-2020 Christophe Battarel + * 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 @@ -507,7 +507,7 @@ if ($action == 'updateline' && $permissiontoreceive && empty($cancel)) { } if ($error > 0) { $db->rollback(); - setEventMessages($error, $errors, 'errors'); + setEventMessages($langs->trans("Error"), $errors, 'errors'); } else { $db->commit(); } diff --git a/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php b/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php index 2f7826c5ea6..bcbcda04656 100644 --- a/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php @@ -1,7 +1,8 @@ - * Copyright (C) 2014 Marcos García - * Copyright (C) 2024 MDW +/* Copyright (C) 2010-2011 Regis Houssin + * Copyright (C) 2014 Marcos García + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France * * 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 @@ -32,8 +33,10 @@ global $noMoreLinkedObjectBlockAfter; $langs = $GLOBALS['langs']; '@phan-var-force Translate $langs'; +/** @var Translate $langs */ $linkedObjectBlock = $GLOBALS['linkedObjectBlock']; '@phan-var-force CommonObject[] $linkedObjectBlock'; +/** @var CommonObject[] $linkedObjectBlock */ $langs->load("orders"); diff --git a/htdocs/reception/dispatch.php b/htdocs/reception/dispatch.php index 0f152e82cfc..e57bed8ba8d 100644 --- a/htdocs/reception/dispatch.php +++ b/htdocs/reception/dispatch.php @@ -7,7 +7,7 @@ * Copyright (C) 2014 Cedric Gross * Copyright (C) 2016 Florian Henry * Copyright (C) 2017-2022 Ferran Marcet - * Copyright (C) 2018-2022 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2019-2020 Christophe Battarel * Copyright (C) 2024 MDW * @@ -280,7 +280,7 @@ if ($action == 'updatelines' && $permissiontoreceive) { } if ($error > 0) { $db->rollback(); - setEventMessages($error, $errors, 'errors'); + setEventMessages($langs->trans("Error"), $errors, 'errors'); } else { $db->commit(); setEventMessages($langs->trans("ReceptionUpdated"), null); diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 483e829b74e..9b047a57945 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -90,7 +90,7 @@ parameters: - '#(?:ProductFournisseur::logPrice\(\)) expects float\|null#' - '#(?:(?:Asset::addDepreciationL|Facture(?:(?:(?:Fournisseur)?::add|Fournisseur::update)l))ine\(\)|calcul_price_total|(?:loanCalcMonthlyPaymen|print_paypal_redirec)t) expects float, string given.#' - '#EvalMath::trigger\(\) expects string\|null,#' - - '#(?:F(?:acture(?:(?:Fournisseur)?Rec::addline\(\))|ichinterRec::addLineRec\(\))|dolMd2Html|setEventMessages) expects string\|null,#' + - '#(?:F(?:acture(?:(?:Fournisseur)?Rec::addline\(\))|ichinterRec::addLineRec\(\))|dolMd2Html) expects string\|null,#' - '#::printStdColumnContent\(\) expects string, float(\|(int|array)(\<.*\>)?)* given.#' - '#::HTML2OpenIDServer\(\) expects string, array given.#' - '# dol_stringtotime expects string, DateTime given.#' From 0d7523d9286a7e152db76ab926b30e5ce88089d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 26 Oct 2024 13:05:05 +0200 Subject: [PATCH 09/13] fix phpstan (#31567) * fix phpstan * fix phpstan * fix phpstan * fix phpstan --- htdocs/core/modules/printing/modules_printing.php | 4 ++-- htdocs/core/modules/printing/printgcp.modules.php | 4 ++-- .../stocktransfer/doc/pdf_eagle_proforma.modules.php | 4 ++-- .../modules/supplier_order/doc/pdf_muscadet.modules.php | 6 +++--- phpstan.neon.dist | 1 - 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/htdocs/core/modules/printing/modules_printing.php b/htdocs/core/modules/printing/modules_printing.php index 4bc49d2c37c..782cc9a9b3d 100644 --- a/htdocs/core/modules/printing/modules_printing.php +++ b/htdocs/core/modules/printing/modules_printing.php @@ -1,7 +1,7 @@ - * Copyright (C) 2024 MDW + * Copyright (C) 2014-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 diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php index 13db8922c58..a1c995a3de5 100644 --- a/htdocs/core/modules/printing/printgcp.modules.php +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -1,7 +1,7 @@ - * Copyright (C) 2024 MDW + * Copyright (C) 2014-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 diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php index 6f3b40e2cea..6e2f6fbe475 100644 --- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php +++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php @@ -1019,8 +1019,8 @@ class pdf_eagle_proforma extends ModelePDFStockTransfer /** * Show total to pay * - * @param TCPDF $pdf Object PDF - * @param Facture $object Object invoice + * @param TCPDF $pdf Object PDF + * @param StockTransfer $object Object StockTransfer * @param int $deja_regle Montant deja regle * @param int $posy Position depart * @param Translate $outputlangs Object langs 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 01d05924a15..2e41df1238c 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -729,7 +729,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders * Show miscellaneous information (payment mode, payment term, ...) * * @param TCPDF $pdf Object PDF - * @param CommandeFournisseur $object Object to show + * @param CommandeFournisseur $object Object to show * @param int $posy Y * @param Translate $outputlangs Langs object * @return integer @@ -793,8 +793,8 @@ class pdf_muscadet extends ModelePDFSuppliersOrders * Show total to pay * * @param TCPDF $pdf Object PDF - * @param Facture $object Object invoice - * @param int $deja_regle Montant deja regle + * @param CommandeFournisseur $object Object CommandeFournisseur + * @param int $deja_regle Amount already paid * @param int $posy Position depart * @param Translate $outputlangs Object langs * @return int Position pour suite diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 9b047a57945..40e993709bf 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -108,7 +108,6 @@ parameters: - '#(?:ftp_(?:c(?:dup|hdir|lose)|delete|get|mkdir|put|rmdir)) expects FTP\\Connection#' - '#(?:ldap_(?:(?:ad|bin)d|delete|err(?:no|or)|first_entry|get_(?:(?:attribut|entri)es|(?:optio|values_le)n)|mod_(?:add|del|replace)|rename|set_option|unbind)) expects LDAP\\Connection#' - '#(?:MultiCurrencies::_cleanObjectDatasRate\(\)) expects MultiCurrency#' - - '# (?:pdf_(?:(?:eagle_proforma::drawTotalTable|muscadet::_tableau_tot)\(\))) expects Facture#' - '# (?:pg_(?:affected_rows|f(?:etch_(?:array|object|row)|ree_result)|num_rows)) expects PgSql\\Result#' - '# (?:Holiday::getNextNumRef\(\)|get_localtax|pdf_pagefoot|societe_prepare_head) expects Societe#' - '# (?:Common(?:DocGenerator::get(?:(?:ExtrafieldsInHtml|_substitutionarray_lines)\(\))|Object::printO(?:(?:bject|rigin)Line\(\)))) expects CommonObjectLine#' From 57fa01759105fbe8bb4e5ff7f405c39092bbd428 Mon Sep 17 00:00:00 2001 From: sonikf <93765174+sonikf@users.noreply.github.com> Date: Sat, 26 Oct 2024 14:07:33 +0300 Subject: [PATCH 10/13] NEW Add payment reference - SQL Part (#31553) * NEW Add payment reference - SQL Part * NEW Add payment reference - SQL Part * NEW Add payment reference - SQL Part * Update llx_facture.sql * Update llx_societe.sql --- htdocs/install/mysql/migration/20.0.0-21.0.0.sql | 2 ++ htdocs/install/mysql/tables/llx_facture.sql | 2 +- htdocs/install/mysql/tables/llx_societe.sql | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/20.0.0-21.0.0.sql b/htdocs/install/mysql/migration/20.0.0-21.0.0.sql index e158fed274f..ad47c2bac29 100644 --- a/htdocs/install/mysql/migration/20.0.0-21.0.0.sql +++ b/htdocs/install/mysql/migration/20.0.0-21.0.0.sql @@ -282,3 +282,5 @@ CREATE TABLE llx_product_customer_price_extrafields ( ) ENGINE=innodb; ALTER TABLE llx_product_customer_price_extrafields ADD UNIQUE INDEX uk_product_customer_price_extrafields (fk_object); +ALTER TABLE llx_facture ADD COLUMN payment_reference varchar(25) AFTER date_lim_reglement; +ALTER TABLE llx_societe ADD COLUMN tp_payment_reference varchar(25) AFTER code_fournisseur; diff --git a/htdocs/install/mysql/tables/llx_facture.sql b/htdocs/install/mysql/tables/llx_facture.sql index b5a1f95db90..9e2f2ad1890 100644 --- a/htdocs/install/mysql/tables/llx_facture.sql +++ b/htdocs/install/mysql/tables/llx_facture.sql @@ -79,7 +79,7 @@ create table llx_facture fk_cond_reglement integer DEFAULT 1 NOT NULL, -- payment term (30 days, end of month...) fk_mode_reglement integer, -- payment mode (Virement, Prelevement) date_lim_reglement date, -- due date - + payment_reference varchar(25), -- SEPA and any other national or custom payment id note_private text, note_public text, model_pdf varchar(255), diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index a4ce431ada2..4f6fc0800a9 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -38,7 +38,7 @@ create table llx_societe code_client varchar(24), -- code client code_fournisseur varchar(24), -- code fournisseur - + tp_payment_reference varchar(25), -- SEPA and any other national or custom payment id accountancy_code_customer_general varchar(32) DEFAULT NULL, -- customer accountancy general account code_compta varchar(32), -- customer accountancy auxiliary account accountancy_code_supplier_general varchar(32) DEFAULT NULL, -- supplier accountancy general account From e8080657ec3a9e7e5724c454da598293c2287184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josep=20Llu=C3=ADs?= Date: Sat, 26 Oct 2024 13:11:21 +0200 Subject: [PATCH 11/13] NEW Add thirdparty state in substitution array (#31549) * Add thirdparty state in substitution array Add thirdparty state in substitution array * Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index fbc7515b421..c09b57e19f7 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -23,6 +23,7 @@ * Copyright (C) 2023 Joachim Kueter * Copyright (C) 2024 MDW * Copyright (C) 2024 Lenin Rivas + * Copyright (C) 2024 Josep Lluís Amador Teruel * * 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 @@ -8905,6 +8906,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, '__MYCOMPANY_ADDRESS__' => $mysoc->address, '__MYCOMPANY_ZIP__' => $mysoc->zip, '__MYCOMPANY_TOWN__' => $mysoc->town, + '__MYCOMPANY_STATE__' => $mysoc->state, '__MYCOMPANY_COUNTRY__' => $mysoc->country, '__MYCOMPANY_COUNTRY_ID__' => $mysoc->country_id, '__MYCOMPANY_COUNTRY_CODE__' => $mysoc->country_code, @@ -8937,6 +8939,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__THIRDPARTY_ADDRESS__'] = '__THIRDPARTY_ADDRESS__'; $substitutionarray['__THIRDPARTY_ZIP__'] = '__THIRDPARTY_ZIP__'; $substitutionarray['__THIRDPARTY_TOWN__'] = '__THIRDPARTY_TOWN__'; + $substitutionarray['__THIRDPARTY_STATE__'] = '__THIRDPARTY_STATE__'; $substitutionarray['__THIRDPARTY_IDPROF1__'] = '__THIRDPARTY_IDPROF1__'; $substitutionarray['__THIRDPARTY_IDPROF2__'] = '__THIRDPARTY_IDPROF2__'; $substitutionarray['__THIRDPARTY_IDPROF3__'] = '__THIRDPARTY_IDPROF3__'; @@ -9068,6 +9071,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__MEMBER_ADDRESS__'] = (isset($object->address) ? $object->address : ''); $substitutionarray['__MEMBER_ZIP__'] = (isset($object->zip) ? $object->zip : ''); $substitutionarray['__MEMBER_TOWN__'] = (isset($object->town) ? $object->town : ''); + $substitutionarray['__MEMBER_STATE__'] = (isset($object->state) ? $object->state : ''); $substitutionarray['__MEMBER_COUNTRY__'] = (isset($object->country) ? $object->country : ''); $substitutionarray['__MEMBER_EMAIL__'] = (isset($object->email) ? $object->email : ''); $substitutionarray['__MEMBER_BIRTH__'] = (isset($birthday) ? $birthday : ''); @@ -9107,6 +9111,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__THIRDPARTY_ADDRESS__'] = (is_object($object) ? $object->address : ''); $substitutionarray['__THIRDPARTY_ZIP__'] = (is_object($object) ? $object->zip : ''); $substitutionarray['__THIRDPARTY_TOWN__'] = (is_object($object) ? $object->town : ''); + $substitutionarray['__THIRDPARTY_STATE__'] = (is_object($object) ? $object->state : ''); $substitutionarray['__THIRDPARTY_COUNTRY_ID__'] = (is_object($object) ? $object->country_id : ''); $substitutionarray['__THIRDPARTY_COUNTRY_CODE__'] = (is_object($object) ? $object->country_code : ''); $substitutionarray['__THIRDPARTY_IDPROF1__'] = (is_object($object) ? $object->idprof1 : ''); @@ -9131,6 +9136,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__THIRDPARTY_ADDRESS__'] = (is_object($object->thirdparty) ? $object->thirdparty->address : ''); $substitutionarray['__THIRDPARTY_ZIP__'] = (is_object($object->thirdparty) ? $object->thirdparty->zip : ''); $substitutionarray['__THIRDPARTY_TOWN__'] = (is_object($object->thirdparty) ? $object->thirdparty->town : ''); + $substitutionarray['__THIRDPARTY_STATE__'] = (is_object($object->thirdparty) ? $object->thirdparty->state : ''); $substitutionarray['__THIRDPARTY_COUNTRY_ID__'] = (is_object($object->thirdparty) ? $object->thirdparty->country_id : ''); $substitutionarray['__THIRDPARTY_COUNTRY_CODE__'] = (is_object($object->thirdparty) ? $object->thirdparty->country_code : ''); $substitutionarray['__THIRDPARTY_IDPROF1__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof1 : ''); From 1ec7b1d5712733fe2d980dede9320c163bdd44fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 26 Oct 2024 13:22:48 +0200 Subject: [PATCH 12/13] fix phpstan (#31566) * fix phpstan * fix phpstan --------- Co-authored-by: Laurent Destailleur --- .../fourn/class/fournisseur.product.class.php | 24 +++++++++---------- phpstan.neon.dist | 1 - 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 27ce3013e19..a7feae2dc24 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -1,14 +1,14 @@ - * Copyright (C) 2006-2011 Laurent Destailleur - * Copyright (C) 2009-2014 Regis Houssin - * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2015 Marcos García - * Copyright (C) 2016-2023 Charlene Benke - * Copyright (C) 2019-2024 Frédéric France - * Copyright (C) 2020 Pierre Ardoin - * Copyright (C) 2024 MDW +/* Copyright (C) 2005 Rodolphe Quiedeville + * Copyright (C) 2006-2011 Laurent Destailleur + * Copyright (C) 2009-2014 Regis Houssin + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2015 Marcos García + * 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 @@ -456,8 +456,8 @@ class ProductFournisseur extends Product $ttx = $tva_tx; $multicurrency_buyprice /= (1 + ($ttx / 100)); } - $multicurrency_buyprice = price2num($multicurrency_buyprice, 'MU'); - $multicurrency_unitBuyPrice = price2num((float) $multicurrency_buyprice / $qty, 'MU'); + $multicurrency_buyprice = (float) price2num($multicurrency_buyprice, 'MU'); + $multicurrency_unitBuyPrice = (float) price2num((float) $multicurrency_buyprice / $qty, 'MU'); $buyprice = (float) $multicurrency_buyprice / $multicurrency_tx; $fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $multicurrency_code); diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 40e993709bf..b186ce6cfdd 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -87,7 +87,6 @@ parameters: - '#(?:Comm(?:(?:ande::updateline|on(?:Invoice::getLibStatut|StickerGenerator::Set_Char_Size))\(\))|Facture(?:(?:::update|FournisseurRec::add)line\(\))|(?:Holiday::addLogCP|Loan::getLibStatut|SupplierProposal::updateline)\(\)|calcul_price_total) expects int, float given\.#' - '#(?:dol_(?:mktime|remove_file_process)|print_actions_filter) expects int, array\|string given\.#' - '# (CSMSFile) constructor expects int, array\|string given.#' - - '#(?:ProductFournisseur::logPrice\(\)) expects float\|null#' - '#(?:(?:Asset::addDepreciationL|Facture(?:(?:(?:Fournisseur)?::add|Fournisseur::update)l))ine\(\)|calcul_price_total|(?:loanCalcMonthlyPaymen|print_paypal_redirec)t) expects float, string given.#' - '#EvalMath::trigger\(\) expects string\|null,#' - '#(?:F(?:acture(?:(?:Fournisseur)?Rec::addline\(\))|ichinterRec::addLineRec\(\))|dolMd2Html) expects string\|null,#' From c50566a0e4b4ca21c26278f8f5f6533d9456bbf7 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+BB2A-Anthony@users.noreply.github.com> Date: Sat, 26 Oct 2024 13:52:40 +0200 Subject: [PATCH 13/13] NEW - Color line total and sub total (#26172) Co-authored-by: Anthony Berton --- htdocs/theme/eldy/global.inc.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 9da7dab5d9a..24bb5e511cd 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -4810,6 +4810,7 @@ input.liste_titre { line-height: 24px; } .noborder tr.liste_total td, tr.liste_total td, form.liste_total div, .noborder tr.liste_total_wrap td, tr.liste_total_wrap td, form.liste_total_wrap div { + background: var(--colorbacktitle1); color: var(--listetotal); font-weight: normal; } @@ -4886,9 +4887,9 @@ div.tabBar .noborder { /* Prepare to remove class pair - impair */ -.noborder:not(.editmode) > tbody > tr:nth-child(even):not(.liste_titre):not(.nooddeven), .liste > tbody > tr:nth-child(even):not(.liste_titre):not(.nooddeven), -div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright) > .border > tbody > tr:nth-of-type(even):not(.liste_titre):not(.nooddeven), .liste > tbody > tr:nth-of-type(even):not(.liste_titre):not(.nooddeven), -div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright) .oddeven.tagtr:nth-of-type(even):not(.liste_titre):not(.nooddeven) +.noborder:not(.editmode) > tbody > tr:nth-child(even):not(.liste_titre):not(.nooddeven):not(.liste_total), .liste > tbody > tr:nth-child(even):not(.liste_titre):not(.nooddeven):not(.liste_total), +div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright) > .border > tbody > tr:nth-of-type(even):not(.liste_titre):not(.nooddeven):not(.liste_total), .liste > tbody > tr:nth-of-type(even):not(.liste_titre):not(.nooddeven):not(.liste_total), +div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright) .oddeven.tagtr:nth-of-type(even):not(.liste_titre):not(.nooddeven):not(.liste_total) { background: linear-gradient(bottom, var(----colorbacklineimpair2) 0%, var(--colorbacklineimpair2) 100%); background: -o-linear-gradient(bottom, var(--colorbacklineimpair2) 0%, var(--colorbacklineimpair2) 100%); @@ -4901,9 +4902,9 @@ div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright) .oddeven.tagtr:nt border-bottom: 1px solid #f0f0f0; } -.noborder:not(.editmode) > tbody > tr:nth-child(odd):not(.liste_titre):not(.nooddeven), .liste > tbody > tr:nth-child(odd):not(.liste_titre):not(.nooddeven), -div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright) > .border > tbody > tr:nth-of-type(odd):not(.liste_titre):not(.nooddeven), .liste > tbody > tr:nth-of-type(odd):not(.liste_titre):not(.nooddeven), -div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright) .oddeven.tagtr:nth-of-type(odd):not(.liste_titre):not(.nooddeven) +.noborder:not(.editmode) > tbody > tr:nth-child(odd):not(.liste_titre):not(.nooddeven):not(.liste_total), .liste > tbody > tr:nth-child(odd):not(.liste_titre):not(.nooddeven):not(.liste_total), +div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright) > .border > tbody > tr:nth-of-type(odd):not(.liste_titre):not(.nooddeven):not(.liste_total), .liste > tbody > tr:nth-of-type(odd):not(.liste_titre):not(.nooddeven):not(.liste_total), +div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright) .oddeven.tagtr:nth-of-type(odd):not(.liste_titre):not(.nooddeven):not(.liste_total) { background: linear-gradient(bottom, var(--colorbacklinepair2) 0%, var(--colorbacklinepair2) 100%); background: -o-linear-gradient(bottom, var(--colorbacklinepair2) 0%, var(--colorbacklinepair2) 100%);