From 76eaf8bd8d44ae2bf5a7cc4c587d716e71592709 Mon Sep 17 00:00:00 2001 From: MDW Date: Thu, 12 Sep 2024 21:16:42 +0200 Subject: [PATCH 1/2] Qual: Fix phan notices in classes related to class using getNextValue. (#30925) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * FIX 🛟 phan * getToolTip() can take null for $coc * Fix uninitialized vars & arg types * PHPDoc typing, argument fixes * PHPDoc typing, argument fixes for AdherentType * PHPDoc typing, argument fixes for AdherentStats * Update baseline to enable adherent notices * Fix PHPDoc typing in api_members * Minor bug fixes, typing * PHPDoc api_subscriptions * PHPDoc Societe * Ignore empty foreach notice * Add initialiser * Categorie is string, old int mode is deprecated * Fix missing initialisations * Fix missing initialisations adherents/note * Fix typing (cast), initialisation of var * Fix initialisations * Fix argument types * Improve array PHPDoc type * PHPDoc array type * PHPDoc: Improve typing * Correct argument type to getNomUrl * Improve typing for timespent * Fix typing for getNextValue args * Improve typing * Fix typing hints contrat/card * Update baseline * Fix typing * Fix extraparams property typing * Fix argument typing * Qual: Correct covariant type * Impove typing for timespent * Remove exclusion no longer matched (level 6) --------- Co-authored-by: Frédéric FRANCE --- dev/tools/phan/baseline.txt | 69 +++++--------- htdocs/adherents/card.php | 39 +++++--- htdocs/adherents/class/adherent.class.php | 91 +++++++++--------- .../adherents/class/adherent_type.class.php | 20 ++-- .../adherents/class/adherentstats.class.php | 14 +-- htdocs/adherents/class/api_members.class.php | 29 ++++-- .../class/api_subscriptions.class.php | 17 +++- htdocs/adherents/class/subscription.class.php | 8 +- htdocs/adherents/list.php | 9 +- htdocs/adherents/note.php | 5 +- htdocs/adherents/stats/geo.php | 12 ++- htdocs/adherents/stats/index.php | 3 +- htdocs/adherents/subscription.php | 5 +- htdocs/adherents/subscription/list.php | 2 + htdocs/adherents/type.php | 10 +- htdocs/bookcal/class/availabilities.class.php | 2 +- htdocs/bookcal/class/calendar.class.php | 7 +- htdocs/comm/mailing/class/mailing.class.php | 21 +++-- htdocs/commande/class/commande.class.php | 3 + .../deplacement/class/deplacement.class.php | 3 + htdocs/contrat/card.php | 10 +- htdocs/contrat/class/contrat.class.php | 94 +++++++++++++------ htdocs/contrat/index.php | 2 +- htdocs/core/class/commonobject.class.php | 2 +- htdocs/core/class/html.formother.class.php | 2 +- htdocs/core/class/stats.class.php | 2 +- htdocs/core/class/timespent.class.php | 63 ++++++++++++- .../modules/import/import_csv.modules.php | 42 ++++++--- .../modules/import/import_xlsx.modules.php | 54 ++++++++--- htdocs/core/modules/import/modules_import.php | 2 +- .../modules/member/mod_member_advanced.php | 2 +- .../core/modules/member/mod_member_simple.php | 2 +- .../modules/member/modules_member.class.php | 4 +- htdocs/delivery/class/delivery.class.php | 51 +++++++--- htdocs/fichinter/class/fichinter.class.php | 4 +- .../class/fournisseur.commande.class.php | 3 + .../fourn/class/fournisseur.facture.class.php | 3 + htdocs/modulebuilder/index.php | 2 +- htdocs/societe/class/societe.class.php | 3 + .../class/supplier_proposal.class.php | 3 + phpstan.neon.dist | 16 +--- 41 files changed, 473 insertions(+), 262 deletions(-) diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 295fc4eda2e..1d05ced1d52 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -9,26 +9,26 @@ */ return [ // # Issue statistics: - // PhanPluginUnknownPropertyType : 1620+ occurrences - // PhanPossiblyUndeclaredGlobalVariable : 1160+ occurrences - // PhanTypeMismatchArgumentProbablyReal : 1050+ occurrences - // PhanUndeclaredProperty : 780+ occurrences - // PhanUndeclaredGlobalVariable : 700+ occurrences - // PhanPluginUnknownObjectMethodCall : 550+ occurrences - // PhanPluginUnknownArrayMethodReturnType : 510+ occurrences - // PhanPluginUnknownArrayMethodParamType : 470+ occurrences + // PhanPluginUnknownPropertyType : 1560+ occurrences + // PhanPossiblyUndeclaredGlobalVariable : 1090+ occurrences + // PhanTypeMismatchArgumentProbablyReal : 1000+ occurrences + // PhanUndeclaredProperty : 770+ occurrences + // PhanUndeclaredGlobalVariable : 690+ occurrences + // PhanPluginUnknownObjectMethodCall : 540+ occurrences + // PhanPluginUnknownArrayMethodReturnType : 480+ occurrences + // PhanPluginUnknownArrayMethodParamType : 430+ occurrences // PhanPossiblyUndeclaredVariable : 350+ occurrences // PhanPluginUnknownArrayFunctionReturnType : 230+ occurrences // PhanTypeMismatchProperty : 210+ occurrences // PhanPluginUnknownArrayFunctionParamType : 170+ occurrences // PhanTypeExpectedObjectPropAccess : 150+ occurrences // PhanTypeMismatchArgumentNullableInternal : 120+ occurrences - // PhanPluginUnknownArrayPropertyType : 85+ occurrences + // PhanPluginUnknownArrayPropertyType : 80+ occurrences // PhanPluginUndeclaredVariableIsset : 70+ occurrences // PhanPluginEmptyStatementIf : 65+ occurrences // PhanRedefineFunction : 55+ occurrences + // PhanTypeSuspiciousNonTraversableForeach : 50+ occurrences // PhanTypeMismatchDimFetch : 45+ occurrences - // PhanTypeSuspiciousNonTraversableForeach : 45+ occurrences // PhanPossiblyNullTypeMismatchProperty : 20+ occurrences // PhanEmptyForeach : 15+ occurrences // PhanTypeComparisonFromArray : 15+ occurrences @@ -50,22 +50,7 @@ return [ 'file_suppressions' => [ 'htdocs/accountancy/class/accountancycategory.class.php' => ['PhanPluginUnknownArrayPropertyType'], 'htdocs/accountancy/class/accountancyexport.class.php' => ['PhanUndeclaredProperty'], - 'htdocs/adherents/admin/member.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/adherents/canvas/actions_adherentcard_common.class.php' => [/* Traverses Adherent as array, ignore */ 'PhanTypeSuspiciousNonTraversableForeach'], - 'htdocs/adherents/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/adherents/class/adherent.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownArrayPropertyType', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/adherents/class/adherent_type.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownArrayPropertyType', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/adherents/class/adherentstats.class.php' => ['PhanPluginUnknownArrayMethodReturnType'], - 'htdocs/adherents/class/api_members.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'], - 'htdocs/adherents/class/api_subscriptions.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'], - 'htdocs/adherents/class/subscription.class.php' => ['PhanPossiblyUndeclaredVariable'], - 'htdocs/adherents/list.php' => ['PhanPossiblyNullTypeMismatchProperty', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'], - 'htdocs/adherents/note.php' => ['PhanPossiblyUndeclaredGlobalVariable'], - 'htdocs/adherents/stats/geo.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal'], - 'htdocs/adherents/stats/index.php' => ['PhanPossiblyUndeclaredGlobalVariable'], - 'htdocs/adherents/subscription.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/adherents/subscription/list.php' => ['PhanEmptyForeach'], - 'htdocs/adherents/type.php' => ['PhanPluginDuplicateExpressionBinaryOp', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'], 'htdocs/admin/agenda_extsites.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/admin/agenda_other.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanUndeclaredGlobalVariable'], 'htdocs/admin/agenda_reminder.php' => ['PhanUndeclaredGlobalVariable'], @@ -178,8 +163,8 @@ return [ 'htdocs/bookcal/calendar_card.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/bookcal/calendar_document.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/bookcal/calendar_list.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/bookcal/class/availabilities.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanUndeclaredMethod', /* Missing getNextValue class, ignored */ 'PhanUndeclaredProperty'], - 'htdocs/bookcal/class/calendar.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanUndeclaredMethod', /* Missing getNextValue class, ignored */ 'PhanUndeclaredProperty'], + 'htdocs/bookcal/class/availabilities.class.php' => ['PhanUndeclaredMethod', /* Missing getNextValue class, ignored */ 'PhanUndeclaredProperty'], + 'htdocs/bookcal/class/calendar.class.php' => ['PhanUndeclaredMethod', /* Missing getNextValue class, ignored */ 'PhanUndeclaredProperty'], 'htdocs/bookcal/lib/bookcal.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'], 'htdocs/bookcal/lib/bookcal_availabilities.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'], 'htdocs/bookcal/lib/bookcal_calendar.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'], @@ -336,11 +321,8 @@ return [ 'htdocs/contrat/agenda.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/contrat/card.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredGlobalVariable'], 'htdocs/contrat/class/api_contracts.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'], - 'htdocs/contrat/class/contrat.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/contrat/index.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/contrat/messaging.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/contrat/services_list.php' => ['PhanEmptyForeach', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/contrat/ticket.php' => ['PhanPluginUnknownObjectMethodCall'], 'htdocs/contrat/tpl/linkedobjectblock.tpl.php' => ['PhanPluginUnknownObjectMethodCall'], 'htdocs/core/actions_addupdatedelete.inc.php' => ['PhanPluginBothLiteralsBinaryOp', 'PhanTypeMismatchDimFetch', 'PhanUndeclaredProperty'], 'htdocs/core/actions_builddoc.inc.php' => ['PhanUndeclaredProperty'], @@ -349,7 +331,7 @@ return [ 'htdocs/core/actions_extrafields.inc.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/core/actions_lineupdown.inc.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable'], 'htdocs/core/actions_linkedfiles.inc.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'], - 'htdocs/core/actions_massactions.inc.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], + 'htdocs/core/actions_massactions.inc.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/core/actions_printing.inc.php' => ['PhanUndeclaredProperty'], 'htdocs/core/actions_sendmails.inc.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/core/actions_setmoduleoptions.inc.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable'], @@ -418,7 +400,7 @@ return [ 'htdocs/core/class/emailsenderprofile.class.php' => ['PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'], 'htdocs/core/class/evalmath.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/core/class/events.class.php' => ['PhanPluginUnknownPropertyType'], - 'htdocs/core/class/extrafields.class.php' => ['PhanPluginConstantVariableNull', 'PhanPluginUnknownArrayMethodParamType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty'], + 'htdocs/core/class/extrafields.class.php' => ['PhanPluginConstantVariableNull', 'PhanPluginUnknownArrayMethodParamType', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty'], 'htdocs/core/class/extralanguages.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownArrayPropertyType'], 'htdocs/core/class/fediverseparser.class.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/core/class/fileupload.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchDimFetch'], @@ -450,8 +432,8 @@ return [ 'htdocs/core/class/rssparser.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanTypeExpectedObjectPropAccess'], 'htdocs/core/class/smtps.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchDimFetch'], 'htdocs/core/class/socialnetworkmanager.class.php' => ['PhanPluginUnknownArrayMethodParamType'], - 'htdocs/core/class/stats.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchDimFetch'], - 'htdocs/core/class/timespent.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty'], + 'htdocs/core/class/stats.class.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchDimFetch'], + 'htdocs/core/class/timespent.class.php' => ['PhanUndeclaredMethod', 'PhanUndeclaredProperty'], 'htdocs/core/class/translate.class.php' => ['PhanPluginEmptyStatementIf', 'PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownArrayPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal'], 'htdocs/core/class/utils.class.php' => ['PhanPluginConstantVariableNull', 'PhanPossiblyUndeclaredVariable'], 'htdocs/core/class/validate.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall'], @@ -572,8 +554,8 @@ return [ 'htdocs/core/modules/fichinter/mod_pacific.php' => ['PhanPossiblyUndeclaredVariable'], 'htdocs/core/modules/hrm/doc/pdf_standard_evaluation.modules.php' => ['PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'], 'htdocs/core/modules/hrm/mod_evaluation_advanced.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], - 'htdocs/core/modules/import/import_csv.modules.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty'], - 'htdocs/core/modules/import/import_xlsx.modules.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty'], + 'htdocs/core/modules/import/import_csv.modules.php' => ['PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty'], + 'htdocs/core/modules/import/import_xlsx.modules.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty'], 'htdocs/core/modules/import/modules_import.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanTypeMismatchDimFetch'], 'htdocs/core/modules/mailings/advthirdparties.modules.php' => ['PhanPluginUnknownArrayMethodParamType'], 'htdocs/core/modules/mailings/contacts1.modules.php' => ['PhanTypeMismatchArgumentProbablyReal'], @@ -687,7 +669,7 @@ return [ 'htdocs/debugbar/class/DataCollector/DolibarrCollector.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/debugbar/class/TraceableDB.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownArrayPropertyType'], 'htdocs/delivery/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'], - 'htdocs/delivery/class/delivery.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], + 'htdocs/delivery/class/delivery.class.php' => ['PhanUndeclaredProperty'], 'htdocs/delivery/tpl/linkedobjectblock.tpl.php' => ['PhanPluginUnknownObjectMethodCall'], 'htdocs/document.php' => ['PhanRedefineFunction', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/don/admin/donation.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanTypeMismatchArgumentProbablyReal'], @@ -724,7 +706,7 @@ return [ 'htdocs/eventorganization/conferenceorbooth_list.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/eventorganization/conferenceorboothattendee_card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'], 'htdocs/eventorganization/conferenceorboothattendee_list.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/eventorganization/core/actions_massactions_mail.inc.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], + 'htdocs/eventorganization/core/actions_massactions_mail.inc.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredProperty'], 'htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'], 'htdocs/eventorganization/tpl/linkedobjectblock.tpl.php' => ['PhanPluginUnknownObjectMethodCall'], 'htdocs/expedition/card.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'], @@ -756,7 +738,7 @@ return [ 'htdocs/fichinter/card-rec.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeExpectedObjectPropAccessButGotNull', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/fichinter/card.php' => ['PhanPluginBothLiteralsBinaryOp', 'PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/fichinter/class/api_interventions.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanUndeclaredProperty'], - 'htdocs/fichinter/class/fichinter.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownArrayPropertyType', 'PhanPluginUnknownObjectMethodCall'], + 'htdocs/fichinter/class/fichinter.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownObjectMethodCall'], 'htdocs/fichinter/class/fichinterrec.class.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], 'htdocs/fichinter/class/fichinterstats.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType'], 'htdocs/fichinter/list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], @@ -836,7 +818,6 @@ return [ 'htdocs/install/step5.php' => ['PhanPluginUndeclaredVariableIsset'], 'htdocs/install/upgrade.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/install/upgrade2.php' => ['PhanPluginEmptyStatementIf', 'PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/intracommreport/admin/intracommreport.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/intracommreport/card.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/intracommreport/class/intracommreport.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable'], 'htdocs/intracommreport/lib/intracommreport.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'], @@ -921,9 +902,8 @@ return [ 'htdocs/product/inventory/list.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/product/list.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/product/price.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], - 'htdocs/product/reassort.php' => ['PhanTypeExpectedObjectPropAccessButGotNull', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/product/reassortlot.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/product/stats/card.php' => ['PhanTypeComparisonFromArray', 'PhanTypeMismatchArgumentProbablyReal'], + 'htdocs/product/reassort.php' => ['PhanTypeExpectedObjectPropAccessButGotNull'], + 'htdocs/product/stats/card.php' => ['PhanTypeComparisonFromArray'], 'htdocs/product/stats/commande.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/product/stats/commande_fournisseur.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/product/stats/facture.php' => ['PhanTypeMismatchArgumentProbablyReal'], @@ -985,7 +965,7 @@ return [ 'htdocs/projet/tasks/comment.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/projet/tasks/contact.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/projet/tasks/document.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/projet/tasks/list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], + 'htdocs/projet/tasks/list.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/projet/tasks/note.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/projet/tasks/task.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/projet/tasks/time.php' => ['PhanEmptyForeach', 'PhanPluginUndeclaredVariableIsset', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], @@ -1154,7 +1134,6 @@ return [ 'htdocs/user/class/usergroup.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'], 'htdocs/user/group/card.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/user/group/perms.php' => ['PhanPluginUnknownObjectMethodCall'], - 'htdocs/user/list.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/user/param_ihm.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/user/passwordforgotten.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/user/perms.php' => ['PhanPluginUnknownObjectMethodCall'], diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index a201003d083..fe705fa99b8 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -72,6 +72,8 @@ if (isModEnabled('mailmanspip')) { $langs->load('mailmanspip'); $mailmanspip = new MailmanSpip($db); +} else { + $mailmanspip = null; } $object = new Adherent($db); @@ -114,6 +116,7 @@ if ($id > 0 || !empty($ref)) { // Define variables to determine what the current user can do on the members $canaddmember = $user->hasRight('adherent', 'creer'); +$caneditfieldmember = false; // Define variables to determine what the current user can do on the properties of a member if ($id) { $caneditfieldmember = $user->hasRight('adherent', 'creer'); @@ -533,6 +536,7 @@ if (empty($reshook)) { } else { $sql = "SELECT login FROM ".MAIN_DB_PREFIX."adherent WHERE login='".$db->escape($login)."'"; $result = $db->query($sql); + $num = 0; if ($result) { $num = $db->num_rows($result); } @@ -848,18 +852,20 @@ if (empty($reshook)) { } // SPIP Management - if ($user->hasRight('adherent', 'supprimer') && $action == 'confirm_del_spip' && $confirm == 'yes') { - if (!count($object->errors)) { - if (!$mailmanspip->del_to_spip($object)) { - setEventMessages($langs->trans('DeleteIntoSpipError').': '.$mailmanspip->error, null, 'errors'); + if (is_object($mailmanspip)) { + if ($user->hasRight('adherent', 'supprimer') && $action == 'confirm_del_spip' && $confirm == 'yes') { + if (!count($object->errors)) { + if (!$mailmanspip->del_to_spip($object)) { + setEventMessages($langs->trans('DeleteIntoSpipError').': '.$mailmanspip->error, null, 'errors'); + } } } - } - if ($user->hasRight('adherent', 'creer') && $action == 'confirm_add_spip' && $confirm == 'yes') { - if (!count($object->errors)) { - if (!$mailmanspip->add_to_spip($object)) { - setEventMessages($langs->trans('AddIntoSpipError').': '.$mailmanspip->error, null, 'errors'); + if ($user->hasRight('adherent', 'creer') && $action == 'confirm_add_spip' && $confirm == 'yes') { + if (!count($object->errors)) { + if (!$mailmanspip->add_to_spip($object)) { + setEventMessages($langs->trans('AddIntoSpipError').': '.$mailmanspip->error, null, 'errors'); + } } } } @@ -980,7 +986,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; } - print dol_get_fiche_head(''); + print dol_get_fiche_head(array()); print ''; print ''; @@ -1201,10 +1207,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $obj = $db->fetch_object($resql); } else { dol_print_error($db); + $obj = null; + } + if (is_object($obj)) { + $object->country_id = $obj->rowid; + $object->country_code = $obj->code; + $object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label; } - $object->country_id = $obj->rowid; - $object->country_code = $obj->code; - $object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label; } $head = member_prepare_head($object); @@ -1397,7 +1406,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Default language if (getDolGlobalInt('MAIN_MULTILANGS')) { print ''; print ''; } @@ -1920,7 +1929,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print $form->editfieldkey('LinkedToDolibarrUser', 'login', '', $object, $editenable); print ''; foreach ($data as $val) { - $year = isset($val['year']) ? $val['year'] : ''; print ''; print ''; if (isset($label2)) { diff --git a/htdocs/adherents/stats/index.php b/htdocs/adherents/stats/index.php index 6a06fa470e3..b886379854f 100644 --- a/htdocs/adherents/stats/index.php +++ b/htdocs/adherents/stats/index.php @@ -128,6 +128,7 @@ $mesg = $px2->isGraphKo(); if (!$mesg) { $px2->SetData($data); $i = $startyear; + $legend = array(); while ($i <= $endyear) { $legend[] = $i; $i++; @@ -189,7 +190,7 @@ print ''; $oldyear = 0; foreach ($data as $val) { - $year = $val['year']; + $year = (int) $val['year']; while ($oldyear > $year + 1) { // If we have empty year $oldyear--; print ''; diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index c7eda4dbaf3..a1ccc1a2616 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -7,6 +7,7 @@ * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2019 Thibault FOUCART * Copyright (C) 2023 Waël Almoman + * 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 @@ -661,7 +662,7 @@ if ($action != 'editlogin' && $user->hasRight('adherent', 'creer')) { print '
'.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).''."\n"; - print img_picto('', 'language', 'class="pictofixedwidth"').$formadmin->select_language($object->default_lang, 'default_lang', 0, 0, 1); + print img_picto('', 'language', 'class="pictofixedwidth"').$formadmin->select_language($object->default_lang, 'default_lang', 0, array(), 1); print '
'; if ($action == 'editlogin') { - $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id, $object->user_id, 'userid', ''); + $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id, $object->user_id, 'userid', array()); } else { if ($object->user_id) { $linkeduser = new User($db); diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 9acc5a1fe78..b5413c0384e 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -294,7 +294,7 @@ class Adherent extends CommonObject public $last_subscription_amount; /** - * @var array + * @var Subscription[] */ public $subscriptions = array(); @@ -305,6 +305,9 @@ class Adherent extends CommonObject // Fields loaded by fetchPartnerships() from partnership table + /** + * @var array> + */ public $partnerships = array(); /** @@ -403,20 +406,20 @@ class Adherent extends CommonObject /** * Function sending an email to the current member with the text supplied in parameter. * - * @param string $text Content of message (not html entities encoded) - * @param string $subject Subject of message - * @param array $filename_list Array of attached files - * @param array $mimetype_list Array of mime types of attached files - * @param array $mimefilename_list Array of public names of attached files - * @param string $addr_cc Email cc - * @param string $addr_bcc Email bcc - * @param int $deliveryreceipt Ask a delivery receipt - * @param int $msgishtml 1=String IS already html, 0=String IS NOT html, -1=Unknown need autodetection - * @param string $errors_to errors to - * @param string $moreinheader Add more html headers + * @param string $text Content of message (not html entities encoded) + * @param string $subject Subject of message + * @param string[] $filename_list Array of attached files + * @param string[] $mimetype_list Array of mime types of attached files + * @param string[] $mimefilename_list Array of public names of attached files + * @param string $addr_cc Email cc + * @param string $addr_bcc Email bcc + * @param int $deliveryreceipt Ask a delivery receipt + * @param int $msgishtml 1=String IS already html, 0=String IS NOT html, -1=Unknown need autodetection + * @param string $errors_to errors to + * @param string $moreinheader Add more html headers * @deprecated since V18 * @see sendEmail() - * @return int Return integer <0 if KO, >0 if OK + * @return int Return integer <0 if KO, >0 if OK */ public function send_an_email($text, $subject, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $addr_cc = "", $addr_bcc = "", $deliveryreceipt = 0, $msgishtml = -1, $errors_to = '', $moreinheader = '') { @@ -429,19 +432,19 @@ class Adherent extends CommonObject /** * Function sending an email to the current member with the text supplied in parameter. * - * @param string $text Content of message (not html entities encoded) - * @param string $subject Subject of message - * @param array $filename_list Array of attached files - * @param array $mimetype_list Array of mime types of attached files - * @param array $mimefilename_list Array of public names of attached files - * @param string $addr_cc Email cc - * @param string $addr_bcc Email bcc - * @param int $deliveryreceipt Ask a delivery receipt - * @param int $msgishtml 1=String IS already html, 0=String IS NOT html, -1=Unknown need autodetection - * @param string $errors_to errors to - * @param string $moreinheader Add more html headers + * @param string $text Content of message (not html entities encoded) + * @param string $subject Subject of message + * @param string[] $filename_list Array of attached files + * @param string[] $mimetype_list Array of mime types of attached files + * @param string[] $mimefilename_list Array of public names of attached files + * @param string $addr_cc Email cc + * @param string $addr_bcc Email bcc + * @param int $deliveryreceipt Ask a delivery receipt + * @param int $msgishtml 1=String IS already html, 0=String IS NOT html, -1=Unknown need autodetection + * @param string $errors_to errors to + * @param string $moreinheader Add more html headers * @since V18 - * @return int Return integer <0 if KO, >0 if OK + * @return int Return integer <0 if KO, >0 if OK */ public function sendEmail($text, $subject, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $addr_cc = "", $addr_bcc = "", $deliveryreceipt = 0, $msgishtml = -1, $errors_to = '', $moreinheader = '') { @@ -1741,7 +1744,7 @@ class Adherent extends CommonObject $dateop = $paymentdate; - $insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq, '', $user, $emetteur_nom, $emetteur_banque); + $insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq, 0, $user, $emetteur_nom, $emetteur_banque); if ($insertid > 0) { $inserturlid = $acct->add_url_line($insertid, $this->id, DOL_URL_ROOT.'/adherents/card.php?rowid=', $this->getFullName($langs), 'member'); if ($inserturlid > 0) { @@ -1864,7 +1867,7 @@ class Adherent extends CommonObject } //print xx".$vattouse." - ".$mysoc." - ".$customer;exit; // @phan-suppress-next-line PhanPluginSuspiciousParamPosition - $result = $invoice->addline($label, 0, 1, $vattouse, 0, 0, $idprodsubscription, 0, $datesubscription, '', 0, 0, '', 'TTC', $amount, 1); + $result = $invoice->addline($label, 0, 1, $vattouse, 0, 0, $idprodsubscription, 0, $datesubscription, '', 0, 0, 0, 'TTC', $amount, 1); if ($result <= 0) { $this->error = $invoice->error; $this->errors = $invoice->errors; @@ -2243,9 +2246,9 @@ class Adherent extends CommonObject /** * getTooltipContentArray - * @param array $params params to construct tooltip data + * @param array $params params to construct tooltip data * @since v18 - * @return array + * @return array{picto:string,ref?:string,refsupplier?:string,label?:string,date?:string,date_echeance?:string,amountht?:string,total_ht?:string,totaltva?:string,amountlt1?:string,amountlt2?:string,amountrevenustamp?:string,totalttc?:string}|array{optimize:string} */ public function getTooltipContentArray($params) { @@ -2398,7 +2401,7 @@ class Adherent extends CommonObject } elseif ($mode == 'ref') { $result .= $this->ref; } else { - $result .= $this->getFullName($langs, '', ($mode == 'firstname' ? 2 : ($mode == 'lastname' ? 4 : -1)), $maxlen); + $result .= $this->getFullName($langs, 0, ($mode == 'firstname' ? 2 : ($mode == 'lastname' ? 4 : -1)), $maxlen); } if (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) { $result .= ''; @@ -2611,13 +2614,13 @@ class Adherent extends CommonObject /** * Create a document onto disk according to template module. * - * @param string $modele Force template to use ('' to not force) - * @param Translate $outputlangs object lang a utiliser pour traduction - * @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 - * @return int 0 if KO, 1 if OK + * @param string $modele Force template to use ('' to not force) + * @param Translate $outputlangs object lang a utiliser pour traduction + * @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,1> 0 if KO, 1 if OK */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { @@ -2716,11 +2719,11 @@ class Adherent extends CommonObject /** * Retourne chaine DN complete dans l'annuaire LDAP pour l'objet * - * @param array $info Info array 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) { @@ -2745,7 +2748,7 @@ class Adherent extends CommonObject /** * Initialise tableau info (tableau des attributes LDAP) * - * @return array Tableau info des attributes + * @return array Tableau info des attributes */ public function _load_ldap_info() { @@ -3074,7 +3077,7 @@ class Adherent extends CommonObject while ($i < $num_rows) { $obj = $this->db->fetch_object($resql); - $adherent->fetch($obj->rowid, '', '', '', true, true); + $adherent->fetch($obj->rowid, '', 0, '', true, true); if (empty($adherent->email)) { $nbko++; diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 497d4e4d8dc..8c1d1f90ec0 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -136,7 +136,7 @@ class AdherentType extends CommonObject public $email; /** - * @var array multilangs + * @var array multilangs */ public $multilangs = array(); @@ -178,9 +178,9 @@ class AdherentType extends CommonObject $this->description = $obj->description; $this->email = $obj->email; } - $this->multilangs["$obj->lang"]["label"] = $obj->label; - $this->multilangs["$obj->lang"]["description"] = $obj->description; - $this->multilangs["$obj->lang"]["email"] = $obj->email; + $this->multilangs[(string) $obj->lang]["label"] = $obj->label; + $this->multilangs[(string) $obj->lang]["description"] = $obj->description; + $this->multilangs[(string) $obj->lang]["email"] = $obj->email; } return 1; } else { @@ -638,7 +638,7 @@ class AdherentType extends CommonObject if ($mode < 2) { $memberstatic = new Adherent($this->db); if ($mode == 1) { - $memberstatic->fetch($obj->rowid, '', '', '', false, false); + $memberstatic->fetch($obj->rowid, '', 0, '', false, false); } else { $memberstatic->fetch($obj->rowid); } @@ -681,9 +681,9 @@ class AdherentType extends CommonObject /** * getTooltipContentArray - * @param array $params params to construct tooltip data + * @param array $params params to construct tooltip data * @since v18 - * @return array + * @return array{picto:string,ref?:string,refsupplier?:string,label?:string,date?:string,date_echeance?:string,amountht?:string,total_ht?:string,totaltva?:string,amountlt1?:string,amountlt2?:string,amountrevenustamp?:string,totalttc?:string}|array{optimize:string} */ public function getTooltipContentArray($params) { @@ -818,7 +818,7 @@ class AdherentType extends CommonObject /** * Retourne chaine DN complete dans l'annuaire LDAP pour l'objet * - * @param array $info Info array loaded by _load_ldap_info + * @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) @@ -846,7 +846,7 @@ class AdherentType extends CommonObject /** * Initialize the info array (array of LDAP values) that will be used to call LDAP functions * - * @return array Tableau info des attributes + * @return array Info table with attributes */ public function _load_ldap_info() { @@ -871,7 +871,7 @@ class AdherentType extends CommonObject $valueofldapfield = array(); foreach ($this->members as $key => $val) { // This is array of users for group into dolibarr database. $member = new Adherent($this->db); - $member->fetch($val->id, '', '', '', false, false); + $member->fetch($val->id, '', 0, '', false, false); $info2 = $member->_load_ldap_info(); $valueofldapfield[] = $member->_load_ldap_dn($info2); } diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index c515188aa20..27173334e7d 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -99,9 +99,9 @@ class AdherentStats extends Stats /** * Return the number of proposition by month for a given year * - * @param int $year Year + * @param int $year Year * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month - * @return array Array of nb each month + * @return array,array{0:int<1,12>,1:int}> Array of nb each month */ public function getNbByMonth($year, $format = 0) { @@ -118,7 +118,7 @@ class AdherentStats extends Stats /** * Return the number of subscriptions by year * - * @return array Array of nb each year + * @return array Array of nb each year */ public function getNbByYear() { @@ -136,7 +136,7 @@ class AdherentStats extends Stats * * @param int $year Year * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month - * @return array Array of amount each month + * @return array,array{0:int<1,12>,1:int|float}> Array of values by month */ public function getAmountByMonth($year, $format = 0) { @@ -153,8 +153,8 @@ class AdherentStats extends Stats /** * Return average amount each month * - * @param int $year Year - * @return array Array of average each month + * @param int $year Year + * @return array,array{0:int<1,12>,1:int|float}> Array of average each month */ public function getAverageByMonth($year) { @@ -172,7 +172,7 @@ class AdherentStats extends Stats /** * Return nb, total and average * - * @return array Array with nb, total amount, average for each year + * @return array Array with nb, total amount, average for each year */ public function getAllByYear() { diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 7d147435108..6f09b14c933 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -37,7 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; class Members extends DolibarrApi { /** - * @var array $FIELDS Mandatory fields, checked when create and update object + * @var string[] $FIELDS Mandatory fields, checked when create and update object */ public static $FIELDS = array( 'morphy', @@ -214,6 +214,8 @@ class Members extends DolibarrApi * @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names * @param bool $pagination_data If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0* * @return array Array of member objects + * @phan-return array> + * @phpstan-return array> * * @throws RestException 400 Error on SQL filters * @throws RestException 403 Access denied @@ -304,7 +306,7 @@ class Members extends DolibarrApi /** * Create member object * - * @param array $request_data Request data + * @param array $request_data Request data * @return int ID of member * * @throws RestException 403 Access denied @@ -339,6 +341,8 @@ class Members extends DolibarrApi * * @param int $id ID of member to update * @param array $request_data Datas + * @phan-param ?array $request_data + * @phpstan-param ?array $request_data * @return Object Updated object * * @throws RestException 403 Access denied @@ -414,6 +418,8 @@ class Members extends DolibarrApi * * @param int $id member ID * @return array + * @phan-return array + * @phpstan-return array * * @throws RestException 403 Access denied * @throws RestException 404 Member not found @@ -451,8 +457,9 @@ class Members extends DolibarrApi /** * Validate fields before creating an object * - * @param array|null $data Data to validate - * @return array Return array with validated mandatory fields and their value + * @param array $data Data to validate + * @return array Return array with validated mandatory fields and their value + * @phan-return array Return array with validated mandatory fields and their value * * @throws RestException */ @@ -553,6 +560,8 @@ class Members extends DolibarrApi * * @param int $id ID of member * @return array Array of subscription objects + * @phan-return Object[] + * @phpstan-return Object[] * * @url GET {id}/subscriptions * @@ -690,6 +699,8 @@ class Members extends DolibarrApi * @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names * @param bool $pagination_data If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0* * @return array Array of member type objects + * @phan-return array> + * @phpstan-return array> * * @url GET /types/ * @@ -772,6 +783,8 @@ class Members extends DolibarrApi * Create member type object * * @param array $request_data Request data + * @phan-param ?array $request_data + * @phpstan-param ?array $request_data * @return int ID of member type * * @url POST /types/ @@ -808,6 +821,8 @@ class Members extends DolibarrApi * * @param int $id ID of member type to update * @param array $request_data Datas + * @phan-param ?array $request_data + * @phpstan-param ?array $request_data * @return Object Updated object * * @url PUT /types/{id} @@ -866,6 +881,8 @@ class Members extends DolibarrApi * * @param int $id member type ID * @return array + * @phan-return array + * @phpstan-return array * * @url DELETE /types/{id} * @@ -904,8 +921,8 @@ class Members extends DolibarrApi /** * Validate fields before creating an object * - * @param array|null $data Data to validate - * @return array + * @param ?array $data Data to validate + * @return array * * @throws RestException */ diff --git a/htdocs/adherents/class/api_subscriptions.class.php b/htdocs/adherents/class/api_subscriptions.class.php index 9bf7b04d91c..88b60506280 100644 --- a/htdocs/adherents/class/api_subscriptions.class.php +++ b/htdocs/adherents/class/api_subscriptions.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 @@ -28,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; class Subscriptions extends DolibarrApi { /** - * @var array $FIELDS Mandatory fields, checked when create and update object + * @var string[] $FIELDS Mandatory fields, checked when create and update object */ public static $FIELDS = array( 'fk_adherent', @@ -85,6 +86,8 @@ class Subscriptions extends DolibarrApi * @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names * @param bool $pagination_data If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0* * @return array Array of subscription objects + * @phan-return array{data:Subscription[],pagination:array{total:int,page:int,page_count:int,limit:int}}|array + * @phpstan-return array{data:Subscription[],pagination:array{total:int,page:int,page_count:int,limit:int}}|array * * @throws RestException 403 Access denied * @throws RestException 404 No Subscription found @@ -165,6 +168,8 @@ class Subscriptions extends DolibarrApi * Create subscription object * * @param array $request_data Request data + * @phan-param array $request_data + * @phpstan-param array $request_data * @return int ID of subscription * * @throws RestException 403 Access denied @@ -198,7 +203,9 @@ class Subscriptions extends DolibarrApi * Update subscription * * @param int $id ID of subscription to update - * @param array $request_data Datas + * @param array $request_data Data + * @phan-param array $request_data + * @phpstan-param array $request_data * @return Object Updated object * * @throws RestException 403 Access denied @@ -242,6 +249,8 @@ class Subscriptions extends DolibarrApi * * @param int $id ID of subscription to delete * @return array + * @phan-return array + * @phpstan-return array * * @throws RestException 403 Access denied * @throws RestException 404 No Subscription found @@ -278,8 +287,8 @@ class Subscriptions extends DolibarrApi /** * Validate fields before creating an object * - * @param array|null $data Data to validate - * @return array + * @param ?array $data Data to validate + * @return array * * @throws RestException */ diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 5f56609fd0d..dee174fb5db 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -344,9 +344,9 @@ class Subscription extends CommonObject /** * Delete a subscription * - * @param User $user User that delete - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int Return integer <0 if KO, 0 if not found, >0 if OK + * @param User $user User that delete + * @param int<0,1> $notrigger 0=launch triggers after, 1=disable triggers + * @return int Return integer <0 if KO, 0 if not found, >0 if OK */ public function delete($user, $notrigger = 0) { @@ -357,6 +357,8 @@ class Subscription extends CommonObject require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $accountline = new AccountLine($this->db); $result = $accountline->fetch($this->fk_bank); + } else { + $accountline = null; } $this->db->begin(); diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index c38e698ec7e..f9ccf9e4af9 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -229,6 +229,10 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massa $massaction = ''; } +$permissiontoread = 0; +$permissiontodelete = 0; +$permissiontoadd = 0; + $parameters = array('socid' => isset($socid) ? $socid : null, 'arrayfields' => &$arrayfields); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { @@ -1238,12 +1242,15 @@ while ($i < $imaxinloop) { if ($memberstatic->thirdparty->id > 0) { $companyname = $memberstatic->thirdparty->name; $companynametoshow = $memberstatic->thirdparty->getNomUrl(1); + } else { + $companyname = null; + $companynametoshow = null; } } else { $companyname = $obj->company; $companynametoshow = $obj->company; } - $memberstatic->company = $companyname; + $memberstatic->company = (string) $companyname; $object = $memberstatic; diff --git a/htdocs/adherents/note.php b/htdocs/adherents/note.php index 3a176747716..297b0ea6284 100644 --- a/htdocs/adherents/note.php +++ b/htdocs/adherents/note.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2015 Frederic France * Copyright (C) 2024 Alexandre Spangaro + * 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 @@ -49,6 +50,8 @@ $result = $object->fetch($id); if ($result > 0) { $adht = new AdherentType($db); $result = $adht->fetch($object->typeid); +} else { + $adht = null; } @@ -107,7 +110,7 @@ llxHeader("", $title, $help_url, '', 0, 0, '', '', '', 'mod-member page-card_not $form = new Form($db); -if ($id) { +if (is_object($adht)) { $head = member_prepare_head($object); print dol_get_fiche_head($head, 'note', $langs->trans("Member"), -1, 'user'); diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php index 78cd1ec763b..30e958d7b83 100644 --- a/htdocs/adherents/stats/geo.php +++ b/htdocs/adherents/stats/geo.php @@ -85,14 +85,16 @@ llxHeader('', $title, $help_url, '', 0, 0, $arrayjs, '', '', 'mod-member page-st print load_fiche_titre($title, '', $memberstatic->picto); //dol_mkdir($dir); +$data = array(); +$tab = null; if ($mode) { // Define sql + $sql = null; if ($mode == 'memberbycountry') { $label = $langs->trans("Country"); $tab = 'statscountry'; - $data = array(); $sql = "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; @@ -160,7 +162,12 @@ if ($mode) { // Define $data array dol_syslog("Count member", LOG_DEBUG); - $resql = $db->query($sql); + if ($sql != null) { + $resql = $db->query($sql); + } else { + $resql = false; + dol_syslog(__FILE__.":No SQL, invalid mode '$mode'", LOG_ERR); + } if ($resql) { $num = $db->num_rows($resql); $i = 0; @@ -314,7 +321,6 @@ if ($mode) { print '
'.$val['label'].'
'; print ''; if ($action == 'editlogin') { - $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id, $object->user_id, 'userid', ''); + $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id, $object->user_id, 'userid', array()); } else { if ($object->user_id) { $linkeduser = new User($db); @@ -947,7 +948,7 @@ if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->h print ''; print ''; - print dol_get_fiche_head(''); + print dol_get_fiche_head(array()); print '
'; print ''."\n"; diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 732f1ea8b50..3d69be5edf3 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -3,6 +3,7 @@ * Copyright (C) 2003 Jean-Louis Bergamo * Copyright (C) 2004-2023 Laurent Destailleur * Copyright (C) 2024 Alexandre Spangaro + * 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 @@ -385,6 +386,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { $setupstring = ''; + // @phan-suppress-next-line PhanEmptyForeach foreach ($fieldstosearchall as $key => $val) { $fieldstosearchall[$key] = $langs->trans($val); $setupstring .= $key."=".$val.";"; diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 1e0c3498453..ea47097002e 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -92,7 +92,7 @@ $comment = GETPOST("comment", 'restricthtml'); $mail_valid = GETPOST("mail_valid", 'restricthtml'); $caneditamount = GETPOSTINT("caneditamount"); -// Initialize a technical objects +// Initialize a technical object $object = new AdherentType($db); $extrafields = new ExtraFields($db); $hookmanager->initHooks(array('membertypecard', 'globalcard')); @@ -108,7 +108,7 @@ $result = restrictedArea($user, 'adherent', $rowid, 'adherent_type'); * Actions */ -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers $search_ref = ""; $search_lastname = ""; $search_login = ""; @@ -168,7 +168,7 @@ if ($action == 'add' && $user->hasRight('adherent', 'configurer')) { if ($num) { $error++; $langs->load("errors"); - setEventMessages($langs->trans("ErrorLabelAlreadyExists", $login), null, 'errors'); + setEventMessages($langs->trans("ErrorLabelAlreadyExists", $object->label), null, 'errors'); } } @@ -443,8 +443,6 @@ if (!$rowid && $action != 'create' && $action != 'edit') { // Creation if ($action == 'create') { - $object = new AdherentType($db); - print load_fiche_titre($langs->trans("NewMemberType"), '', 'members'); print '
'; @@ -452,7 +450,7 @@ if ($action == 'create') { print ''; print ''; - print dol_get_fiche_head(''); + print dol_get_fiche_head(array()); print '
'; print ''; diff --git a/htdocs/bookcal/class/availabilities.class.php b/htdocs/bookcal/class/availabilities.class.php index b28e7ef20ce..a04ed3acd76 100644 --- a/htdocs/bookcal/class/availabilities.class.php +++ b/htdocs/bookcal/class/availabilities.class.php @@ -1056,7 +1056,7 @@ class Availabilities extends CommonObject * @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 ?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/bookcal/class/calendar.class.php b/htdocs/bookcal/class/calendar.class.php index 22a62be126f..8b8d15bd96e 100644 --- a/htdocs/bookcal/class/calendar.class.php +++ b/htdocs/bookcal/class/calendar.class.php @@ -667,10 +667,9 @@ class Calendar extends CommonObject /** * getTooltipContentArray - * - * @param array $params Params to construct tooltip data - * @since v18 - * @return array + * @param array $params params to construct tooltip data + * @since v18 + * @return array{picto:string,ref?:string,refsupplier?:string,label?:string,date?:string,date_echeance?:string,amountht?:string,total_ht?:string,totaltva?:string,amountlt1?:string,amountlt2?:string,amountrevenustamp?:string,totalttc?:string}|array{optimize:string} */ public function getTooltipContentArray($params) { diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 432faa6a136..370ef3ca4db 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2016 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * 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 @@ -144,7 +145,7 @@ class Mailing extends CommonObject public $date_envoi; /** - * @var array extraparams + * @var array (Encoded as JSON in database) */ public $extraparams = array(); @@ -498,14 +499,14 @@ class Mailing extends CommonObject if ($this->db->num_rows($result)) { while ($obj = $this->db->fetch_object($result)) { $target_array[] = array( - 'fk_contact'=>$obj->fk_contact, - 'lastname'=>$obj->lastname, - 'firstname'=>$obj->firstname, - 'email'=>$obj->email, - 'other'=>$obj->other, - 'source_url'=>$obj->source_url, - 'source_id'=>$obj->source_id, - 'source_type'=>$obj->source_type + 'fk_contact' => $obj->fk_contact, + 'lastname' => $obj->lastname, + 'firstname' => $obj->firstname, + 'email' => $obj->email, + 'other' => $obj->other, + 'source_url' => $obj->source_url, + 'source_id' => $obj->source_id, + 'source_type' => $obj->source_type ); } } @@ -876,7 +877,7 @@ class Mailing extends CommonObject global $action; $hookmanager->initHooks(array('emailingdao')); - $parameters = array('id'=>$this->id, 'getnomurl' => &$result); + $parameters = array('id' => $this->id, 'getnomurl' => &$result); $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) { $result = $hookmanager->resPrint; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 7723e9e992f..749294d5a7e 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -229,6 +229,9 @@ class Commande extends CommonOrder */ public $warehouse_id; + /** + * @var array (Encoded as JSON in database) + */ public $extraparams = array(); public $linked_objects = array(); diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index 8501dcc1322..e61d302f6be 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -95,6 +95,9 @@ class Deplacement extends CommonObject * @var int Status 0=draft, 1=validated, 2=Refunded */ public $statut; + /** + * @var array (Encoded as JSON in database) + */ public $extraparams = array(); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index d9aee4712a7..25d1186c5c9 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -89,6 +89,7 @@ $hookmanager->initHooks(array('contractcard', 'globalcard')); $object = new Contrat($db); $extrafields = new ExtraFields($db); +$ret = 0; // Load object if ($id > 0 || !empty($ref) && $action != 'add') { @@ -1592,6 +1593,7 @@ if ($action == 'create') { $sql .= " WHERE cd.rowid = ".((int) $object->lines[$cursorline - 1]->id); $result = $db->query($sql); + $objp = null; if ($result) { $total = 0; @@ -1950,7 +1952,7 @@ if ($action == 'create') { print ''; print ''; print '
'.$langs->trans("ServiceStatus").': '.$object->lines[$cursorline - 1]->getLibStatut(4).''; if ($user->socid == 0) { - if ($object->statut > 0 && $action != 'activateline' && $action != 'unactivateline') { + if ($object->statut > 0 && $action != 'activateline' && $action != 'unactivateline' && is_object($objp)) { $tmpaction = 'activateline'; $tmpactionpicto = 'play'; $tmpactiontext = $langs->trans("Activate"); @@ -2006,7 +2008,7 @@ if ($action == 'create') { } // Form to activate line - if ($user->hasRight('contrat', 'activer') && $action == 'activateline' && $object->lines[$cursorline - 1]->id == GETPOSTINT('ligne')) { + if ($user->hasRight('contrat', 'activer') && $action == 'activateline' && $object->lines[$cursorline - 1]->id == GETPOSTINT('ligne') && is_object($objp)) { print ''; print ''; print ''; @@ -2061,7 +2063,7 @@ if ($action == 'create') { print ''; } - if ($user->hasRight('contrat', 'activer') && $action == 'unactivateline' && $object->lines[$cursorline - 1]->id == GETPOSTINT('ligne')) { + if ($user->hasRight('contrat', 'activer') && $action == 'unactivateline' && $object->lines[$cursorline - 1]->id == GETPOSTINT('ligne') && is_object($objp)) { /** * Disable a contract line */ @@ -2327,7 +2329,7 @@ if ($action == 'create') { // Show links to link elements - $linktoelem = $form->showLinkToObjectBlock($object, null, array('contrat')); + $linktoelem = $form->showLinkToObjectBlock($object, array(), array('contrat')); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); // Show online signature link diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index ba5d56c0bf1..1c740316446 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -88,6 +88,10 @@ class Contrat extends CommonObject * @var string */ public $ref_customer; + + /** + * @var string Partial SQL query: 'FROM ' expression + */ public $from; /** @@ -132,6 +136,9 @@ class Contrat extends CommonObject */ public $status = 0; + /** + * @var Product + */ public $product; /** @@ -169,9 +176,21 @@ class Contrat extends CommonObject */ public $signed_status = 0; + /** + * @var int + */ public $commercial_signature_id; + /** + * @var int|string + */ public $fk_commercial_signature; + /** + * @var int + */ public $commercial_suivi_id; + /** + * @var int|string + */ public $fk_commercial_suivi; /** @@ -181,6 +200,9 @@ class Contrat extends CommonObject */ public $fk_projet; + /** + * @var array (Encoded as JSON in database) + */ public $extraparams = array(); /** @@ -188,10 +210,25 @@ class Contrat extends CommonObject */ public $lines = array(); + /** + * @var int + */ public $nbofservices; + /** + * @var int + */ public $nbofserviceswait; + /** + * @var int + */ public $nbofservicesopened; + /** + * @var int + */ public $nbofservicesexpired; + /** + * @var int + */ public $nbofservicesclosed; //public $lower_planned_end_date; //public $higher_planner_end_date; @@ -676,16 +713,18 @@ class Contrat extends CommonObject /** * Load a contract from database * - * @param int $id Id of contract to load - * @param string $ref Ref - * @param string $ref_customer Customer ref - * @param string $ref_supplier Supplier ref - * @param int $noextrafields 0=Default to load extrafields, 1=No extrafields - * @param int $nolines 0=Default to load lines, 1=No lines + * @param int $id Id of contract to load + * @param string $ref Ref + * @param string $ref_customer Customer ref + * @param string $ref_supplier Supplier ref + * @param int<0,1> $noextrafields 0=Default to load extrafields, 1=No extrafields + * @param int<0,1> $nolines 0=Default to load lines, 1=No lines * @return int Return integer <0 if KO, 0 if not found or if two records found for same ref, Id of contract if OK */ public function fetch($id, $ref = '', $ref_customer = '', $ref_supplier = '', $noextrafields = 0, $nolines = 0) { + $result = -10; + $sql = "SELECT rowid, statut as status, ref, fk_soc as thirdpartyid,"; $sql .= " ref_supplier, ref_customer,"; $sql .= " ref_ext,"; @@ -800,10 +839,10 @@ class Contrat extends CommonObject * Load lines array into this->lines. * This set also nbofserviceswait, nbofservicesopened, nbofservicesexpired and nbofservicesclosed * - * @param int $only_services 0=Default for all, 1=Force only services (depending on setup, we may also have physical products in a contract) - * @param int $loadalsotranslation 0=Default to not load translations, 1=Load also translations of product descriptions - * @param int $noextrafields 0=Default to load extrafields, 1=Do not load the extrafields of lines - * @return array|int Return array of contract lines + * @param int<0,1> $only_services 0=Default for all, 1=Force only services (depending on setup, we may also have physical products in a contract) + * @param int<0,1> $loadalsotranslation 0=Default to not load translations, 1=Load also translations of product descriptions + * @param int<0,1> $noextrafields 0=Default to load extrafields, 1=Do not load the extrafields of lines + * @return array|int Return array of contract lines */ public function fetch_lines($only_services = 0, $loadalsotranslation = 0, $noextrafields = 0) { @@ -1443,7 +1482,7 @@ class Contrat extends CommonObject * @param int $info_bits Bits of type of lines * @param int $fk_fournprice Fourn price id * @param int $pa_ht Buying price HT - * @param array $array_options extrafields array + * @param array $array_options extrafields array * @param string $fk_unit Code of the unit to use. Null to use the default one * @param int $rang Position * @return int Return integer <0 if KO, >0 if OK @@ -1678,7 +1717,7 @@ class Contrat extends CommonObject * @param int $info_bits Bits of type of lines * @param int $fk_fournprice Fourn price id * @param int $pa_ht Buying price HT - * @param array $array_options extrafields array + * @param array $array_options extrafields array * @param string $fk_unit Code of the unit to use. Null to use the default one * @param int $rang Position * @return int Return integer <0 if KO, >0 if OK @@ -2006,9 +2045,9 @@ class Contrat extends CommonObject /** * getTooltipContentArray - * @param array $params params to construct tooltip data + * @param array $params params to construct tooltip data * @since v18 - * @return array + * @return array{picto:string,ref?:string,refsupplier?:string,label?:string,date?:string,date_echeance?:string,amountht?:string,total_ht?:string,totaltva?:string,amountlt1?:string,amountlt2?:string,amountrevenustamp?:string,totalttc?:string}|array{optimize:string} */ public function getTooltipContentArray($params) { @@ -2175,8 +2214,8 @@ class Contrat extends CommonObject /** * Return list of line rowid * - * @param int $status Status of lines to get - * @return array|int Array of line's rowid or <0 if error + * @param int $status Status of lines to get + * @return int[]|int Array of line's rowid or <0 if error */ public function array_detail($status = -1) { @@ -2210,11 +2249,11 @@ class Contrat extends CommonObject /** * Return list of other contracts for the same company than current contract * - * @param string $option 'all' or 'others' - * @param array $status sort contracts having these status - * @param array $product_categories sort contracts containing these product categories - * @param array $line_status sort contracts where lines have these status - * @return array|int Array of contracts id or <0 if error + * @param 'all'|'others' $option 'all' or 'others' + * @param int[] $status sort contracts having these status + * @param string[] $product_categories sort contracts containing these product categories + * @param int[] $line_status sort contracts where lines have these status + * @return array|int Array of contracts id or <0 if error */ public function getListOfContracts($option = 'all', $status = [], $product_categories = [], $line_status = []) { @@ -2394,7 +2433,7 @@ class Contrat extends CommonObject /** * Return id des contacts clients de facturation * - * @return array Liste des id contacts facturation + * @return int[] Liste des id contacts facturation */ public function getIdBillingContact() { @@ -2404,7 +2443,7 @@ class Contrat extends CommonObject /** * Return id des contacts clients de prestation * - * @return array Liste des id contacts prestation + * @return int[] Liste des id contacts prestation */ public function getIdServiceContact() { @@ -2499,14 +2538,14 @@ class Contrat extends CommonObject /** * Create an array of associated tickets * - * @return array|int Array o tickets or <0 if KO + * @return Ticket[]|int Array o tickets or <0 if KO */ public function getTicketsArray() { global $user; $ticket = new Ticket($this->db); - $nbTicket = $ticket->fetchAll($user, 'ASC', 't.datec', '', 0, '', array('t.fk_contract' => $this->id)); + $nbTicket = $ticket->fetchAll($user, 'ASC', 't.datec', 0, 0, 0, array('t.fk_contract' => $this->id)); return ($nbTicket < 0 ? $nbTicket : $ticket->lines); } @@ -2520,7 +2559,7 @@ class Contrat extends CommonObject * @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 ?array $moreparams Array to provide more information * @return int Return integer < 0 if KO, 0 = no doc generated, > 0 if OK */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) @@ -2635,7 +2674,7 @@ class Contrat extends CommonObject require_once DOL_DOCUMENT_ROOT."/core/modules/contract/" . getDolGlobalString('CONTRACT_ADDON').'.php'; $obj = getDolGlobalString('CONTRACT_ADDON'); $modContract = new $obj(); - '@phan-var-force ModelNumRefContracts $modContrat'; + '@phan-var-force ModelNumRefContracts $modContract'; $clonedObj->ref = $modContract->getNextValue($objsoc, $clonedObj); // get extrafields so they will be clone @@ -2916,6 +2955,7 @@ class Contrat extends CommonObject } if (!empty($arraydata['thirdparty'])) { $tmpthirdparty = $arraydata['thirdparty']; + '@phan-var-force Societe $tmpthirdparty'; $return .= '
'.$tmpthirdparty->getNomUrl(1).'
'; } if (property_exists($this, 'date_contrat')) { diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index c76a4181aff..5f8a5305563 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -296,7 +296,7 @@ if (isModEnabled('contract') && $user->hasRight('contrat', 'lire')) { $staticcompany->fournisseur = $obj->fournisseur; print '
'; - print $staticcontrat->getNomUrl(1, ''); + print $staticcontrat->getNomUrl(1, 0); print ''; print $staticcompany->getNomUrl(1, '', 16); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 86b6961d2d3..0d28261d4c7 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -817,7 +817,7 @@ abstract class CommonObject public $output; /** - * @var array|string extra parameters. Try to store here the array of parameters. Old code is sometimes storing a string. + * @var array|string extra parameters. Try to store here the array of parameters. Old code is sometimes storing a string. */ public $extraparams = array(); diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index aaeca56555d..86a4b8f433a 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -397,7 +397,7 @@ class FormOther /** * Return select list for categories (to use in form search selectors) * - * @param int $type Type of category ('customer', 'supplier', 'contact', 'product', 'member'). Old mode (0, 1, 2, ...) is deprecated. + * @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member'). Old mode (0, 1, 2, ...) is deprecated. * @param integer $selected Preselected value * @param string $htmlname Name of combo list * @param int $nocateg Show also an entry "Not categorized" diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php index 69ae2fcd693..2499ec19ff1 100644 --- a/htdocs/core/class/stats.class.php +++ b/htdocs/core/class/stats.class.php @@ -395,7 +395,7 @@ abstract class Stats * Return nb of elements by year * * @param string $sql SQL request - * @return array + * @return array Array of nb each year */ protected function _getNbByYear($sql) { diff --git a/htdocs/core/class/timespent.class.php b/htdocs/core/class/timespent.class.php index ef8c2cdb148..de75e537531 100644 --- a/htdocs/core/class/timespent.class.php +++ b/htdocs/core/class/timespent.class.php @@ -123,22 +123,73 @@ class TimeSpent extends CommonObject 'datec' => array('type' => 'datetime', 'label' => 'datec', 'enabled' => 1, 'position' => 16, 'notnull' => 0, 'visible' => -1,), 'note' => array('type' => 'text', 'label' => 'note', 'enabled' => 1, 'position' => 18, 'notnull' => 0, 'visible' => -1,), ); + /** + * @var int + */ public $rowid; + /** + * @var string + */ public $import_key; + /** + * @var int + */ public $fk_element; + /** + * @var string + */ public $elementtype; + /** + * @var int|string + */ public $element_date; + /** + * @var int + */ public $element_datehour; + /** + * @var int + */ public $element_date_withhour; + /** + * @var float + */ public $element_duration; + /** + * @var int + */ public $fk_product; + /** + * @var int + */ public $fk_user; + /** + * @var float + */ public $thm; + /** + * @var int + */ public $invoice_id; + /** + * @var int + */ public $invoice_line_id; + /** + * @var int + */ public $intervention_id; + /** + * @var int + */ public $intervention_line_id; + /** + * @var string + */ public $datec; + /** + * @var string + */ public $note; // END MODULEBUILDER PROPERTIES @@ -235,6 +286,7 @@ class TimeSpent extends CommonObject $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default']; } if (property_exists($object, 'label')) { + // @phan-suppress-next-line PhanUndeclaredProperty $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default']; } if (property_exists($object, 'status')) { @@ -277,7 +329,7 @@ class TimeSpent extends CommonObject } if (!$error) { - // copy external contacts if same company + // copy external contacts if same company @phan-suppress-next-line PHanUndeclaredProperty if (!empty($object->socid) && property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) { if ($this->copy_linked_contact($object, 'external') < 0) { $error++; @@ -321,7 +373,7 @@ class TimeSpent 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 self[]|int int <0 if KO, array of pages if OK */ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND') { @@ -632,9 +684,9 @@ class TimeSpent extends CommonObject /** * getTooltipContentArray - * @param array $params params to construct tooltip data + * @param array $params params to construct tooltip data * @since v18 - * @return array + * @return array{picto:string,ref?:string,refsupplier?:string,label?:string,date?:string,date_echeance?:string,amountht?:string,total_ht?:string,totaltva?:string,amountlt1?:string,amountlt2?:string,amountrevenustamp?:string,totalttc?:string}|array{optimize:string} */ public function getTooltipContentArray($params) { @@ -804,6 +856,7 @@ class TimeSpent extends CommonObject } if (property_exists($this, 'amount')) { $return .= '
'; + // @phan-suppress-next-line PhanUndeclaredProperty $return .= ''.price($this->amount, 0, $langs, 1, -1, -1, $conf->currency).''; } if (method_exists($this, 'getLibStatut')) { @@ -981,7 +1034,7 @@ class TimeSpent extends CommonObject * @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 ?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/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 42fd4f9a19a..4fe9d75f1c1 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -51,15 +51,30 @@ class ImportCsv extends ModeleImports */ public $version = 'dolibarr'; - public $label_lib; // Label of external lib used by driver + /** + * @var string Label of external lib used by driver + */ + public $label_lib; - public $version_lib; // Version of external lib used by driver + /** + * @var string Version of external lib used by driver + */ + public $version_lib; + /** + * @var string|string[] + */ public $separator; + /** + * @var string + */ public $file; // Path of file - public $handle; // Handle fichier + /** + * @var resource + */ + public $handle; // File handle public $cacheconvert = array(); // Array to cache list of value found after a conversion @@ -135,7 +150,7 @@ class ImportCsv extends ModeleImports * Output title line of an example file for this format * * @param Translate $outputlangs Output language - * @param array $headerlinefields Array of fields name + * @param string[] $headerlinefields Array of fields name * @return string String output */ public function write_title_example($outputlangs, $headerlinefields) @@ -150,7 +165,7 @@ class ImportCsv extends ModeleImports * Output record of an example file for this format * * @param Translate $outputlangs Output language - * @param array $contentlinevalues Array of lines + * @param string[] $contentlinevalues Array of lines * @return string String output */ public function write_record_example($outputlangs, $contentlinevalues) @@ -191,12 +206,13 @@ class ImportCsv extends ModeleImports ini_set('auto_detect_line_endings', 1); // For MAC compatibility - $this->handle = fopen(dol_osencode($file), "r"); + $handle = fopen(dol_osencode($file), "r"); if (!$this->handle) { $langs->load("errors"); $this->error = $langs->trans("ErrorFailToOpenFile", $file); $ret = -1; } else { + $this->handle = $handle; $this->file = $file; } @@ -297,12 +313,12 @@ class ImportCsv extends ModeleImports /** * Insert a record into database * - * @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]... - * @param array $array_match_file_to_database Array of target fields where to insert data: [fieldpos] => 's.fieldname', [fieldpos+1]... - * @param Object $objimport Object import (contains objimport->array_import_tables, objimport->array_import_fields, objimport->array_import_convertvalue, ...) - * @param int $maxfields Max number of fields to use - * @param string $importid Import key - * @param array $updatekeys Array of keys to use to try to do an update first before insert. This field are defined into the module descriptor. + * @param array|bool $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]... + * @param array $array_match_file_to_database Array of target fields where to insert data: [fieldpos] => 's.fieldname', [fieldpos+1]... + * @param Object $objimport Object import (contains objimport->array_import_tables, objimport->array_import_fields, objimport->array_import_convertvalue, ...) + * @param int $maxfields Max number of fields to use + * @param string $importid Import key + * @param string[] $updatekeys Array of keys to use to try to do an update first before insert. This field are defined into the module descriptor. * @return int Return integer <0 if KO, >0 if OK */ public function import_insert($arrayrecord, $array_match_file_to_database, $objimport, $maxfields, $importid, $updatekeys) @@ -711,7 +727,7 @@ class ImportCsv extends ModeleImports } } - // Now we check cache is not empty (should not) and key is into cache + // Now we check cache is not empty (should not) and key is in cache if (!is_array($this->cachefieldtable[$cachekey]) || !in_array($newval, $this->cachefieldtable[$cachekey])) { $tableforerror = $table; if (!empty($filter)) { diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 8d0d762244d..33ab2608e6a 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -56,14 +56,29 @@ class ImportXlsx extends ModeleImports */ public $version = 'dolibarr'; + /** + * @var string + */ public $label_lib; // Label of external lib used by driver + /** + * @var string + */ public $version_lib; // Version of external lib used by driver + /** + * @var string + */ public $separator; + /** + * @var string + */ public $file; // Path of file + /** + * @var resource + */ public $handle; // Handle fichier public $cacheconvert = array(); // Array to cache list of value found after a conversion @@ -74,10 +89,19 @@ class ImportXlsx extends ModeleImports public $nbupdate = 0; // # of update done during the import + /** + * @var \PhpOffice\PhpSpreadsheet\Spreadsheet + */ public $workbook; // temporary import file + /** + * @var int + */ public $record; // current record + /** + * @var array + */ public $headers; @@ -161,7 +185,7 @@ class ImportXlsx extends ModeleImports * Output title line of an example file for this format * * @param Translate $outputlangs Output language - * @param array $headerlinefields Array of fields name + * @param string[] $headerlinefields Array of fields name * @return string String output */ public function write_title_example($outputlangs, $headerlinefields) @@ -187,7 +211,7 @@ class ImportXlsx extends ModeleImports * Output record of an example file for this format * * @param Translate $outputlangs Output language - * @param array $contentlinevalues Array of lines + * @param mixed[] $contentlinevalues Array of lines * @return string Empty string */ public function write_record_example($outputlangs, $contentlinevalues) @@ -354,12 +378,12 @@ class ImportXlsx extends ModeleImports /** * Insert a record into database * - * @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]... - * @param array $array_match_file_to_database Array of target fields where to insert data: [fieldpos] => 's.fieldname', [fieldpos+1]... - * @param Object $objimport Object import (contains objimport->array_import_tables, objimport->array_import_fields, objimport->array_import_convertvalue, ...) - * @param int $maxfields Max number of fields to use - * @param string $importid Import key - * @param array $updatekeys Array of keys to use to try to do an update first before insert. This field are defined into the module descriptor. + * @param array|bool $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]... + * @param array $array_match_file_to_database Array of target fields where to insert data: [fieldpos] => 's.fieldname', [fieldpos+1]... + * @param Object $objimport Object import (contains objimport->array_import_tables, objimport->array_import_fields, objimport->array_import_convertvalue, ...) + * @param int $maxfields Max number of fields to use + * @param string $importid Import key + * @param string[] $updatekeys Array of keys to use to try to do an update first before insert. This field are defined into the module descriptor. * @return int Return integer <0 if KO, >0 if OK */ public function import_insert($arrayrecord, $array_match_file_to_database, $objimport, $maxfields, $importid, $updatekeys) @@ -899,10 +923,16 @@ class ImportXlsx extends ModeleImports } } else { $this->errors[$error]['type'] = 'CLASSERROR'; - $this->errors[$error]['lib'] = implode( - "\n", - array_merge([$classinstance->error], $classinstance->errors) - ); + if (is_object($classinstance)) { + $this->errors[$error]['lib'] = implode( + "\n", + array_merge([$classinstance->error], $classinstance->errors) + ); + } else { + $this->errors[$error]['lib'] + = "Unexpected rule ".$objimport->array_import_convertvalue[0][$fieldname]['rule']; + } + $errorforthistable++; $error++; } diff --git a/htdocs/core/modules/import/modules_import.php b/htdocs/core/modules/import/modules_import.php index d6f9b3452ff..a5c2218efec 100644 --- a/htdocs/core/modules/import/modules_import.php +++ b/htdocs/core/modules/import/modules_import.php @@ -473,7 +473,7 @@ class ModeleImports * Insert a record into database * * @param array}>|boolean $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]... - * @param array $array_match_file_to_database Array of target fields where to insert data: [fieldpos] => 's.fieldname', [fieldpos+1]... + * @param array $array_match_file_to_database Array of target fields where to insert data: [fieldpos] => 's.fieldname', [fieldpos+1]... * @param Object $objimport Object import (contains objimport->array_import_tables, objimport->array_import_fields, objimport->array_import_convertvalue, ...) * @param int $maxfields Max number of fields to use * @param string $importid Import key diff --git a/htdocs/core/modules/member/mod_member_advanced.php b/htdocs/core/modules/member/mod_member_advanced.php index 83dafa23e4a..a158c9ef21d 100644 --- a/htdocs/core/modules/member/mod_member_advanced.php +++ b/htdocs/core/modules/member/mod_member_advanced.php @@ -115,7 +115,7 @@ class mod_member_advanced extends ModeleNumRefMembers /** * Return next value * - * @param Societe $objsoc Object third party + * @param ?Societe $objsoc Object third party * @param ?Adherent $object Object we need next value for * @return string|int<-1,0> Value if OK, -1 if KO */ diff --git a/htdocs/core/modules/member/mod_member_simple.php b/htdocs/core/modules/member/mod_member_simple.php index 6c5059b086c..e35531f3265 100644 --- a/htdocs/core/modules/member/mod_member_simple.php +++ b/htdocs/core/modules/member/mod_member_simple.php @@ -113,7 +113,7 @@ class mod_member_simple extends ModeleNumRefMembers /** * Return next value * - * @param Societe $objsoc Object third party + * @param ?Societe $objsoc Object third party * @param ?Adherent $object Object we need next value for * @return string|int<-1,0> Value if OK, -1 if KO */ diff --git a/htdocs/core/modules/member/modules_member.class.php b/htdocs/core/modules/member/modules_member.class.php index d9835a3789e..eeb188056e6 100644 --- a/htdocs/core/modules/member/modules_member.class.php +++ b/htdocs/core/modules/member/modules_member.class.php @@ -85,7 +85,7 @@ abstract class ModeleNumRefMembers extends CommonNumRefGenerator * Return description of module parameters * * @param Translate $langs Output language - * @param Societe $soc Third party object + * @param ?Societe $soc Third party object * @return string HTML translated description */ public function getToolTip($langs, $soc) @@ -128,7 +128,7 @@ abstract class ModeleNumRefMembers extends CommonNumRefGenerator /** * Return next value * - * @param Societe $objsoc Object third party + * @param ?Societe $objsoc Object third party * @param ?Adherent $object Object we need next value for * @return string|int<-1,0> next value */ diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index 79e91f53e4e..470bee4724b 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -276,7 +276,7 @@ class Delivery extends CommonObject * @param string $qty Quantity * @param int $fk_product Id of predefined product * @param string $description Description - * @param array $array_options Array options + * @param array $array_options Array options * @return int Return integer <0 if KO, >0 if OK */ public function create_line($origin_id, $qty, $fk_product, $description, $array_options = []) @@ -420,6 +420,7 @@ class Delivery extends CommonObject // Retrieving the new reference $objMod = new $modName($this->db); + '@phan-var-force ModeleNumRefDeliveryOrder $objMod'; $soc = new Societe($this->db); $soc->fetch($this->socid); @@ -546,7 +547,7 @@ class Delivery extends CommonObject * * @param User $user User who creates * @param int $sending_id Id of the expedition that serves as a model - * @return integer Return integer <=0 if KO, >0 if OK + * @return int Return integer <=0 if KO, >0 if OK */ public function create_from_sending($user, $sending_id) { @@ -596,9 +597,9 @@ class Delivery extends CommonObject /** * Update a livraison line (only extrafields) * - * @param int $id Id of line (livraison line) - * @param array $array_options extrafields array - * @return int Return integer <0 if KO, >0 if OK + * @param int $id Id of line (livraison line) + * @param array $array_options extrafields array + * @return int Return integer <0 if KO, >0 if OK */ public function update_line($id, $array_options = []) { @@ -631,7 +632,7 @@ class Delivery extends CommonObject * * @param int $origin_id Origin id * @param float $qty Qty - * @param array $array_options Array options + * @param array $array_options Array options * @return void */ public function addline($origin_id, $qty, $array_options = []) @@ -750,9 +751,9 @@ class Delivery extends CommonObject /** * getTooltipContentArray - * @param array $params params to construct tooltip data + * @param array $params params to construct tooltip data * @since v18 - * @return array + * @return array{picto:string,ref?:string,refsupplier?:string,label?:string,date?:string,date_echeance?:string,amountht?:string,total_ht?:string,totaltva?:string,amountlt1?:string,amountlt2?:string,amountrevenustamp?:string,totalttc?:string}|array{optimize:string} */ public function getTooltipContentArray($params) { @@ -1015,15 +1016,15 @@ class Delivery extends CommonObject } /** - * Renvoie la quantite de produit restante a livrer pour une commande + * Get data list of Products remaining to be delivered for an order (with qty) * - * @return array|int Product remaining to be delivered or <0 if KO + * @return array|int Product remaining to be delivered or <0 if KO * TODO use new function */ public function getRemainingDelivered() { // Get the linked object - $this->fetchObjectLinked('', '', $this->id, $this->element); + $this->fetchObjectLinked(null, '', $this->id, $this->element); //var_dump($this->linkedObjectsIds); // Get the product ref and qty in source $sqlSourceLine = "SELECT st.rowid, st.description, st.qty"; @@ -1208,11 +1209,13 @@ class DeliveryLine extends CommonObjectLine /** * @deprecated * @see $product_ref + * @var string */ public $ref; /** * @deprecated * @see product_label; + * @var string */ public $libelle; @@ -1228,19 +1231,43 @@ class DeliveryLine extends CommonObjectLine public $qty_asked; /** - * @var float Quantity shiiped + * @var float Quantity shipped */ public $qty_shipped; + /** + * @var int + */ public $fk_product; + /** + * @var string + */ public $product_desc; + /** + * @var int + */ public $product_type; + /** + * @var string + */ public $product_ref; + /** + * @var string + */ public $product_label; + /** + * @var int|float|string + */ public $price; + /** + * @var int + */ public $fk_origin_line; + /** + * @var int + */ public $origin_id; /** diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index b74c9588e5f..89221862c39 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -179,7 +179,7 @@ class Fichinter extends CommonObject public $ref_client; /** - * @var array extraparams + * @var array (Encoded as JSON in database) */ public $extraparams = array(); @@ -514,7 +514,7 @@ class Fichinter extends CommonObject $this->socid = $obj->fk_soc; $this->status = $obj->status; $this->statut = $obj->status; // deprecated - $this->signed_status= $obj->signed_status; + $this->signed_status = $obj->signed_status; $this->duration = $obj->duree; $this->datec = $this->db->jdate($obj->datec); $this->dateo = $this->db->jdate($obj->dateo); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 02f82a17ccf..d09b8bbe301 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -261,6 +261,9 @@ class CommandeFournisseur extends CommonOrder public $refuse_note; + /** + * @var array (Encoded as JSON in database) + */ public $extraparams = array(); /** diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index c0fe3d11dc8..ab69fbeceb9 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -237,6 +237,9 @@ class FactureFournisseur extends CommonInvoice */ public $vat_reverse_charge; + /** + * @var array (Encoded as JSON in database) + */ public $extraparams = array(); /** diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 54cdda1035b..0a378de9553 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -3689,7 +3689,7 @@ if ($module == 'initmodule') { if ($moduledescritpionautotrans != "Module".$moduleobj->name."Desc") { // $moduledescritpionautotrans has been found into a translation file print ' '.$form->textwithpicto('', $langs->trans("ModuleTranslatedIntoLangForKeyInto", "Module".$moduleobj->name."Desc", $moduledescritpionautotrans)); - } elseif ($moduledescritpionautotrans != "Module".$moduleobj->numeroc."Desc") { + } elseif ($moduledescritpionautotrans != "Module".$moduleobj->numero."Desc") { // $moduledescritpionautotrans has been found into a translation file print ' '.$form->textwithpicto('', $langs->trans("ModuleTranslatedIntoLangForKeyInto", "Module".$moduleobj->numero."Desc", $moduledescritpionautotrans)); } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 81afbaa2e31..7b2930044c3 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -862,6 +862,9 @@ class Societe extends CommonObject // Fields loaded by fetchPartnerships() + /** + * @var array> + */ public $partnerships = array(); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index db843edcbdf..b99220b84d5 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -161,6 +161,9 @@ class SupplierProposal extends CommonObject */ public $mode_reglement; + /** + * @var array (Encoded as JSON in database) + */ public $extraparams = array(); public $lines = array(); public $line; diff --git a/phpstan.neon.dist b/phpstan.neon.dist index d06ff1390f3..61f7c7152e7 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -47,7 +47,6 @@ parameters: treatPhpDocTypesAsCertain: false ignoreErrors: - '#Result of function fieldList#' - - '#Caught class Stripe#' - '#Function llxHeaderVierge invoked with#' - '#always exists and is not falsy#' - '#always exists and is not nullable#' @@ -70,8 +69,6 @@ parameters: - '#expects bool, string given.#' - '#expects int\|string#' - '#expects int\|null#' - - '#expects int<-2, 2>, bool given.#' - - '#expects int<0, 1>#' - '#color.* expects int, string#' - '#imap.* expects int, string#' - '#convert.* expects int, string#' @@ -87,7 +84,8 @@ parameters: - '#dol_move expects string, int given#' - '#expects int, float#' - '#expects int, array\|string given.#' - - '#expects int<0, 1>, '''' given.#' + - '#expects int<0, 1>#' + - '#expects int<-2, 2>, bool given.#' - '#expects float\|string#' - '#expects float\|null#' - '#expects float, string given.#' @@ -110,27 +108,17 @@ parameters: - '#expects array, null given.#' - - '#expects array, string given.#' - - '#expects array\|string#' - '#expects resource#' - - '#expects resource, object given.#' - '#expects object#' - - '#expects Adherent#' - - '#expects BOM#' - '#expects FTP\\Connection#' - '#expects LDAP\\Connection#' - '#expects MultiCurrency#' - - '#expects Productlot#' - '#expects Facture#' - - '#expects FactureFournisseur#' - '#expects Paiement#' - '#expects PgSql\\Result#' - '#expects Societe#' - '#expects ''''\|Societe#' - - '#expects SupplierProposal#' - '#expects CommonObjectLine#' - - '#check_authentication expects#' - '#colorHexToHsl expects#' internalErrorsCountLimit: 50 cache: From e4e5d1df8f5df91588a8fd5d8dfa2406b64188a2 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 12 Sep 2024 21:21:18 +0200 Subject: [PATCH 2/2] Fix : missing indexes on product_attribute_combination2val table (#30936) * Fix : missing indexes on product_attribute_combination2val table * Update 15.0.0-16.0.0.sql --------- Co-authored-by: Laurent Destailleur --- ..._product_attribute_combination2val.key.sql | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 htdocs/install/mysql/tables/llx_product_attribute_combination2val.key.sql diff --git a/htdocs/install/mysql/tables/llx_product_attribute_combination2val.key.sql b/htdocs/install/mysql/tables/llx_product_attribute_combination2val.key.sql new file mode 100644 index 00000000000..407062423d6 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_product_attribute_combination2val.key.sql @@ -0,0 +1,21 @@ +-- ============================================================================ +-- Copyright (C) 2024 Maxime Kohlhaas +-- +-- 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 +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ============================================================================ + +ALTER TABLE llx_product_attribute_combination2val ADD INDEX idx_product_att_com2v_prod_combination (fk_prod_combination); +ALTER TABLE llx_product_attribute_combination2val ADD INDEX idx_product_att_com2v_prod_attr (fk_prod_attr); +ALTER TABLE llx_product_attribute_combination2val ADD INDEX idx_product_att_com2v_prod_attr_val (fk_prod_attr_val);