From e7539f2e195b7d107e8bace09e7d20480e20b4dd Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 4 Nov 2024 12:32:13 +0100 Subject: [PATCH] Qual: Fix notices in .lib.php files (#31672) * Qual: Fix notices in .lib.php files * Update wrapper.php * Update availabilities_card.php * Update index.php * Update document.controller.class.php --------- Co-authored-by: Laurent Destailleur --- dev/tools/phan/baseline.txt | 43 +++---------- dev/tools/phan/config.php | 2 + htdocs/admin/menus/index.php | 45 +++++++------- htdocs/asterisk/wrapper.php | 2 +- htdocs/bookcal/availabilities_card.php | 1 - htdocs/categories/index.php | 3 +- htdocs/categories/viewcat.php | 2 +- htdocs/comm/propal/class/propal.class.php | 40 ++++++------ htdocs/commande/class/commande.class.php | 40 ++++++------ htdocs/compta/deplacement/stats/index.php | 1 - htdocs/compta/facture/card.php | 16 ++--- .../facture/class/facture-rec.class.php | 4 +- htdocs/compta/facture/class/facture.class.php | 62 +++++++++---------- .../facture/class/factureligne.class.php | 4 +- htdocs/compta/localtax/clients.php | 3 +- htdocs/compta/localtax/index.php | 3 +- htdocs/compta/localtax/quadri_detail.php | 3 +- htdocs/contrat/class/contratligne.class.php | 10 +-- htdocs/core/class/commonobject.class.php | 2 +- htdocs/core/class/diasporahandler.class.php | 2 +- .../connectors/php/connector.lib.php | 15 ++--- .../connectors/php/connector.php | 4 +- htdocs/core/lib/accounting.lib.php | 13 ++-- htdocs/core/lib/agenda.lib.php | 12 ++-- htdocs/core/lib/ajax.lib.php | 20 +++--- htdocs/core/lib/bank.lib.php | 8 ++- htdocs/core/lib/company.lib.php | 32 +++++----- htdocs/core/lib/customreports.lib.php | 31 +++++----- htdocs/core/lib/date.lib.php | 37 ++++++----- htdocs/core/lib/doc.lib.php | 2 + htdocs/core/lib/ftp.lib.php | 7 ++- htdocs/core/lib/functions.lib.php | 38 ++++++------ htdocs/core/lib/functionsnumtoword.lib.php | 13 +++- htdocs/core/lib/geturl.lib.php | 14 ++--- htdocs/core/lib/images.lib.php | 25 +++++--- htdocs/core/lib/invoice2.lib.php | 5 +- htdocs/core/lib/ldap.lib.php | 2 +- htdocs/core/lib/loan.lib.php | 3 +- htdocs/core/lib/memory.lib.php | 12 ++-- htdocs/core/lib/oauth.lib.php | 6 +- htdocs/core/lib/payments.lib.php | 2 +- htdocs/core/lib/pdf.lib.php | 4 +- htdocs/core/lib/price.lib.php | 20 +++--- htdocs/core/lib/report.lib.php | 3 +- htdocs/core/lib/security.lib.php | 12 ++-- htdocs/core/lib/signature.lib.php | 3 +- htdocs/core/lib/treeview.lib.php | 14 ++--- htdocs/core/lib/xcal.lib.php | 8 +-- htdocs/core/menus/standard/auguria.lib.php | 2 +- .../facture/doc/pdf_octopus.modules.php | 4 +- .../core/modules/syslog/mod_syslog_syslog.php | 2 +- htdocs/core/tpl/objectline_view.tpl.php | 4 +- htdocs/datapolicy/lib/datapolicy.lib.php | 3 +- .../emailcollector/lib/emailcollector.lib.php | 14 ++--- htdocs/expedition/class/expedition.class.php | 10 +-- .../class/expensereport.class.php | 40 ++++++------ .../class/fournisseur.commande.class.php | 44 ++++++------- .../fourn/class/fournisseur.facture.class.php | 46 +++++++------- htdocs/ftp/index.php | 7 ++- htdocs/install/upgrade2.php | 30 ++++----- htdocs/margin/lib/margins.lib.php | 2 +- htdocs/opensurvey/lib/opensurvey.lib.php | 2 +- htdocs/paypal/lib/paypal.lib.php | 16 ++--- htdocs/public/onlinesign/newonlinesign.php | 3 +- htdocs/stripe/class/stripe.class.php | 2 +- .../class/supplier_proposal.class.php | 44 ++++++------- htdocs/user/hierarchy.php | 6 +- htdocs/webhook/target_card.php | 4 +- .../controllers/document.controller.class.php | 13 ++-- phpstan.neon.dist | 5 +- scripts/invoices/rebuild_merge_pdf.php | 6 +- 71 files changed, 496 insertions(+), 466 deletions(-) diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 25bd8357ad0..a9276985563 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -64,7 +64,7 @@ return [ 'htdocs/api/class/api_setup.class.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/api/class/api_status.class.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/asset/admin/setup.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/asset/class/asset.class.php' => ['PhanPluginUndeclaredVariableIsset'], + 'htdocs/asset/class/asset.class.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanTypeInvalidDimOffset'], 'htdocs/asset/class/assetdepreciationoptions.class.php' => ['PhanTypeInvalidDimOffset'], 'htdocs/asset/class/assetmodel.class.php' => ['PhanUndeclaredProperty'], 'htdocs/asset/depreciation.php' => ['PhanPluginEmptyStatementIf'], @@ -260,36 +260,16 @@ return [ 'htdocs/core/datepicker.php' => ['PhanTypeInvalidDimOffset'], 'htdocs/core/db/sqlite3.class.php' => ['PhanTypeMismatchReturn'], 'htdocs/core/extrafieldsinimport.inc.php' => ['PhanTypeMismatchArgumentNullableInternal'], - 'htdocs/core/filemanagerdol/connectors/php/connector.lib.php' => ['PhanPluginConstantVariableNull', 'PhanPluginUnknownArrayFunctionParamType', 'PhanTypeInvalidDimOffset'], - 'htdocs/core/lib/accounting.lib.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType'], 'htdocs/core/lib/admin.lib.php' => ['PhanUndeclaredProperty'], - 'htdocs/core/lib/agenda.lib.php' => ['PhanPluginConstantVariableNull', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/core/lib/ajax.lib.php' => ['PhanPluginUnknownArrayFunctionParamType'], - 'htdocs/core/lib/bank.lib.php' => ['PhanPluginEmptyStatementIf', 'PhanUndeclaredProperty'], - 'htdocs/core/lib/company.lib.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeInvalidDimOffset', 'PhanTypeMismatchProperty'], - 'htdocs/core/lib/customreports.lib.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanTypeMismatchDimFetch'], - 'htdocs/core/lib/date.lib.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal'], - 'htdocs/core/lib/doc.lib.php' => ['PhanPossiblyUndeclaredVariable'], + 'htdocs/core/lib/agenda.lib.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchArgumentReal'], + 'htdocs/core/lib/company.lib.php' => ['PhanTypeInvalidDimOffset'], + 'htdocs/core/lib/customreports.lib.php' => ['PhanTypeMismatchDimFetch', 'PhanUndeclaredProperty'], 'htdocs/core/lib/files.lib.php' => ['PhanUndeclaredProperty'], - 'htdocs/core/lib/ftp.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal'], 'htdocs/core/lib/functions2.lib.php' => ['PhanUndeclaredProperty'], - 'htdocs/core/lib/functionsnumtoword.lib.php' => ['PhanPossiblyUndeclaredVariable'], - 'htdocs/core/lib/geturl.lib.php' => ['PhanPluginConstantVariableNull', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanTypeMismatchArgumentNullableInternal'], - 'htdocs/core/lib/images.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal'], - 'htdocs/core/lib/invoice2.lib.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPossiblyUndeclaredVariable'], - 'htdocs/core/lib/loan.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'], - 'htdocs/core/lib/memory.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'], - 'htdocs/core/lib/oauth.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'], - 'htdocs/core/lib/payments.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'], - 'htdocs/core/lib/pdf.lib.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanUndeclaredProperty'], - 'htdocs/core/lib/price.lib.php' => ['PhanPluginSuspiciousParamPosition', 'PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanPossiblyUndeclaredVariable'], + 'htdocs/core/lib/images.lib.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal'], + 'htdocs/core/lib/pdf.lib.php' => ['PhanUndeclaredProperty'], 'htdocs/core/lib/project.lib.php' => ['PhanUndeclaredProperty'], - 'htdocs/core/lib/report.lib.php' => ['PhanPluginUnknownArrayFunctionParamType'], - 'htdocs/core/lib/security.lib.php' => ['PhanPluginUnknownArrayFunctionParamType'], - 'htdocs/core/lib/signature.lib.php' => ['PhanPossiblyUndeclaredVariable'], - 'htdocs/core/lib/treeview.lib.php' => ['PhanPluginUnknownArrayFunctionParamType'], 'htdocs/core/lib/xcal.lib.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPossiblyUndeclaredVariable', 'PhanUndeclaredProperty'], - 'htdocs/core/menus/standard/auguria.lib.php' => ['PhanTypeInvalidDimOffset'], 'htdocs/core/modules/action/doc/pdf_standard_actions.class.php' => ['PhanPluginUnknownArrayPropertyType'], 'htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/core/modules/asset/mod_asset_advanced.php' => ['PhanUndeclaredProperty'], @@ -357,7 +337,6 @@ return [ 'htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php' => ['PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], 'htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php' => ['PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], 'htdocs/core/modules/syslog/mod_syslog_file.php' => ['PhanPluginDuplicateArrayKey'], - 'htdocs/core/modules/syslog/mod_syslog_syslog.php' => ['PhanPluginConstantVariableNull', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable'], 'htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable'], 'htdocs/core/modules/workstation/mod_workstation_advanced.php' => ['PhanUndeclaredProperty'], @@ -393,7 +372,6 @@ return [ 'htdocs/cron/class/cronjob.class.php' => ['PhanPluginUnknownPropertyType'], 'htdocs/cron/list.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/datapolicy/class/datapolicycron.class.php' => ['PhanPluginUnknownPropertyType'], - 'htdocs/datapolicy/lib/datapolicy.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'], 'htdocs/debugbar/class/DataCollector/DolConfigCollector.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/debugbar/class/DataCollector/DolExceptionsCollector.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/debugbar/class/DataCollector/DolMemoryCollector.php' => ['PhanPluginUnknownArrayMethodReturnType'], @@ -536,7 +514,6 @@ return [ 'htdocs/loan/schedule.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/mailmanspip/class/mailmanspip.class.php' => ['PhanPluginUnknownArrayPropertyType'], 'htdocs/margin/customerMargins.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/margin/lib/margins.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'], 'htdocs/margin/productMargins.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/master.inc.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/mrp/class/api_mos.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'], @@ -551,7 +528,6 @@ return [ 'htdocs/opcachepreload.php' => ['PhanEmptyForeach'], 'htdocs/opensurvey/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/opensurvey/class/opensurveysondage.class.php' => ['PhanPluginUnknownPropertyType', 'PhanTypeMismatchProperty'], - 'htdocs/opensurvey/lib/opensurvey.lib.php' => ['PhanPluginUnknownArrayFunctionParamType'], 'htdocs/opensurvey/list.php' => ['PhanEmptyForeach', 'PhanPluginUndeclaredVariableIsset', 'PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/opensurvey/results.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredGlobalVariable'], 'htdocs/opensurvey/wizard/choix_date.php' => ['PhanPossiblyUndeclaredGlobalVariable'], @@ -562,7 +538,6 @@ return [ 'htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php' => ['PhanUndeclaredProperty'], 'htdocs/partnership/partnership_card.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/partnership/partnership_list.php' => ['PhanUndeclaredProperty'], - 'htdocs/paypal/lib/paypal.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'], 'htdocs/printing/index.php' => ['PhanUndeclaredProperty'], 'htdocs/product/admin/product.php' => ['PhanPluginEmptyStatementIf', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/product/ajax/products.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], @@ -653,11 +628,11 @@ return [ 'htdocs/public/payment/newpayment.php' => ['PhanUndeclaredProperty'], 'htdocs/public/payment/paymentko.php' => ['PhanPluginEmptyStatementIf', 'PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/public/payment/paymentok.php' => ['PhanPluginSuspiciousParamPosition', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'], - 'htdocs/public/project/index.php' => ['PhanRedefineFunction', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'], + 'htdocs/public/project/index.php' => ['PhanRedefineFunction', 'PhanUndeclaredGlobalVariable'], 'htdocs/public/project/new.php' => ['PhanRedefineFunction'], 'htdocs/public/project/suggestbooth.php' => ['PhanRedefineFunction', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/public/project/suggestconference.php' => ['PhanRedefineFunction', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], - 'htdocs/public/project/viewandvote.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'], + 'htdocs/public/project/viewandvote.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable'], 'htdocs/public/recruitment/view.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'], 'htdocs/public/stripe/ipn.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredGlobalVariable'], 'htdocs/public/test/test_arrays.php' => ['PhanPluginUndeclaredVariableIsset'], @@ -768,7 +743,7 @@ return [ 'htdocs/webhook/target_list.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/webportal/class/context.class.php' => ['PhanPluginUnknownArrayMethodParamType'], 'htdocs/webportal/class/controller.class.php' => ['PhanPluginUnknownArrayMethodParamType'], - 'htdocs/webportal/class/html.formcardwebportal.class.php' => ['PhanUndeclaredProperty'], + 'htdocs/webportal/class/html.formcardwebportal.class.php' => ['PhanPossiblyNullTypeMismatchProperty', 'PhanUndeclaredProperty'], 'htdocs/webportal/class/html.formlistwebportal.class.php' => ['PhanPluginUnknownArrayPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], 'htdocs/webportal/class/webportalpropal.class.php' => ['PhanUndeclaredProperty'], 'htdocs/webservices/server_actioncomm.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanUndeclaredProperty'], diff --git a/dev/tools/phan/config.php b/dev/tools/phan/config.php index 476b3a85580..c0d92b3a75d 100644 --- a/dev/tools/phan/config.php +++ b/dev/tools/phan/config.php @@ -272,6 +272,8 @@ return [ 'objectoffield' => '\CommonObject', 'objsoc' => '\Societe', 'senderissupplier' => 'int<0,2>', + 'shmkeys' => 'array', // memory.lib + 'shmoffset' => 'int', // memory.lib 'user' => '\User', 'website' => 'string', // See discussion https://github.com/Dolibarr/dolibarr/pull/28891#issuecomment-2002268334 // Disable because Phan infers Website type 'websitepage' => '\WebSitePage', diff --git a/htdocs/admin/menus/index.php b/htdocs/admin/menus/index.php index 0ad6f60a42f..a6730b18bfa 100644 --- a/htdocs/admin/menus/index.php +++ b/htdocs/admin/menus/index.php @@ -3,6 +3,7 @@ * Copyright (C) 2007-2012 Laurent Destailleur * Copyright (C) 2009-2012 Regis Houssin * Copyright (C) 2019 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 @@ -82,10 +83,10 @@ if ($action == 'up') { $i = 0; while ($i < $num) { $obj = $db->fetch_object($result); - $current['rowid'] = $obj->rowid; - $current['order'] = $obj->position; - $current['type'] = $obj->type; - $current['fk_menu'] = $obj->fk_menu; + $current['rowid'] = (int) $obj->rowid; + $current['order'] = (int) $obj->position; + $current['type'] = (string) $obj->type; + $current['fk_menu'] = (int) $obj->fk_menu; $i++; } @@ -104,8 +105,8 @@ if ($action == 'up') { $i = 0; while ($i < $num) { $obj = $db->fetch_object($result); - $previous['rowid'] = $obj->rowid; - $previous['order'] = $obj->position; + $previous['rowid'] = (int) $obj->rowid; + $previous['order'] = (int) $obj->position; $i++; } @@ -133,10 +134,10 @@ if ($action == 'up') { $i = 0; while ($i < $num) { $obj = $db->fetch_object($result); - $current['rowid'] = $obj->rowid; - $current['order'] = $obj->position; - $current['type'] = $obj->type; - $current['fk_menu'] = $obj->fk_menu; + $current['rowid'] = (int) $obj->rowid; + $current['order'] = (int) $obj->position; + $current['type'] = (string) $obj->type; + $current['fk_menu'] = (int) $obj->fk_menu; $i++; } @@ -155,8 +156,8 @@ if ($action == 'up') { $i = 0; while ($i < $num) { $obj = $db->fetch_object($result); - $next['rowid'] = $obj->rowid; - $next['order'] = $obj->position; + $next['rowid'] = (int) $obj->rowid; + $next['order'] = (int) $obj->position; $i++; } @@ -276,7 +277,7 @@ i.e.: data[]= array (index, parent index, string ) // First the root item of the tree must be declared: $data = array(); -$data[] = array('rowid' => 0, 'fk_menu' => -1, 'title' => "racine", 'mainmenu' => '', 'leftmenu' => '', 'fk_mainmenu' => '', 'fk_leftmenu' => ''); +$data[] = array('rowid' => 0, 'fk_menu' => -1, 'title' => 'racine', 'mainmenu' => '', 'leftmenu' => '', 'fk_mainmenu' => '', 'fk_leftmenu' => ''); // Then all child items must be declared @@ -316,15 +317,15 @@ if ($res) { $buttons .= ''.img_picto("Up", "1uparrow").''.img_picto("Down", "1downarrow").''; $data[] = array( - 'rowid' => $menu['rowid'], - 'module' => $menu['module'], - 'fk_menu' => $menu['fk_menu'], - 'title' => $titre, - 'mainmenu' => $menu['mainmenu'], - 'leftmenu' => $menu['leftmenu'], - 'fk_mainmenu' => $menu['fk_mainmenu'], - 'fk_leftmenu' => $menu['fk_leftmenu'], - 'position' => $menu['position'], + 'rowid' => (int) $menu['rowid'], + 'module' => (string) $menu['module'], + 'fk_menu' => (int) $menu['fk_menu'], + 'title' => (string) $titre, + 'mainmenu' => (string) $menu['mainmenu'], + 'leftmenu' => (string) $menu['leftmenu'], + 'fk_mainmenu' => (string) $menu['fk_mainmenu'], + 'fk_leftmenu' => (string) $menu['fk_leftmenu'], + 'position' => (int) $menu['position'], 'entry' => $entry, 'buttons' => $buttons ); diff --git a/htdocs/asterisk/wrapper.php b/htdocs/asterisk/wrapper.php index 77c75620ef0..4fee625fdae 100644 --- a/htdocs/asterisk/wrapper.php +++ b/htdocs/asterisk/wrapper.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -96,7 +97,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Security check if (!isModEnabled('clicktodial')) { accessforbidden(); - exit; } diff --git a/htdocs/bookcal/availabilities_card.php b/htdocs/bookcal/availabilities_card.php index c548901716b..52e411b40dc 100644 --- a/htdocs/bookcal/availabilities_card.php +++ b/htdocs/bookcal/availabilities_card.php @@ -247,7 +247,6 @@ llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-bookcal page-card_av if ($action == 'create') { if (empty($permissiontoadd)) { accessforbidden($langs->trans('NotEnoughPermissions'), 0, 1); - exit; } print load_fiche_titre($langs->trans("NewAvailabilities"), '', 'object_'.$object->picto); diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index 364292d9c11..0cef4cf08c3 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -6,6 +6,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2021 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 @@ -176,7 +177,7 @@ if (getDolGlobalString('CATEGORY_SHOW_COUNTS')) { // Define data (format for treeview) $data = array(); -$data[] = array('rowid'=>0, 'fk_menu'=>-1, 'title'=>"racine", 'mainmenu'=>'', 'leftmenu'=>'', 'fk_mainmenu'=>'', 'fk_leftmenu'=>''); +$data[] = array('rowid' => 0, 'fk_menu' => -1, 'title' => 'racine', 'mainmenu' => '', 'leftmenu' => '', 'fk_mainmenu' => '', 'fk_leftmenu' => ''); foreach ($fulltree as $key => $val) { $categstatic->id = $val['id']; $categstatic->ref = $val['label']; diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index a11f5309b1a..406e50122a3 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -416,7 +416,7 @@ if ($cats < 0) { // Define data (format for treeview) $data = array(); - $data[] = array('rowid' => 0, 'fk_menu' => -1, 'title' => "racine", 'mainmenu' => '', 'leftmenu' => '', 'fk_mainmenu' => '', 'fk_leftmenu' => ''); + $data[] = array('rowid' => 0, 'fk_menu' => -1, 'title' => 'racine', 'mainmenu' => '', 'leftmenu' => '', 'fk_mainmenu' => '', 'fk_leftmenu' => ''); foreach ($fulltree as $key => $val) { $categstatic->id = $val['id']; $categstatic->ref = $val['label']; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index c2a66d70ed2..50aa901eea3 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -773,14 +773,14 @@ class Propal extends CommonObject $this->line->product_type = $type; $this->line->fk_remise_except = $fk_remise_except; $this->line->remise_percent = $remise_percent; - $this->line->subprice = $pu_ht; + $this->line->subprice = (float) $pu_ht; $this->line->rang = $ranktouse; $this->line->info_bits = $info_bits; - $this->line->total_ht = $total_ht; - $this->line->total_tva = $total_tva; - $this->line->total_localtax1 = $total_localtax1; - $this->line->total_localtax2 = $total_localtax2; - $this->line->total_ttc = $total_ttc; + $this->line->total_ht = (float) $total_ht; + $this->line->total_tva = (float) $total_tva; + $this->line->total_localtax1 = (float) $total_localtax1; + $this->line->total_localtax2 = (float) $total_localtax2; + $this->line->total_ttc = (float) $total_ttc; $this->line->special_code = $special_code; $this->line->fk_parent_line = $fk_parent_line; $this->line->fk_unit = $fk_unit; @@ -797,10 +797,10 @@ class Propal extends CommonObject // Multicurrency $this->line->fk_multicurrency = $this->fk_multicurrency; $this->line->multicurrency_code = $this->multicurrency_code; - $this->line->multicurrency_subprice = $pu_ht_devise; - $this->line->multicurrency_total_ht = $multicurrency_total_ht; - $this->line->multicurrency_total_tva = $multicurrency_total_tva; - $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; + $this->line->multicurrency_subprice = (float) $pu_ht_devise; + $this->line->multicurrency_total_ht = (float) $multicurrency_total_ht; + $this->line->multicurrency_total_tva = (float) $multicurrency_total_tva; + $this->line->multicurrency_total_ttc = (float) $multicurrency_total_ttc; // Mise en option de la ligne if (empty($qty) && empty($special_code)) { @@ -989,14 +989,14 @@ class Propal extends CommonObject $this->line->localtax1_type = empty($localtaxes_type[0]) ? '' : $localtaxes_type[0]; $this->line->localtax2_type = empty($localtaxes_type[2]) ? '' : $localtaxes_type[2]; $this->line->remise_percent = $remise_percent; - $this->line->subprice = $pu_ht; + $this->line->subprice = (float) $pu_ht; $this->line->info_bits = $info_bits; - $this->line->total_ht = $total_ht; - $this->line->total_tva = $total_tva; - $this->line->total_localtax1 = $total_localtax1; - $this->line->total_localtax2 = $total_localtax2; - $this->line->total_ttc = $total_ttc; + $this->line->total_ht = (float) $total_ht; + $this->line->total_tva = (float) $total_tva; + $this->line->total_localtax1 = (float) $total_localtax1; + $this->line->total_localtax2 = (float) $total_localtax2; + $this->line->total_ttc = (float) $total_ttc; $this->line->special_code = $special_code; $this->line->fk_parent_line = $fk_parent_line; $this->line->skip_update_total = $skip_update_total; @@ -1016,10 +1016,10 @@ class Propal extends CommonObject } // Multicurrency - $this->line->multicurrency_subprice = $pu_ht_devise; - $this->line->multicurrency_total_ht = $multicurrency_total_ht; - $this->line->multicurrency_total_tva = $multicurrency_total_tva; - $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; + $this->line->multicurrency_subprice = (float) $pu_ht_devise; + $this->line->multicurrency_total_ht = (float) $multicurrency_total_ht; + $this->line->multicurrency_total_tva = (float) $multicurrency_total_tva; + $this->line->multicurrency_total_ttc = (float) $multicurrency_total_ttc; $result = $this->line->update($notrigger); if ($result > 0) { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 58aa8d1843f..2ee8d0153ed 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1697,14 +1697,14 @@ class Commande extends CommonOrder $this->line->product_type = $product_type; $this->line->fk_remise_except = $fk_remise_except; $this->line->remise_percent = $remise_percent; - $this->line->subprice = $pu_ht; + $this->line->subprice = (float) $pu_ht; $this->line->rang = $ranktouse; $this->line->info_bits = $info_bits; - $this->line->total_ht = $total_ht; - $this->line->total_tva = $total_tva; - $this->line->total_localtax1 = $total_localtax1; - $this->line->total_localtax2 = $total_localtax2; - $this->line->total_ttc = $total_ttc; + $this->line->total_ht = (float) $total_ht; + $this->line->total_tva = (float) $total_tva; + $this->line->total_localtax1 = (float) $total_localtax1; + $this->line->total_localtax2 = (float) $total_localtax2; + $this->line->total_ttc = (float) $total_ttc; $this->line->special_code = $special_code; $this->line->origin = $origin; $this->line->origin_id = $origin_id; @@ -1720,10 +1720,10 @@ class Commande extends CommonOrder // Multicurrency $this->line->fk_multicurrency = $this->fk_multicurrency; $this->line->multicurrency_code = $this->multicurrency_code; - $this->line->multicurrency_subprice = $pu_ht_devise; - $this->line->multicurrency_total_ht = $multicurrency_total_ht; - $this->line->multicurrency_total_tva = $multicurrency_total_tva; - $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; + $this->line->multicurrency_subprice = (float) $pu_ht_devise; + $this->line->multicurrency_total_ht = (float) $multicurrency_total_ht; + $this->line->multicurrency_total_tva = (float) $multicurrency_total_tva; + $this->line->multicurrency_total_ttc = (float) $multicurrency_total_ttc; // TODO Ne plus utiliser $this->line->price = $price; @@ -3278,14 +3278,14 @@ class Commande extends CommonOrder $this->line->localtax1_type = empty($localtaxes_type[0]) ? '' : $localtaxes_type[0]; $this->line->localtax2_type = empty($localtaxes_type[2]) ? '' : $localtaxes_type[2]; $this->line->remise_percent = $remise_percent; - $this->line->subprice = $pu_ht; + $this->line->subprice = (float) $pu_ht; $this->line->info_bits = $info_bits; $this->line->special_code = $special_code; - $this->line->total_ht = $total_ht; - $this->line->total_tva = $total_tva; - $this->line->total_localtax1 = $total_localtax1; - $this->line->total_localtax2 = $total_localtax2; - $this->line->total_ttc = $total_ttc; + $this->line->total_ht = (float) $total_ht; + $this->line->total_tva = (float) $total_tva; + $this->line->total_localtax1 = (float) $total_localtax1; + $this->line->total_localtax2 = (float) $total_localtax2; + $this->line->total_ttc = (float) $total_ttc; $this->line->date_start = $date_start; $this->line->date_end = $date_end; $this->line->product_type = $type; @@ -3297,10 +3297,10 @@ class Commande extends CommonOrder $this->line->pa_ht = $pa_ht; // Multicurrency - $this->line->multicurrency_subprice = $pu_ht_devise; - $this->line->multicurrency_total_ht = $multicurrency_total_ht; - $this->line->multicurrency_total_tva = $multicurrency_total_tva; - $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; + $this->line->multicurrency_subprice = (float) $pu_ht_devise; + $this->line->multicurrency_total_ht = (float) $multicurrency_total_ht; + $this->line->multicurrency_total_tva = (float) $multicurrency_total_tva; + $this->line->multicurrency_total_ttc = (float) $multicurrency_total_ttc; // TODO deprecated $this->line->price = $price; diff --git a/htdocs/compta/deplacement/stats/index.php b/htdocs/compta/deplacement/stats/index.php index 55b28a9102d..777b6530781 100644 --- a/htdocs/compta/deplacement/stats/index.php +++ b/htdocs/compta/deplacement/stats/index.php @@ -61,7 +61,6 @@ $childids[] = $user->id; if ($userid > 0) { if (!$user->hasRight('deplacement', 'readall') && !$user->hasRight('deplacement', 'lire_tous') && !in_array($userid, $childids)) { accessforbidden(); - exit; } } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index ee9fd7a7933..3dee298d143 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2006,14 +2006,14 @@ if (empty($reshook)) { // The $line->situation_percent has been modified, so we must recalculate all amounts $tabprice = calcul_price_total($line->qty, $line->subprice, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 0, 'HT', 0, $line->product_type, $mysoc, array(), $line->situation_percent); - $line->total_ht = $tabprice[0]; - $line->total_tva = $tabprice[1]; - $line->total_ttc = $tabprice[2]; - $line->total_localtax1 = $tabprice[9]; - $line->total_localtax2 = $tabprice[10]; - $line->multicurrency_total_ht = $tabprice[16]; - $line->multicurrency_total_tva = $tabprice[17]; - $line->multicurrency_total_ttc = $tabprice[18]; + $line->total_ht = (float) $tabprice[0]; + $line->total_tva = (float) $tabprice[1]; + $line->total_ttc = (float) $tabprice[2]; + $line->total_localtax1 = (float) $tabprice[9]; + $line->total_localtax2 = (float) $tabprice[10]; + $line->multicurrency_total_ht = (float) $tabprice[16]; + $line->multicurrency_total_tva = (float) $tabprice[17]; + $line->multicurrency_total_ttc = (float) $tabprice[18]; // If fk_remise_except defined we check if the reduction has already been applied if ($line->fk_remise_except) { diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 816077ab08a..2ed18a031d4 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -805,8 +805,8 @@ class FactureRec extends CommonInvoice $line->buyprice = $marginInfos[0]; $line->pa_ht = $marginInfos[0]; // For backward compatibility - $line->marge_tx = $marginInfos[1]; - $line->marque_tx = $marginInfos[2]; + $line->marge_tx = (string) $marginInfos[1]; + $line->marque_tx = (string) $marginInfos[2]; $line->rang = $objp->rang; $line->special_code = $objp->special_code; $line->fk_unit = $objp->fk_unit; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index d8467e9a810..89feb37dcfb 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2408,8 +2408,8 @@ class Facture extends CommonInvoice $line->fk_fournprice = $objp->fk_fournprice; $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); $line->pa_ht = $marginInfos[0]; - $line->marge_tx = $marginInfos[1]; - $line->marque_tx = $marginInfos[2]; + $line->marge_tx = (string) $marginInfos[1]; + $line->marque_tx = (string) $marginInfos[2]; $line->rang = $objp->rang; $line->special_code = $objp->special_code; $line->fk_parent_line = $objp->fk_parent_line; @@ -4022,8 +4022,8 @@ class Facture extends CommonInvoice $this->line->desc = $desc; $this->line->ref_ext = $ref_ext; - $this->line->qty = ($this->type == self::TYPE_CREDIT_NOTE ? abs((float) $qty) : $qty); // For credit note, quantity is always positive and unit price negative - $this->line->subprice = ($this->type == self::TYPE_CREDIT_NOTE ? -abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise + $this->line->qty = ($this->type == self::TYPE_CREDIT_NOTE ? abs((float) $qty) : (float) $qty); // For credit note, quantity is always positive and unit price negative + $this->line->subprice = ($this->type == self::TYPE_CREDIT_NOTE ? -abs((float) $pu_ht) : (float) $pu_ht); // For credit note, unit price always negative, always positive otherwise $this->line->vat_src_code = $vat_src_code; $this->line->tva_tx = $txtva; @@ -4032,11 +4032,11 @@ class Facture extends CommonInvoice $this->line->localtax1_type = empty($localtaxes_type[0]) ? 0 : $localtaxes_type[0]; $this->line->localtax2_type = empty($localtaxes_type[2]) ? 0 : $localtaxes_type[2]; - $this->line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_ht) : $total_ht); // For credit note and if qty is negative, total is negative - $this->line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_ttc) : $total_ttc); // For credit note and if qty is negative, total is negative - $this->line->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_tva) : $total_tva); // For credit note and if qty is negative, total is negative - $this->line->total_localtax1 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_localtax1) : $total_localtax1); // For credit note and if qty is negative, total is negative - $this->line->total_localtax2 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_localtax2) : $total_localtax2); // For credit note and if qty is negative, total is negative + $this->line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs((float) $total_ht) : (float) $total_ht); // For credit note and if qty is negative, total is negative + $this->line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs((float) $total_ttc) : (float) $total_ttc); // For credit note and if qty is negative, total is negative + $this->line->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs((float) $total_tva) : (float) $total_tva); // For credit note and if qty is negative, total is negative + $this->line->total_localtax1 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs((float) $total_localtax1) : (float) $total_localtax1); // For credit note and if qty is negative, total is negative + $this->line->total_localtax2 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs((float) $total_localtax2) : (float) $total_localtax2); // For credit note and if qty is negative, total is negative $this->line->fk_product = $fk_product; $this->line->product_type = $product_type; @@ -4063,11 +4063,11 @@ class Facture extends CommonInvoice // Multicurrency $this->line->fk_multicurrency = $this->fk_multicurrency; $this->line->multicurrency_code = $this->multicurrency_code; - $this->line->multicurrency_subprice = ($this->type == self::TYPE_CREDIT_NOTE ? -abs($pu_ht_devise) : $pu_ht_devise); // For credit note, unit price always negative, always positive otherwise + $this->line->multicurrency_subprice = ($this->type == self::TYPE_CREDIT_NOTE ? -abs((float) $pu_ht_devise) : (float) $pu_ht_devise); // For credit note, unit price always negative, always positive otherwise - $this->line->multicurrency_total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($multicurrency_total_ht) : $multicurrency_total_ht); // For credit note and if qty is negative, total is negative - $this->line->multicurrency_total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($multicurrency_total_tva) : $multicurrency_total_tva); // For credit note and if qty is negative, total is negative - $this->line->multicurrency_total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($multicurrency_total_ttc) : $multicurrency_total_ttc); // For credit note and if qty is negative, total is negative + $this->line->multicurrency_total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs((float) $multicurrency_total_ht) : (float) $multicurrency_total_ht); // For credit note and if qty is negative, total is negative + $this->line->multicurrency_total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs((float) $multicurrency_total_tva) : (float) $multicurrency_total_tva); // For credit note and if qty is negative, total is negative + $this->line->multicurrency_total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs((float) $multicurrency_total_ttc) : (float) $multicurrency_total_ttc); // For credit note and if qty is negative, total is negative if (is_array($array_options) && count($array_options) > 0) { $this->line->array_options = $array_options; @@ -4294,14 +4294,14 @@ class Facture extends CommonInvoice $this->line->localtax2_type = empty($localtaxes_type[2]) ? 0 : $localtaxes_type[2]; $this->line->remise_percent = $remise_percent; - $this->line->subprice = ($this->type == self::TYPE_CREDIT_NOTE ? -abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise + $this->line->subprice = ($this->type == self::TYPE_CREDIT_NOTE ? -abs((float) $pu_ht) : (float) $pu_ht); // For credit note, unit price always negative, always positive otherwise $this->line->date_start = $date_start; $this->line->date_end = $date_end; - $this->line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_ht) : $total_ht); // For credit note and if qty is negative, total is negative - $this->line->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_tva) : $total_tva); - $this->line->total_localtax1 = $total_localtax1; - $this->line->total_localtax2 = $total_localtax2; - $this->line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_ttc) : $total_ttc); + $this->line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs((float) $total_ht) : (float) $total_ht); // For credit note and if qty is negative, total is negative + $this->line->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs((float) $total_tva) : (float) $total_tva); + $this->line->total_localtax1 = (float) $total_localtax1; + $this->line->total_localtax2 = (float) $total_localtax2; + $this->line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs((float) $total_ttc) : (float) $total_ttc); $this->line->info_bits = $info_bits; $this->line->special_code = $special_code; $this->line->product_type = $type; @@ -4314,10 +4314,10 @@ class Facture extends CommonInvoice $this->line->pa_ht = $pa_ht; // Multicurrency - $this->line->multicurrency_subprice = ($this->type == self::TYPE_CREDIT_NOTE ? -abs($pu_ht_devise) : $pu_ht_devise); // For credit note, unit price always negative, always positive otherwise - $this->line->multicurrency_total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($multicurrency_total_ht) : $multicurrency_total_ht); // For credit note and if qty is negative, total is negative - $this->line->multicurrency_total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($multicurrency_total_tva) : $multicurrency_total_tva); - $this->line->multicurrency_total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($multicurrency_total_ttc) : $multicurrency_total_ttc); + $this->line->multicurrency_subprice = ($this->type == self::TYPE_CREDIT_NOTE ? -abs((float) $pu_ht_devise) : (float) $pu_ht_devise); // For credit note, unit price always negative, always positive otherwise + $this->line->multicurrency_total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs((float) $multicurrency_total_ht) : (float) $multicurrency_total_ht); // For credit note and if qty is negative, total is negative + $this->line->multicurrency_total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs((float) $multicurrency_total_tva) : (float) $multicurrency_total_tva); + $this->line->multicurrency_total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs((float) $multicurrency_total_ttc) : (float) $multicurrency_total_ttc); if (is_array($array_options) && count($array_options) > 0) { // We replace values in this->line->array_options only for entries defined into $array_options @@ -4410,14 +4410,14 @@ class Facture extends CommonInvoice $line->situation_percent = $percent; $tabprice = calcul_price_total($line->qty, $line->subprice, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 0, 'HT', 0, $line->product_type, $mysoc, array(), $percent); } - $line->total_ht = $tabprice[0]; - $line->total_tva = $tabprice[1]; - $line->total_ttc = $tabprice[2]; - $line->total_localtax1 = $tabprice[9]; - $line->total_localtax2 = $tabprice[10]; - $line->multicurrency_total_ht = $tabprice[16]; - $line->multicurrency_total_tva = $tabprice[17]; - $line->multicurrency_total_ttc = $tabprice[18]; + $line->total_ht = (float) $tabprice[0]; + $line->total_tva = (float) $tabprice[1]; + $line->total_ttc = (float) $tabprice[2]; + $line->total_localtax1 = (float) $tabprice[9]; + $line->total_localtax2 = (float) $tabprice[10]; + $line->multicurrency_total_ht = (float) $tabprice[16]; + $line->multicurrency_total_tva = (float) $tabprice[17]; + $line->multicurrency_total_ttc = (float) $tabprice[18]; $line->update($user); // sometimes it is better to not update price for each line, ie when updating situation on all lines diff --git a/htdocs/compta/facture/class/factureligne.class.php b/htdocs/compta/facture/class/factureligne.class.php index 356c1ab382d..585e3e11b7b 100644 --- a/htdocs/compta/facture/class/factureligne.class.php +++ b/htdocs/compta/facture/class/factureligne.class.php @@ -256,8 +256,8 @@ class FactureLigne extends CommonInvoiceLine $this->fk_fournprice = $objp->fk_fournprice; $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht); $this->pa_ht = $marginInfos[0]; - $this->marge_tx = $marginInfos[1]; - $this->marque_tx = $marginInfos[2]; + $this->marge_tx = (string) $marginInfos[1]; + $this->marque_tx = (string) $marginInfos[2]; $this->ref = $objp->product_ref; // deprecated diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php index 169e610eff4..ba4641fac79 100644 --- a/htdocs/compta/localtax/clients.php +++ b/htdocs/compta/localtax/clients.php @@ -113,7 +113,8 @@ $result = restrictedArea($user, 'tax', '', '', 'charges'); if (empty($local)) { accessforbidden('Parameter localTaxType is missing'); - exit; + // @phan-suppress-next-line PhanPluginUnreachableCode + exit; // accessforbidden already exits @phpstan-ignore-line } $calc = 0; diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index 6bf479a04e2..362f554d4ce 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -199,7 +199,8 @@ function pt($db, $sql, $date) if (empty($localTaxType)) { accessforbidden('Parameter localTaxType is missing'); - exit; + // @phan-suppress-next-line PhanPluginUnreachableCode + exit; // accessforbidden already exits @phpstan-ignore-line } diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php index 3a1dd1cc05b..6746bfe336e 100644 --- a/htdocs/compta/localtax/quadri_detail.php +++ b/htdocs/compta/localtax/quadri_detail.php @@ -121,7 +121,8 @@ $result = restrictedArea($user, 'tax', '', '', 'charges'); if (empty($local)) { accessforbidden('Parameter localTaxType is missing'); - exit; + // @phan-suppress-next-line PhanPluginUnreachableCode + exit; // accessforbidden already exits @phpstan-ignore-line } diff --git a/htdocs/contrat/class/contratligne.class.php b/htdocs/contrat/class/contratligne.class.php index 713497af42e..cf5b58f2397 100644 --- a/htdocs/contrat/class/contratligne.class.php +++ b/htdocs/contrat/class/contratligne.class.php @@ -672,11 +672,11 @@ class ContratLigne extends CommonObjectLine $localtaxes_type = getLocalTaxesFromRate($this->tva_tx, 0, $this->thirdparty, $mysoc); $tabprice = calcul_price_total($this->qty, $this->price_ht, $this->remise_percent, $this->tva_tx, $this->localtax1_tx, $this->localtax2_tx, 0, 'HT', 0, 1, $mysoc, $localtaxes_type); - $this->total_ht = $tabprice[0]; - $this->total_tva = $tabprice[1]; - $this->total_ttc = $tabprice[2]; - $this->total_localtax1 = $tabprice[9]; - $this->total_localtax2 = $tabprice[10]; + $this->total_ht = (float) $tabprice[0]; + $this->total_tva = (float) $tabprice[1]; + $this->total_ttc = (float) $tabprice[2]; + $this->total_localtax1 = (float) $tabprice[9]; + $this->total_localtax2 = (float) $tabprice[10]; if (empty($this->pa_ht)) { $this->pa_ht = 0; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 969d73913f2..f8f13945c5e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3954,7 +3954,7 @@ abstract class CommonObject $localtax_array = array($obj->localtax1_type, $obj->localtax1_tx, $obj->localtax2_type, $obj->localtax2_tx); $tmpcal = calcul_price_total($obj->qty, $obj->up, $obj->remise_percent, $obj->vatrate, $obj->localtax1_tx, $obj->localtax2_tx, 0, $base_price_type, $obj->info_bits, $obj->product_type, $seller, $localtax_array, (isset($obj->situation_percent) ? $obj->situation_percent : 100), $multicurrency_tx); - $diff_when_using_price_ht = price2num($tmpcal[1] - $obj->total_tva, 'MT', 1); // If price was set with tax price and unit price HT has a low number of digits, then we may have a diff on recalculation from unit price HT. + $diff_when_using_price_ht = price2num((float) $tmpcal[1] - $obj->total_tva, 'MT', 1); // If price was set with tax price and unit price HT has a low number of digits, then we may have a diff on recalculation from unit price HT. $diff_on_current_total = price2num($obj->total_ttc - $obj->total_ht - $obj->total_tva - $obj->total_localtax1 - $obj->total_localtax2, 'MT', 1); //var_dump($obj->total_ht.' '.$obj->total_tva.' '.$obj->total_localtax1.' '.$obj->total_localtax2.' => '.$obj->total_ttc); //var_dump($diff_when_using_price_ht.' '.$diff_on_current_total); diff --git a/htdocs/core/class/diasporahandler.class.php b/htdocs/core/class/diasporahandler.class.php index 13b9794af17..64ba5bbc9e3 100644 --- a/htdocs/core/class/diasporahandler.class.php +++ b/htdocs/core/class/diasporahandler.class.php @@ -120,7 +120,7 @@ class DiasporaHandler } } - $data = json_decode($data, true); + $data = json_decode((string) $data, true); if (!is_null($data)) { if (is_array($data)) { $this->posts = []; diff --git a/htdocs/core/filemanagerdol/connectors/php/connector.lib.php b/htdocs/core/filemanagerdol/connectors/php/connector.lib.php index 52ab28c9a12..3854d3f8b6e 100644 --- a/htdocs/core/filemanagerdol/connectors/php/connector.lib.php +++ b/htdocs/core/filemanagerdol/connectors/php/connector.lib.php @@ -87,7 +87,7 @@ function CreateXmlFooter() * * @param integer $number Number * @param string $text Text - * @return void + * @return never */ function SendError($number, $text) { @@ -293,18 +293,19 @@ function CreateFolder($resourceType, $currentFolder) * @param string $currentFolder Current folder * @param string $sCommand Command * @param string $CKEcallback Callback - * @return null + * @return never */ function FileUpload($resourceType, $currentFolder, $sCommand, $CKEcallback = '') { global $user; if (!isset($_FILES)) { - global $_FILES; + global $_FILES; // @phan-suppress-current-line PhanPluginConstantVariableNull } $sErrorNumber = '0'; $sFileName = ''; + // (_FILES indexes:) @phan-suppress-next-line PhanTypeInvalidDimOffset if (isset($_FILES['NewFile']) && !is_null($_FILES['NewFile']['tmp_name']) && !is_null($_FILES['NewFile']['name']) || (isset($_FILES['upload']) && !is_null($_FILES['upload']['tmp_name']) && !is_null($_FILES['upload']['name']))) { global $Config; @@ -638,7 +639,7 @@ function CreateServerFolder($folderPath, $lastFolder = null) function GetRootPath() { if (!isset($_SERVER)) { - global $_SERVER; + global $_SERVER; // @phan-suppress-current-line PhanPluginConstantVariableNull } $sRealPath = realpath('./'); // #2124 ensure that no slash is at the end @@ -816,7 +817,7 @@ function SanitizeFileName($sNewFileName) * @param string $fileUrl fileUrl * @param string $fileName fileName * @param string $customMsg customMsg - * @return void + * @return never */ function SendUploadResults($errorNumber, $fileUrl = '', $fileName = '', $customMsg = '') { @@ -936,8 +937,8 @@ function ConvertToXmlAttribute($value) /** * Check whether given extension is in html extensions list * - * @param string $ext Extension - * @param array $formExtensions Array of extensions + * @param string $ext Extension (Will only match if lowercase) + * @param string[] $formExtensions Array of extensions (Internally lowercased) * @return boolean */ function IsHtmlExtension($ext, $formExtensions) diff --git a/htdocs/core/filemanagerdol/connectors/php/connector.php b/htdocs/core/filemanagerdol/connectors/php/connector.php index 49b55f30b09..25d9312015f 100644 --- a/htdocs/core/filemanagerdol/connectors/php/connector.php +++ b/htdocs/core/filemanagerdol/connectors/php/connector.php @@ -2,6 +2,7 @@ /* * FCKeditor - The text editor for Internet - http://www.fckeditor.net * Copyright (C) 2003-2010 Frederico Caldeira Knabben + * Copyright (C) 2024 MDW * * == BEGIN LICENSE == * @@ -61,7 +62,8 @@ function DoResponse() // File Upload doesn't have to Return XML, so it must be intercepted before anything. if ($sCommand == 'FileUpload') { FileUpload($sResourceType, $sCurrentFolder, $sCommand); - return; + // @phan-suppress-next-line PhanPluginUnreachableCode + return; // FileUpload exits @phpstan-ignore-line } CreateXmlHeader($sCommand, $sResourceType, $sCurrentFolder); diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php index dbe0933d1cd..fdc2db376a9 100644 --- a/htdocs/core/lib/accounting.lib.php +++ b/htdocs/core/lib/accounting.lib.php @@ -176,10 +176,10 @@ function length_accounta($accounta) * @param string $description Description * @param integer $builddate Date of generation * @param string $exportlink Link for export or '' - * @param array $moreparam Array with list of params to add into hidden fields of form + * @param array $moreparam Array with list of params to add into hidden fields of form * @param string $calcmode Calculation mode * @param string $varlink Add a variable into the address of the page - * @param array $moreoptions Array with list of params to add to table + * @param array $moreoptions Array with list of params to add to table * @return void */ function journalHead($nom, $variant, $period, $periodlink, $description, $builddate, $exportlink = '', $moreparam = array(), $calcmode = '', $varlink = '', $moreoptions = array()) @@ -279,7 +279,7 @@ function journalHead($nom, $variant, $period, $periodlink, $description, $buildd /** * Return Default dates for transfer based on periodicity option in accountancy setup * - * @return array Dates of periodicity by default + * @return array{date_start:int,date_end:int,pastmonthyear:int,pastmonth:int} Dates of periodicity by default */ function getDefaultDatesForTransfer() { @@ -334,7 +334,6 @@ function getDefaultDatesForTransfer() $pastmonthyear--; } } - return array( 'date_start' => $date_start, 'date_end' => $date_end, @@ -348,10 +347,10 @@ function getDefaultDatesForTransfer() * * @param DoliDB $db Database handler * @param Conf $conf Config - * @param int $from_time [=null] Get current time or set time to find fiscal period - * @param mixed $gm 'gmt' => we return GMT timestamp (recommended), 'tzserver' => we return in the PHP server timezone + * @param ?int $from_time [=null] Get current time or set time to find fiscal period + * @param 'tzserver'|'gmt' $gm 'gmt' => we return GMT timestamp (recommended), 'tzserver' => we return in the PHP server timezone * @param int $withenddateonly Do not return period if and date is not defined - * @return array Period of fiscal year : [date_start, date_end] + * @return array{date_start:int,date_end:int} Period of fiscal year : [date_start, date_end] */ function getCurrentPeriodOfFiscalYear($db, $conf, $from_time = null, $gm = 'tzserver', $withenddateonly = 1) { diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index b63a6806d99..cb7d1654e0b 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -42,8 +42,8 @@ * @param int $pid Product id * @param int $socid Third party id * @param string $action Action string - * @param array|int $showextcals Array with list of external calendars (used to show links to select calendar), or -1 to show no legend - * @param string|array $actioncode Preselected value(s) of actioncode for filter on event type + * @param array|int<-1,-1> $showextcals Array with list of external calendars (used to show links to select calendar), or -1 to show no legend + * @param string|string[] $actioncode Preselected value(s) of actioncode for filter on event type * @param int $usergroupid Id of group to filter on users * @param string $excludetype A type to exclude ('systemauto', 'system', '') * @param int $resourceid Preselected value of resource for filter on resource @@ -110,7 +110,7 @@ function print_actions_filter( // Assigned to user group print '
'; print img_picto($langs->trans("ToUserOfGroup"), 'object_group', 'class="pictofixedwidth inline-block"'); - print $form->select_dolgroups($usergroupid, 'usergroup', 1, '', !$canedit, '', '', '0', false, 'minwidth100 maxwidth250 widthcentpercentminusx'); + print $form->select_dolgroups($usergroupid, 'usergroup', 1, '', !$canedit, '', array(), '0', false, 'minwidth100 maxwidth250 widthcentpercentminusx'); print '
'; if (isModEnabled('resource')) { @@ -120,7 +120,7 @@ function print_actions_filter( // Resource print '
'; print img_picto($langs->trans("Resource"), 'object_resource', 'class="pictofixedwidth inline-block"'); - print $formresource->select_resource_list($resourceid, "search_resourceid", [], 1, 0, 0, [], [], 2, 0, 'minwidth100 maxwidth250 widthcentpercentminusx'); + print $formresource->select_resource_list($resourceid, "search_resourceid", '', 1, 0, 0, [], '', 2, 0, 'minwidth100 maxwidth250 widthcentpercentminusx'); print '
'; } } @@ -128,7 +128,7 @@ function print_actions_filter( if (isModEnabled('societe') && $user->hasRight('societe', 'lire')) { print '
'; print img_picto($langs->trans("ThirdParty"), 'company', 'class="pictofixedwidth inline-block"'); - print $form->select_company($socid, 'search_socid', '', ' ', 0, 0, null, 0, 'minwidth100 maxwidth250 widthcentpercentminusx'); + print $form->select_company($socid, 'search_socid', '', ' ', 0, 0, array(), 0, 'minwidth100 maxwidth250 widthcentpercentminusx'); print '
'; } @@ -164,7 +164,7 @@ function print_actions_filter( // Hooks $parameters = array('canedit' => $canedit, 'pid' => $pid, 'socid' => $socid); - $object = null; + $object = null; // Null on purpose: @phan-suppress-next-line PhanPluginConstantVariableNull $reshook = $hookmanager->executeHooks('searchAgendaFrom', $parameters, $object, $action); // Note that $action and $object may have been print '
'; diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index f0c04ffa7b8..f573fa9360d 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -553,8 +553,8 @@ function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete = * Add event management script. * * @param string $htmlname Name of html select field ('myid' or '.myclass') - * @param array $events Add some Ajax events option on change of $htmlname component to call ajax to autofill a HTML element (select#htmlname and #inputautocompletehtmlname) - * Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) + * @param array}> $events Add some Ajax events option on change of $htmlname component to call ajax to autofill a HTML element (select#htmlname and #inputautocompletehtmlname) + * Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @return string Return JS string to manage event */ function ajax_event($htmlname, $events) @@ -626,14 +626,14 @@ function ajax_event($htmlname, $events) * On/off button for constant * * @param string $code Name of constant - * @param array $input Array of complementary actions to do if success ("disabled"|"enabled'|'set'|'del') => CSS element to switch, 'alert' => message to show, ... Example: array('disabled'=>array(0=>'cssid')) - * @param int|null $entity Entity. Current entity is used if null. - * @param int $revertonoff 1=Revert on/off - * @param int $strict 0=Default, 1=Only the complementary actions "disabled and "enabled" (found into $input) are processed. Use only "disabled" with delConstant and "enabled" with setConstant. + * @param array $input Array of complementary actions to do if success ("disabled"|"enabled'|'set'|'del') => CSS element to switch, 'alert' => message to show, ... Example: array('disabled'=>array(0=>'cssid')) + * @param ?int $entity Entity. Current entity is used if null. + * @param int<0,1> $revertonoff 1=Revert on/off + * @param int<0,1> $strict 0=Default, 1=Only the complementary actions "disabled and "enabled" (found into $input) are processed. Use only "disabled" with delConstant and "enabled" with setConstant. * @param int $forcereload Force to reload page if we click/change value (this is supported only when there is no 'alert' option in input) - * @param int $marginleftonlyshort 1 = Add a short left margin on picto, 2 = Add a larger left margin on picto, 0 = No left margin. - * @param int $forcenoajax 1 = Force to use a ahref link instead of ajax code. - * @param int $setzeroinsteadofdel 1 = Set constant to '0' instead of deleting it when $input is empty. + * @param int<0,2> $marginleftonlyshort 1 = Add a short left margin on picto, 2 = Add a larger left margin on picto, 0 = No left margin. + * @param int<0,1> $forcenoajax 1 = Force to use a ahref link instead of ajax code. + * @param int<0,1> $setzeroinsteadofdel 1 = Set constant to '0' instead of deleting it when $input is empty. * @param string $suffix Suffix to use on the name of the switch picto when option is on. Example: '', '_red' * @param string $mode Add parameter &mode= to the href link (Used for href link) * @param string $morecss More CSS @@ -722,7 +722,7 @@ function ajax_constantonoff($code, $input = array(), $entity = null, $revertonof * @param string $field Name of database field : 'tosell' or 'tobuy' for product by example * @param string $text_on Text if on ('Text' or 'Text:Picto on:Css picto on') * @param string $text_off Text if off ('Text' or 'Text:Picto off:Css picto off') - * @param array $input Array of type->list of CSS element to switch. Example: array('disabled'=>array(0=>'cssid')) + * @param array $input Array of type->list of CSS element to switch. Example: array('disabled'=>array(0=>'cssid')) * @param string $morecss More CSS * @param string $htmlname Name of HTML component. Keep '' or use a different value if you need to use this component several time on the same page for the same field. * @param int $forcenojs Force the component to work as link post (without javascript) instead of ajax call diff --git a/htdocs/core/lib/bank.lib.php b/htdocs/core/lib/bank.lib.php index 9edb9f58e52..787ae745949 100644 --- a/htdocs/core/lib/bank.lib.php +++ b/htdocs/core/lib/bank.lib.php @@ -342,7 +342,7 @@ function getIbanHumanReadable(Account $account) /** * Check account number information for a bank account * - * @param Account $account A bank account + * @param Account|CompanyBankAccount $account A bank account * @return boolean True if information are valid, false otherwise */ function checkBanForAccount($account) @@ -353,7 +353,7 @@ function checkBanForAccount($account) // account of type CompanyBankAccount class (we use number, cle_rib) // account of type Account class (we use num_compte, cle) if (empty($account->number)) { - $account->number = $account->num_compte; + $account->number = $account->num_compte; // @phan-suppress-current-line PhanUndeclaredProperty } if (empty($account->cle)) { $account->cle = $account->cle_rib; @@ -383,8 +383,10 @@ function checkBanForAccount($account) return false; } - if ($country_code == 'BE') { // Belgium rules + /* + if ($country_code == 'BE') { // Belgian rules } + */ if ($country_code == 'ES') { // Spanish rules $CCC = strtolower(trim($account->number)); diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 774a92c47f0..733e454e193 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -198,8 +198,8 @@ function societe_prepare_head(Societe $object) $title = $langs->trans("PaymentModes"); + $servicestatus = 0; if (isModEnabled('stripe')) { - $servicestatus = 0; if (getDolGlobalString('STRIPE_LIVE') && !GETPOST('forcesandbox', 'alpha')) { $servicestatus = 1; } @@ -805,7 +805,7 @@ function getFormeJuridiqueLabel($code) * Return list of countries that are inside the EEC (European Economic Community) * Note: Try to keep this function as a "memory only" function for performance reasons. * - * @return array Array of countries code in EEC + * @return string[] Array of countries code in EEC */ function getCountriesInEEC() { @@ -1745,7 +1745,7 @@ function show_actions_todo($conf, $langs, $db, $filterobj, $objcon = null, $nopr * @param int<0,1> $noprint Return string but does not output it * @param string|string[] $actioncode Filter on actioncode * @param 'done'|'todo'|'' $donetodo Filter on event 'done' or 'todo' or ''=nofilter (all). - * @param array $filters Filter on other fields + * @param array $filters Filter on other fields * @param string $sortfield Sort field * @param string $sortorder Sort order * @param string $module You can add module name here if elementtype in table llx_actioncomm is objectkey@module @@ -1889,7 +1889,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr } elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') { $sql .= ", ".MAIN_DB_PREFIX."contrat as o"; } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) - && ((!empty($filterobj->fields['ref']) && is_array($filterobj->fields['ref'])) || (!empty($filterobj->fields['label']) && is_array($filterobj->fields['label'])) || (!empty($filterobj->fields['titre']) && is_array($filterobj->fields['titre']))) + && ((!empty($filterobj->fields['ref']) && is_array($filterobj->fields['ref'])) || (!empty($filterobj->fields['label']) && is_array($filterobj->fields['label'])) || (!empty($filterobj->fields['titre']) && is_array($filterobj->fields['titre']))) // @phan-suppress-curren-line PhanTypeInvalidDimOffset && $filterobj->table_element && $filterobj->element) { $sql .= ", ".MAIN_DB_PREFIX.$filterobj->table_element." as o"; } @@ -1948,7 +1948,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr $sql .= " AND a.fk_element = ".((int) $filterobj->id); } } elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) - && ((!empty($filterobj->fields['ref']) && is_array($filterobj->fields['ref'])) || (!empty($filterobj->fields['label']) && is_array($filterobj->fields['label'])) || (!empty($filterobj->fields['titre']) && is_array($filterobj->fields['titre']))) + && ((!empty($filterobj->fields['ref']) && is_array($filterobj->fields['ref'])) || (!empty($filterobj->fields['label']) && is_array($filterobj->fields['label'])) || (!empty($filterobj->fields['titre']) && is_array($filterobj->fields['titre']))) // ref, titre, label do not exist on $fields - @phan-suppress-current-line PhanTypeInvalidDimOffset && $filterobj->table_element && $filterobj->element) { // Generic case (if there is a $filterobj and a field rowid and (ref or label) exists. $sql .= " AND a.fk_element = o.rowid AND a.elementtype = '".$db->escape($filterobj->element).($module ? "@".$module : "")."'"; @@ -2069,23 +2069,23 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr $histo[$numaction] = array( 'type' => $obj->type, 'tododone' => $tododone, - 'id' => $obj->id, + 'id' => (int) $obj->id, 'datestart' => $db->jdate($obj->dp), 'dateend' => $db->jdate($obj->dp2), 'note' => $obj->label, - 'percent' => $obj->percent, + 'percent' => (int) $obj->percent, - 'userid' => $obj->user_id, + 'userid' => (int) $obj->user_id, 'login' => $obj->user_login, 'userfirstname' => $obj->user_firstname, 'userlastname' => $obj->user_lastname, 'userphoto' => $obj->user_photo, - 'contact_id' => $obj->fk_contact, + 'contact_id' => (int) $obj->fk_contact, 'socpeopleassigned' => $contactaction->socpeopleassigned, 'lastname' => empty($obj->lastname) ? '' : $obj->lastname, 'firstname' => empty($obj->firstname) ? '' : $obj->firstname, - 'fk_element' => $obj->fk_element, + 'fk_element' => (int) $obj->fk_element, 'elementtype' => $obj->elementtype, // Type of event 'acode' => $obj->acode, @@ -2097,14 +2097,14 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr $histo[$numaction] = array( 'type' => $obj->type, 'tododone' => 'done', - 'id' => $obj->id, + 'id' => (int) $obj->id, 'datestart' => $db->jdate($obj->dp), 'dateend' => $db->jdate($obj->dp2), 'note' => $obj->label, - 'percent' => $obj->percent, + 'percent' => (int) $obj->percent, 'acode' => $obj->acode, - 'userid' => $obj->user_id, + 'userid' => (int) $obj->user_id, 'login' => $obj->user_login, 'userfirstname' => $obj->user_firstname, 'userlastname' => $obj->user_lastname, @@ -2120,7 +2120,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr } } - '@phan-var-force array,datestart:int,dateend:int,fk_element:string,elementtype:string,contact_id:string,lastname:string,firstname:string,contact_photo:string,socpeaopleassigned:int[],login:string,userfirstname:string,userlastname:string,userphoto:string}> $histo'; + '@phan-var-force array,datestart:int,dateend:int,fk_element:string,elementtype:string,contact_id:int,lastname:string,firstname:string,contact_photo:string,socpeopleassigned:int[],login:string,userfirstname:string,userlastname:string,userphoto:string}> $histo'; if (isModEnabled('agenda') || (isModEnabled('mailing') && !empty($objcon->email))) { $delay_warning = getDolGlobalInt('MAIN_DELAY_ACTIONS_TODO') * 24 * 60 * 60; @@ -2565,7 +2565,7 @@ function addEventTypeSQL(&$sql, $actioncode, $sqlANDOR = "AND") * @param string $sql $sql modified * @param string $donetodo donetodo * @param int $now now - * @param array $filters array + * @param array $filters array * @return string sql request */ function addOtherFilterSQL(&$sql, $donetodo, $now, $filters) @@ -2637,7 +2637,7 @@ function addMailingEventTypeSQL($actioncode, $objcon, $filterobj) * @param Translate $langs Output language * @param int $addformmessage Add the payment form message * @param string $suffix Suffix to use on constants - * @param Object $object Object related to payment + * @param null|CommonObject|CommonHookActions $object Object related to payment * @return void */ function htmlPrintOnlineFooter($fromcompany, $langs, $addformmessage = 0, $suffix = '', $object = null) diff --git a/htdocs/core/lib/customreports.lib.php b/htdocs/core/lib/customreports.lib.php index b97e888354b..a2f39247d95 100644 --- a/htdocs/core/lib/customreports.lib.php +++ b/htdocs/core/lib/customreports.lib.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,11 +29,11 @@ * @param mixed $object Any object * @param string $tablealias Alias of table * @param string $labelofobject Label of object - * @param array $arrayofmesures Array of measures already filled + * @param array $arrayofmesures Array of measures already filled * @param int $level Level * @param int $count Count * @param string $tablepath Path of all tables ('t' or 't,contract' or 't,contract,societe'...) - * @return array Array of measures + * @return array Array of measures */ function fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesures, $level = 0, &$count = 0, &$tablepath = '') { @@ -182,11 +183,11 @@ function fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesu * @param mixed $object Any object * @param string $tablealias Alias of table ('t' for example) * @param string $labelofobject Label of object - * @param array $arrayofxaxis Array of xaxis already filled + * @param array $arrayofxaxis Array of xaxis already filled * @param int $level Level * @param int $count Count * @param string $tablepath Path of all tables ('t' or 't,contract' or 't,contract,societe'...) - * @return array Array of xaxis + * @return array Array of xaxis */ function fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis, $level = 0, &$count = 0, &$tablepath = '') { @@ -346,16 +347,16 @@ function fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis, /** - * Fill arrayofgrupby for an object + * Fill arrayofgroupby for an object * - * @param mixed $object Any object + * @param CommonObject $object Any object * @param string $tablealias Alias of table * @param string $labelofobject Label of object - * @param array $arrayofgroupby Array of groupby already filled + * @param array $arrayofgroupby Array of groupby already filled * @param int $level Level * @param int $count Count * @param string $tablepath Path of all tables ('t' or 't,contract' or 't,contract,societe'...) - * @return array Array of groupby + * @return array Array of groupby */ function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroupby, $level = 0, &$count = 0, &$tablepath = '') { @@ -469,7 +470,7 @@ function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroup 'tablefromt' => $tablepath ); $arrayofgroupby[preg_replace('/^t/', 'te', $tablealias).'.'.$key.'-day'] = array( - 'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val).' ('.$YYYY.'-'.$MM.'-'.$DD.')', + 'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val).' ('.$YYYY.'-'.$MM.'-'.$DD.')', // @phan-suppress-current-line PhanUndeclaredProperty 'labelnohtml' => $labelofobject.': '.$langs->trans($val), 'position' => ($position + ($count * 100000)).'.3', 'table' => $object->table_element, @@ -477,7 +478,7 @@ function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroup ); } else { $arrayofgroupby[preg_replace('/^t/', 'te', $tablealias).'.'.$key] = array( - 'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val), + 'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val), // @phan-suppress-current-line PhanUndeclaredProperty 'labelnohtml' => $labelofobject.': '.$langs->trans($val), 'position' => 1000 + (int) $extrafields->attributes[$object->table_element]['pos'][$key] + ($count * 100000), 'table' => $object->table_element, @@ -513,14 +514,14 @@ function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroup /** * Fill array of possible filter fields for an object * - * @param mixed $object Any object + * @param CommonObject $object Any object * @param string $tablealias Alias of table ('t' for example) * @param string $labelofobject Label of object - * @param array $arrayoffields Array of fields already filled + * @param array $arrayoffields Array of fields already filled * @param int $level Level * @param int $count Count * @param string $tablepath Path of all tables ('t' or 't,contract' or 't,contract,societe'...) - * @return array Array of fields + * @return array Array of fields */ function fillArrayOfFilterFields($object, $tablealias, $labelofobject, &$arrayoffields, $level = 0, &$count = 0, &$tablepath = '') { @@ -588,12 +589,12 @@ function fillArrayOfFilterFields($object, $tablealias, $labelofobject, &$arrayof } $arrayoffields[preg_replace('/^t/', 'te', $tablealias).'.'.$key] = array( - 'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val), + 'label' => img_picto('', (empty($object->picto) ? 'generic' : $object->picto), 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val), // @phan-suppress-current-line PhanUndeclaredProperty 'labelnohtml' => $labelofobject.': '.$langs->trans($val), 'position' => 1000 + (int) $extrafields->attributes[$object->table_element]['pos'][$key] + ($count * 100000), 'table' => $object->table_element, 'tablefromt' => $tablepath, - 'type' => $val['type'] + 'type' => $val['type'] // TODO: Check this, seems a copy/paste error ); } } diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 54d3cdee980..278b782ed4a 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -118,7 +118,7 @@ function getServerTimeZoneInt($refgmtdate = 'now') * @param int|string $time Date timestamp (or string with format YYYY-MM-DD) * @param float $duration_value Value of delay to add * @param string $duration_unit Unit of added delay (d, m, y, w, h, i) - * @param int $ruleforendofmonth Change the behavior of PHP over data-interval, 0 or 1 + * @param int<0,1> $ruleforendofmonth Change the behavior of PHP over data-interval, 0 or 1 * @return int New timestamp * @see convertSecondToTime(), convertTimeToSeconds() */ @@ -142,6 +142,8 @@ function dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforend $deltastring = 'P'; + $sub = false; + if ($duration_value > 0) { $deltastring .= abs($duration_value); $sub = false; @@ -221,20 +223,20 @@ function convertTime2Seconds($iHours = 0, $iMinutes = 0, $iSeconds = 0) * Can be used to show a duration. * * @param int $iSecond Number of seconds - * @param string $format Output format - * - 'all': total delay days hour:min like "2 days 12:30", - * - 'allwithouthour': total delay days without hour part like "2 days", - * - 'allhourmin': total delay with format hours:min like "60:30", - * - 'allhourminsec': total delay with format hours:min:sec like "60:30:10", - * - 'allhour': total delay hours without min/sec like "60:30", - * - 'fullhour': total delay hour decimal like "60.5" for 60:30, - * - 'hour': only hours part "12", - * - 'min': only minutes part "30", - * - 'sec': only seconds part, - * - 'month': only month part, - * - 'year': only year part); - * @param int $lengthOfDay Length of day (default 86400 seconds for 1 day, 28800 for 8 hour) - * @param int $lengthOfWeek Length of week (default 7) + * @param 'all'|'allwithouthour'|'allhourmin'|'allhourminsec'|'allhour'|'fullhour'|'hour'|'min'|'sec'|'month'|'year' $format Output format + * - 'all': total delay days hour:min like "2 days 12:30", + * - 'allwithouthour': total delay days without hour part like "2 days", + * - 'allhourmin': total delay with format hours:min like "60:30", + * - 'allhourminsec': total delay with format hours:min:sec like "60:30:10", + * - 'allhour': total delay hours without min/sec like "60:30", + * - 'fullhour': total delay hour decimal like "60.5" for 60:30, + * - 'hour': only hours part "12", + * - 'min': only minutes part "30", + * - 'sec': only seconds part, + * - 'month': only month part, + * - 'year': only year part); + * @param int<1,86400> $lengthOfDay Length of day (default 86400 seconds for 1 day, 28800 for 8 hour) + * @param int<1,7> $lengthOfWeek Length of week (default 7) * @return string Formatted text of duration * Example: 0 return 00:00, 3600 return 1:00, 86400 return 1d, 90000 return 1 Day 01:00 * @see convertTime2Seconds() @@ -251,12 +253,13 @@ function convertSecondToTime($iSecond, $format = 'all', $lengthOfDay = 86400, $l } $nbHbyDay = $lengthOfDay / 3600; + $sTime = ''; + if ($format == 'all' || $format == 'allwithouthour' || $format == 'allhour' || $format == 'allhourmin' || $format == 'allhourminsec') { if ((int) $iSecond === 0) { return '0'; // This is to avoid having 0 return a 12:00 AM for en_US } - $sTime = ''; $sDay = 0; $sWeek = 0; @@ -321,7 +324,7 @@ function convertSecondToTime($iSecond, $format = 'all', $lengthOfDay = 86400, $l } elseif ($format == 'year') { // only year part $sTime = dol_print_date($iSecond, '%Y', true); } - return trim($sTime); + return trim((string) $sTime); } diff --git a/htdocs/core/lib/doc.lib.php b/htdocs/core/lib/doc.lib.php index 1e2c1090c8b..e7ead77d997 100644 --- a/htdocs/core/lib/doc.lib.php +++ b/htdocs/core/lib/doc.lib.php @@ -5,6 +5,7 @@ * Copyright (C) 2010-2012 Regis Houssin * Copyright (C) 2010 Juanjo Menent * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -136,6 +137,7 @@ function doc_getlinedesc($line, $outputlangs, $hideref = 0, $hidedesc = 0, $issu if (!empty($line->date_start) || !empty($line->date_end)) { $format = 'day'; + $period = ''; // Show duration if exists if ($line->date_start && $line->date_end) { $period = '('.$outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($line->date_start, $format, false, $outputlangs), dol_print_date($line->date_end, $format, false, $outputlangs)).')'; diff --git a/htdocs/core/lib/ftp.lib.php b/htdocs/core/lib/ftp.lib.php index 245953cec8f..e071b2c0de5 100644 --- a/htdocs/core/lib/ftp.lib.php +++ b/htdocs/core/lib/ftp.lib.php @@ -34,7 +34,7 @@ * @param string $ftp_password FTP password * @param string $section Directory * @param integer $ftp_passive Use a passive mode - * @return array Result of connect + * @return array{conn_id:false|null|resource,ok:int<0,1>,mesg:string,curdir:string,curdiriso:string} Result of connect */ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $section, $ftp_passive = 0) { @@ -53,6 +53,7 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect if ($ok) { $connecttimeout = (!getDolGlobalString('FTP_CONNECT_TIMEOUT') ? 40 : $conf->global->FTP_CONNECT_TIMEOUT); + $tmp_conn_id = 0; if (getDolGlobalString('FTP_CONNECT_WITH_SFTP')) { dol_syslog('Try to connect with ssh2_connect'); $tmp_conn_id = ssh2_connect($ftp_server, (int) $ftp_port); @@ -67,7 +68,7 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect if ($ftp_user) { if (getDolGlobalString('FTP_CONNECT_WITH_SFTP')) { dol_syslog('Try to authenticate with ssh2_auth_password'); - if (ssh2_auth_password($tmp_conn_id, $ftp_user, $ftp_password)) { + if (!empty($tmp_conn_id) && ssh2_auth_password($tmp_conn_id, $ftp_user, $ftp_password)) { // Turn on passive mode transfers (must be after a successful login //if ($ftp_passive) ftp_pasv($connect_id, true); @@ -88,7 +89,7 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect $error++; } } else { - if (ftp_login($connect_id, $ftp_user, $ftp_password)) { + if (!empty($connect_id) && ftp_login($connect_id, $ftp_user, $ftp_password)) { // Turn on passive mode transfers (must be after a successful login) if ($ftp_passive) { ftp_pasv($connect_id, true); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 120d6c00bb1..541d413db1f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -789,7 +789,7 @@ function GETPOSTISARRAY($paramname, $method = 0) * @param ?int $filter Filter to apply when $check is set to 'custom'. (See http://php.net/manual/en/filter.filters.php for détails) * @param mixed $options Options to pass to filter_var when $check is set to 'custom' * @param int $noreplace Force disable of replacement of __xxx__ strings. - * @return string|array Value found (string or array), or '' if check fails + * @return string|array Value found (string or array), or '' if check fails */ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null, $options = null, $noreplace = 0) { @@ -1176,11 +1176,11 @@ function GETPOSTDATE($prefix, $hourTime = '', $gm = 'auto') * Return a sanitized or empty value after checking value against a rule. * * @deprecated - * @param string|array $out Value to check/clear. - * @param string $check Type of check/sanitizing - * @param int $filter Filter to apply when $check is set to 'custom'. (See http://php.net/manual/en/filter.filters.php for détails) - * @param mixed $options Options to pass to filter_var when $check is set to 'custom' - * @return string|array Value sanitized (string or array). It may be '' if format check fails. + * @param string|array $out Value to check/clear. + * @param string $check Type of check/sanitizing + * @param ?int $filter Filter to apply when $check is set to 'custom'. (See http://php.net/manual/en/filter.filters.php for détails) + * @param ?mixed $options Options to pass to filter_var when $check is set to 'custom' + * @return string|array Value sanitized (string or array). It may be '' if format check fails. */ function checkVal($out = '', $check = 'alphanohtml', $filter = null, $options = null) { @@ -1190,11 +1190,11 @@ function checkVal($out = '', $check = 'alphanohtml', $filter = null, $options = /** * Return a sanitized or empty value after checking value against a rule. * - * @param string|array $out Value to check/clear. + * @param string|array $out Value to check/clear. * @param string $check Type of check/sanitizing - * @param int $filter Filter to apply when $check is set to 'custom'. (See http://php.net/manual/en/filter.filters.php for détails) - * @param mixed $options Options to pass to filter_var when $check is set to 'custom' - * @return string|array Value sanitized (string or array). It may be '' if format check fails. + * @param ?int $filter Filter to apply when $check is set to 'custom'. (See http://php.net/manual/en/filter.filters.php for détails) + * @param ?mixed $options Options to pass to filter_var when $check is set to 'custom' + * @return string|array Value sanitized (string or array). It may be '' if format check fails. */ function sanitizeVal($out = '', $check = 'alphanohtml', $filter = null, $options = null) { @@ -1802,9 +1802,9 @@ function dol_string_unaccent($str) * * @param string $str String to clean * @param string $newstr String to replace forbidden chars with - * @param array|string $badcharstoreplace Array of forbidden characters to replace. Use '' to keep default list. - * @param array|string $badcharstoremove Array of forbidden characters to remove. Use '' to keep default list. - * @param int $keepspaces 1=Do not treat space as a special char to replace or remove + * @param string[]|string $badcharstoreplace Array of forbidden characters to replace. Use '' to keep default list. + * @param string[]|string $badcharstoremove Array of forbidden characters to remove. Use '' to keep default list. + * @param int<0,1> $keepspaces 1=Do not treat space as a special char to replace or remove * @return string Cleaned string * * @see dol_sanitizeFilename(), dol_string_unaccent(), dol_string_nounprintableascii() @@ -2240,13 +2240,13 @@ function getCallerInfoString() * This must not use any call to other function calling dol_syslog (avoid infinite loop). * * @param string $message Line to log. ''=Show nothing - * @param int $level Log level + * @param int<0,7> $level Log level * On Windows LOG_ERR=4, LOG_WARNING=5, LOG_NOTICE=LOG_INFO=6, LOG_DEBUG=6 if define_syslog_variables ou PHP 5.3+, 7 if dolibarr * On Linux LOG_ERR=3, LOG_WARNING=4, LOG_NOTICE=5, LOG_INFO=6, LOG_DEBUG=7 - * @param int $ident 1=Increase ident of 1 (after log), -1=Decrease ident of 1 (before log) + * @param int<-1,1> $ident 1=Increase ident of 1 (after log), -1=Decrease ident of 1 (before log) * @param string $suffixinfilename When output is a file, append this suffix into default log filename. Example '_stripe', '_mail' * @param string $restricttologhandler Force output of log only to this log handler - * @param array|null $logcontext If defined, an array with extra information (can be used by some log handlers) + * @param ?array $logcontext If defined, an array with extra information (can be used by some log handlers) * @return void * @phan-suppress PhanPluginUnknownArrayFunctionParamType $logcontext is not defined in detail */ @@ -8239,9 +8239,9 @@ function dol_string_onlythesehtmlattributes($stringtoclean, $allowed_attributes * Clean a string from some undesirable HTML tags. * Note: You should use instead dol_string_onlythesehtmltags() that is more secured if you can. * - * @param string $stringtoclean String to clean - * @param array $disallowed_tags Array of tags not allowed - * @param int $cleanalsosomestyles Clean also some tags + * @param string $stringtoclean String to clean + * @param string[] $disallowed_tags Array of tags not allowed + * @param int<0,1> $cleanalsosomestyles Clean also some tags * @return string String cleaned * * @see dol_escape_htmltag() strip_tags() dol_string_nohtmltag() dol_string_onlythesehtmltags() dol_string_onlythesehtmlattributes() diff --git a/htdocs/core/lib/functionsnumtoword.lib.php b/htdocs/core/lib/functionsnumtoword.lib.php index 7c7ace312da..967644efaaf 100644 --- a/htdocs/core/lib/functionsnumtoword.lib.php +++ b/htdocs/core/lib/functionsnumtoword.lib.php @@ -172,6 +172,7 @@ function dolNumberToWord($numero, $langs, $numorcurrency = 'number') // Get 2 decimals to cents, another functions round or truncate $strnumber = number_format($numero, 10); $len = strlen($strnumber); + $parte_decimal = '00'; // For static analysis, strnumber should contain '.' for ($i = 0; $i < $len; $i++) { if ($strnumber[$i] == '.') { $parte_decimal = $strnumber[$i + 1].$strnumber[$i + 2]; @@ -179,8 +180,7 @@ function dolNumberToWord($numero, $langs, $numorcurrency = 'number') } } - /*In dolibarr 3.6.2 (my current version) doesn't have $langs->default and - in case exist why ask $lang like a parameter?*/ + /* Dolibarr 3.6.2 doesn't have $langs->default, why ask $lang like a parameter in case it exists? */ if (((is_object($langs) && $langs->getDefaultLang(0) == 'es_MX') || (!is_object($langs) && $langs == 'es_MX')) && $numorcurrency == 'currency') { if ($numero >= 1 && $numero < 2) { return ("UN PESO ".$parte_decimal." / 100 M.N."); @@ -202,6 +202,10 @@ function dolNumberToWord($numero, $langs, $numorcurrency = 'number') $numero -= $UdMMillon * 1000000000; $entexto .= hundreds2text($CdMMillon, $DdMMillon, $UdMMillon); $entexto .= " MIL "; + } else { + $CdMMillon = 0; + $DdMMillon = 0; + $UdMMillon = 0; } if ($number >= 1000000) { $CdMILLON = (int) ($numero / 100000000); @@ -217,6 +221,7 @@ function dolNumberToWord($numero, $langs, $numorcurrency = 'number') $entexto .= " MILLONES "; } } + if ($number >= 1000) { $cdm = (int) ($numero / 100000); $numero -= $cdm * 100000; @@ -228,6 +233,10 @@ function dolNumberToWord($numero, $langs, $numorcurrency = 'number') if ($cdm || $ddm || $udm) { $entexto .= " MIL "; } + } else { + $ddm = 0; + $cdm = 0; + $udm = 0; } $c = (int) ($numero / 100); $numero -= $c * 100; diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index 7eb5d57d502..c25b095df08 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -30,14 +30,14 @@ * - common local lookup ips like 127.*.*.* are automatically added * * @param string $url URL to call. - * @param string $postorget 'POST', 'GET', 'HEAD', 'PUT', 'PUTALREADYFORMATED', 'POSTALREADYFORMATED', 'DELETE' + * @param 'POST'|'GET'|'HEAD'|'PUT'|'PUTALREADYFORMATED'|'POSTALREADYFORMATED'|'DELETE' $postorget 'POST', 'GET', 'HEAD', 'PUT', 'PUTALREADYFORMATED', 'POSTALREADYFORMATED', 'DELETE' * @param string $param Parameters of URL (x=value1&y=value2) or may be a formatted content with $postorget='PUTALREADYFORMATED' - * @param integer $followlocation 0=Do not follow, 1=Follow location. + * @param int<0,1> $followlocation 0=Do not follow, 1=Follow location. * @param string[] $addheaders Array of string to add into header. Example: ('Accept: application/xrds+xml', ....) * @param string[] $allowedschemes List of schemes that are allowed ('http' + 'https' only by default) - * @param int $localurl 0=Only external URL are possible, 1=Only local URL, 2=Both external and local URL are allowed. - * @param int $ssl_verifypeer -1=Auto (no ssl check on dev, check on prod), 0=No ssl check, 1=Always ssl check - * @return array Returns an associative array containing the response from the server array('http_code'=>http response code, 'content'=>response, 'curl_error_no'=>errno, 'curl_error_msg'=>errmsg...) + * @param int<0,2> $localurl 0=Only external URL are possible, 1=Only local URL, 2=Both external and local URL are allowed. + * @param int<-1,1> $ssl_verifypeer -1=Auto (no ssl check on dev, check on prod), 0=No ssl check, 1=Always ssl check + * @return array{http_code:int,content:string,curl_error_no:int,curl_error_msg:string} Returns an associative array containing the response from the server array('http_code'=>http response code, 'content'=>response, 'curl_error_no'=>errno, 'curl_error_msg'=>errmsg...) */ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = 1, $addheaders = array(), $allowedschemes = array('http', 'https'), $localurl = 0, $ssl_verifypeer = -1) { @@ -117,7 +117,7 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = // limit size of downloaded files. TODO Add MAIN_SECURITY_MAXFILESIZE_DOWNLOADED $maxsize = getDolGlobalInt('MAIN_SECURITY_MAXFILESIZE_DOWNLOADED'); if ($maxsize && defined('CURLOPT_MAXFILESIZE_LARGE')) { - curl_setopt($ch, CURLOPT_MAXFILESIZE_LARGE, $maxsize); + curl_setopt($ch, CURLOPT_MAXFILESIZE_LARGE, $maxsize); // @phan-suppress-current-line PhanTypeMismatchArgumentNullableInternal } if ($maxsize && defined('CURLOPT_MAXFILESIZE')) { curl_setopt($ch, CURLOPT_MAXFILESIZE, $maxsize); @@ -135,7 +135,7 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = $array_param = null; curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); // HTTP request is 'PUT' if (!is_array($param)) { - parse_str($param, $array_param); + parse_str($param, $array_param); // @phan-suppress-current-line PhanPluginConstantVariableNull } else { dol_syslog("parameter param must be a string", LOG_WARNING); $array_param = $param; diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index c92922c5426..6ff9a5087f6 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -40,7 +40,7 @@ if (!defined('IMAGETYPE_WEBP')) { /** * Return default values for image sizes * - * @return array Array of default values + * @return array{maxwidthsmall:int,maxheightsmall:int,maxwidthmini:int,maxheightmini:int,quality:int} Array of default values */ function getDefaultImageSizes() { @@ -140,7 +140,7 @@ function image_format_supported($file, $acceptsvg = 0) * * @param string $file Full path name of file * @param bool $url Image with url (true or false) - * @return array array('width'=>width, 'height'=>height) + * @return array{width:int,height:int}|array{}|array{width:'',height:''} array('width'=>width, 'height'=>height) */ function dol_getImageSize($file, $url = false) { @@ -290,6 +290,8 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, } // Read source image file + $img = null; + $extImg = null; switch ($infoImg[2]) { case 1: // Gif $img = imagecreatefromgif($filetoread); @@ -396,8 +398,12 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, dolChmod($imgTargetName); // Free memory. This does not delete image. - imagedestroy($img); - imagedestroy($imgTarget); + if ($img) { + imagedestroy($img); + } + if ($imgTarget) { + imagedestroy($imgTarget); + } clearstatcache(); // File was replaced by a modified one, so we clear file caches. @@ -730,6 +736,9 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', // Variable initialization according to image extension // $targetformat is 0 by default, in such case, we keep original extension + $extImgTarget = null; + $trans_colour = false; + $newquality = null; switch ($targetformat) { case IMAGETYPE_GIF: // 1 $trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // The GIF format works differently @@ -765,7 +774,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', $newquality = $quality; break; } - if (function_exists("imagefill")) { + if (function_exists("imagefill") && $trans_colour !== false) { imagefill($imgThumb, 0, 0, $trans_colour); } @@ -789,10 +798,10 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', imagegif($imgThumb, $imgThumbName); break; case IMAGETYPE_JPEG: // 2 - imagejpeg($imgThumb, $imgThumbName, $newquality); + imagejpeg($imgThumb, $imgThumbName, $newquality); // @phan-suppress-current-line PhanTypeMismatchArgumentNullableInternal,PhanPossiblyUndeclaredVariable break; case IMAGETYPE_PNG: // 3 - imagepng($imgThumb, $imgThumbName, $newquality); + imagepng($imgThumb, $imgThumbName, $newquality); // @phan-suppress-current-line PhanPossiblyUndeclaredVariable break; case IMAGETYPE_BMP: // 6 // Not supported by PHP GD @@ -801,7 +810,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', imagewbmp($imgThumb, $imgThumbName); break; case IMAGETYPE_WEBP: // 18 - imagewebp($imgThumb, $imgThumbName, $newquality); + imagewebp($imgThumb, $imgThumbName, $newquality); // @phan-suppress-current-line PhanTypeMismatchArgumentNullableInternal,PhanPossiblyUndeclaredVariable break; } diff --git a/htdocs/core/lib/invoice2.lib.php b/htdocs/core/lib/invoice2.lib.php index 4a89aaf8f6b..bf2e51a47fd 100644 --- a/htdocs/core/lib/invoice2.lib.php +++ b/htdocs/core/lib/invoice2.lib.php @@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; * @param Conf $conf Object conf * @param string $diroutputpdf Dir to output file * @param string $newlangid Lang id - * @param array $filter Array with filters + * @param string[] $filter Array with filters * @param integer $dateafterdate Invoice after date * @param integer $datebeforedate Invoice before date * @param integer $paymentdateafter Payment after date (must includes hour) @@ -45,7 +45,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; * @param string $regenerate ''=Use existing PDF files, 'nameofpdf'=Regenerate all PDF files using the template * @param string $filesuffix Suffix to add into file name of generated PDF * @param string $paymentbankid Only if payment on this bank account id - * @param array $thirdpartiesid List of thirdparties id when using filter=excludethirdpartiesid or filter=onlythirdpartiesid + * @param int[] $thirdpartiesid List of thirdparties id when using filter=excludethirdpartiesid or filter=onlythirdpartiesid * @param string $fileprefix Prefix to add into filename of generated PDF * @return int Error code */ @@ -246,6 +246,7 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte } //$pdf->SetCompression(false); + $pagecount = 0; // Add all others foreach ($files as $file) { if ($usestdout) { diff --git a/htdocs/core/lib/ldap.lib.php b/htdocs/core/lib/ldap.lib.php index 04bc6bedb1a..93a20fb56f8 100644 --- a/htdocs/core/lib/ldap.lib.php +++ b/htdocs/core/lib/ldap.lib.php @@ -123,7 +123,7 @@ function show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass) /** * Show a LDAP array into an HTML output array. * - * @param array<'count'|int|string,int|string|array> $result Array to show. This array is already encoded into charset_output + * @param array<'count'|int|string,int|string|mixed[]> $result Array to show. This array is already encoded into charset_output * @param int $level Level * @param int $count Count * @param bool $var Var deprecated (replaced by css oddeven) diff --git a/htdocs/core/lib/loan.lib.php b/htdocs/core/lib/loan.lib.php index 76bebe2d046..3de9f42290b 100644 --- a/htdocs/core/lib/loan.lib.php +++ b/htdocs/core/lib/loan.lib.php @@ -98,7 +98,7 @@ function loan_prepare_head($object) * @param float $rate Loan rate * @param int $numactualloadterm Actual loan term * @param int $nbterm Total number of term for this loan - * @return array Array with remaining capital, interest, and mensuality for each remaining terms + * @return array Array with remaining capital, interest, and mensuality for each remaining terms */ function loanCalcMonthlyPayment($mens, $capital, $rate, $numactualloadterm, $nbterm) { @@ -141,7 +141,6 @@ function loanCalcMonthlyPayment($mens, $capital, $rate, $numactualloadterm, $nbt 'interet_str' => price($int, 0, '', 1, -1, -1, $conf->currency), 'mens' => $mens, ); - $capital = $cap_rest; $numactualloadterm++; } diff --git a/htdocs/core/lib/memory.lib.php b/htdocs/core/lib/memory.lib.php index 084549d2eb2..239b9f26f1d 100644 --- a/htdocs/core/lib/memory.lib.php +++ b/htdocs/core/lib/memory.lib.php @@ -233,11 +233,11 @@ function dol_getshmopaddress($memoryid) /** * Return list of contents of all memory area shared * - * @return array + * @return array */ function dol_listshmop() { - global $shmkeys, $shmoffset; + global $shmkeys; $resarray = array(); foreach ($shmkeys as $key => $val) { @@ -253,13 +253,13 @@ function dol_listshmop() * Save data into a memory area shared by all users, all sessions on server * * @param string $memoryid Memory id of shared area ('main', 'agenda', ...) - * @param string $data Data to save. Must be a not null value. + * @param mixed|mixed[] $data Data to save. Must be a not null value. * @param int $expire ttl in seconds, 0 never expire * @return int Return integer <0 if KO, 0=Caching not available, Nb of bytes written if OK */ function dol_setshmop($memoryid, $data, $expire) { - global $shmkeys, $shmoffset; + global $shmkeys; //print 'dol_setshmop memoryid='.$memoryid."
\n"; if (empty($shmkeys[$memoryid]) || !function_exists("shmop_write")) { @@ -293,11 +293,11 @@ function dol_setshmop($memoryid, $data, $expire) * Read a memory area shared by all users, all sessions on server * * @param string $memoryid Memory id of shared area ('main', 'agenda', ...) - * @return int|null Return integer <0 if KO, data if OK, null if no cache enabled or not found + * @return int<-1,-1>|null|mixed|mixed[] integer <0 if KO, data if OK, null if no cache enabled or not found */ function dol_getshmop($memoryid) { - global $shmkeys, $shmoffset; + global $shmkeys; $data = null; diff --git a/htdocs/core/lib/oauth.lib.php b/htdocs/core/lib/oauth.lib.php index 383546cf036..b5ff496e774 100644 --- a/htdocs/core/lib/oauth.lib.php +++ b/htdocs/core/lib/oauth.lib.php @@ -29,7 +29,7 @@ /** * Return array of possible OAUTH2 services * - * @return array Array of services + * @return array Array of services */ function getAllOauth2Array() { @@ -273,9 +273,9 @@ function getAllOauth2Array() /** - * Return array of tabs to used on pages to setup cron module. + * Return array of tabs to use on pages to setup cron module. * - * @return array Array of tabs + * @return array> Array of tabs */ function getSupportedOauth2Array() { diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index fa7ad623f3a..980b72a2874 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -156,7 +156,7 @@ function payment_supplier_prepare_head(Paiement $object) * Return array of valid payment mode * * @param string $paymentmethod Filter on this payment method (''=none, 'paypal', 'stripe', ...) - * @return array Array of valid payment method + * @return array Array of valid payment method */ function getValidOnlinePaymentMethods($paymentmethod = '') { diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index ea8e314b441..7fa9750d854 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -2196,7 +2196,7 @@ function pdf_getlineqty_shipped($object, $i, $outputlangs, $hidedetails = 0) /** * Return line keep to ship quantity * - * @param Object $object Object + * @param Delivery|Asset|Commande|Facture|CommandeFournisseur|FactureFournisseur|SupplierProposal|Propal|StockTransfer|MyObject $object Object * @param int $i Current line number * @param Translate $outputlangs Object langs for output * @param int<0,2> $hidedetails Hide details (0=no, 1=yes, 2=just special lines) @@ -2211,7 +2211,7 @@ function pdf_getlineqty_keeptoship($object, $i, $outputlangs, $hidedetails = 0) //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line) ) ) if (is_object($hookmanager)) { // Old code is commented on preceding line. Reproduce this test in the pdf_xxx function if you don't want your hook to run $special_code = empty($object->lines[$i]->special_code) ? '' : $object->lines[$i]->special_code; - if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) { + if (!empty($object->lines[$i]->fk_parent_line) && $object->lines[$i]->fk_parent_line > 0) { // @phan-suppress-current-line PhanUndeclaredProperty $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); } $parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code); diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index a6a4012ac46..5a5558bdad6 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -47,14 +47,14 @@ * @param float $remise_percent_global 0 * @param string $price_base_type 'HT'=Unit price parameter $pu is HT, 'TTC'=Unit price parameter $pu is TTC (HT+VAT but not Localtax. TODO Add also mode 'INCT' when pu is price HT+VAT+LT1+LT2) * @param int $info_bits Miscellaneous information on line - * @param int $type 0/1=Product/service + * @param int<0,1> $type 0/1=Product/service * @param Societe|string $seller Thirdparty seller (we need $seller->country_id property). Provided only if seller is the supplier, otherwise $seller will be $mysoc. - * @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). - * @param integer $progress Situation invoices progress (value from 0 to 100, 100 by default) - * @param double $multicurrency_tx Currency rate (1 by default) - * @param double $pu_devise Amount in currency + * @param array{0:string,1:int|string,2:string,3:string}|array{0:string,1:int|string,2:string,3:int|string,4:string,5:string} $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). + * @param float $progress Situation invoices progress (value from 0 to 100, 100 by default) + * @param float $multicurrency_tx Currency rate (1 by default) + * @param float $pu_devise Amount in currency * @param string $multicurrency_code Value of the foreign currency if multicurrency is used ('EUR', 'USD', ...). It will be used for rounding according to currency. - * @return array [ + * @return array{}|array,string> Array [ * 0=total_ht, * 1=total_vat, (main vat only) * 2=total_ttc, (total_ht + main vat + local taxes) @@ -84,8 +84,10 @@ * 24=multicurrency_total_ttc_without_discount * 25=multicurrency_total_tax1 for total_ht * 26=multicurrency_total_tax2 for total_ht + * + * @phan-suppress PhanTypeMismatchDefault */ -function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller = '', $localtaxes_array = [], $progress = 100, $multicurrency_tx = 1, $pu_devise = 0, $multicurrency_code = '') +function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller = '', $localtaxes_array = [], $progress = 100, $multicurrency_tx = 1, $pu_devise = 0, $multicurrency_code = '') // @phpstan-ignore-line { global $conf, $mysoc, $db; @@ -140,6 +142,8 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt // Now we search localtaxes information ourself (rates and types). $localtax1_type = 0; $localtax2_type = 0; + $localtax1_rate = 1000; // For static analysis, exaggerated value to help detect bugs + $localtax2_rate = 1000; // For static analysis, exaggerated value to help detect bugs if (is_array($localtaxes_array) && count($localtaxes_array)) { $localtax1_type = $localtaxes_array[0]; @@ -408,7 +412,7 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt } // Recall function using the multicurrency price as reference price. We must set param $multicurrency_tx to 1 to avoid infinite loop. - $newresult = calcul_price_total($qty, $pu_devise, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller, $localtaxes_array, $progress, 1, 0, ''); + $newresult = calcul_price_total($qty, $pu_devise, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller, $localtaxes_array, $progress, 1, 0, ''); // pu_devise is normally arg#15, here as arg#2 @phan-suppress-current-line PhanPluginSuspiciousParamPosition if ($multicurrency_code) { // Restore setup of currency accurency diff --git a/htdocs/core/lib/report.lib.php b/htdocs/core/lib/report.lib.php index ebf4b39ab98..f55727b412a 100644 --- a/htdocs/core/lib/report.lib.php +++ b/htdocs/core/lib/report.lib.php @@ -1,6 +1,7 @@ * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,7 +34,7 @@ * @param string $description Description * @param integer $builddate Date generation * @param string $exportlink Link for export or '' - * @param array $moreparam Array with list of params to add into form + * @param array $moreparam Array with list of params to add into form * @param string $calcmode Calculation mode * @param string $varlink Add a variable into the address of the page * @return void diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 580ffecd283..f016a3e610d 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -1200,7 +1200,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl * @param string $message Force error message * @param int $http_response_code HTTP response code * @param int<0,1> $stringalreadysanitized 1 if string is already sanitized with HTML entities - * @return void + * @return never * @see accessforbidden() */ function httponly_accessforbidden($message = '1', $http_response_code = 403, $stringalreadysanitized = 0) @@ -1223,11 +1223,11 @@ function httponly_accessforbidden($message = '1', $http_response_code = 403, $st * Calling this function terminate execution of PHP. * * @param string $message Force error message - * @param int $printheader Show header before - * @param int $printfooter Show footer after - * @param int $showonlymessage Show only message parameter. Otherwise add more information. - * @param array|null $params More parameters provided to hook - * @return void + * @param int<0,1> $printheader Show header before + * @param int<0,1> $printfooter Show footer after + * @param int<0,1> $showonlymessage Show only message parameter. Otherwise add more information. + * @param ?array $params More parameters provided to hook + * @return never * @see httponly_accessforbidden() */ function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $showonlymessage = 0, $params = null) diff --git a/htdocs/core/lib/signature.lib.php b/htdocs/core/lib/signature.lib.php index 76b464a508f..9b885c2b82e 100644 --- a/htdocs/core/lib/signature.lib.php +++ b/htdocs/core/lib/signature.lib.php @@ -2,6 +2,7 @@ /** * Copyright (C) 2013 Marcos García * 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 @@ -196,7 +197,7 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1, $o if ($mode == 1) { $out .= "hash('".$securekeyseed."' + '".$type."' + $type + '_ref)"; } else { - $out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.(!isModEnabled('multicompany') ? '' : $object->entity), '0'); + $out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.(!isModEnabled('multicompany') ? '' : $obj->entity), '0'); } } diff --git a/htdocs/core/lib/treeview.lib.php b/htdocs/core/lib/treeview.lib.php index 3b8a31e4f5f..e68716561a9 100644 --- a/htdocs/core/lib/treeview.lib.php +++ b/htdocs/core/lib/treeview.lib.php @@ -29,9 +29,9 @@ /** * Show indent and picto of a tree line. Return array with information of line. * - * @param array $fulltree Array of entries in correct order - * @param string $key Key of entry into fulltree to show picto - * @param int $silent Do not output indent and picto, returns only value + * @param array $fulltree Array of entries in correct order + * @param int $key Key of entry into fulltree to show picto + * @param int<0,1> $silent Do not output indent and picto, returns only value * @return array{0:int,1:int,2:int} array(0 or 1 if at least one of this level after, 0 or 1 if at least one of higher level after, nbofdirinsub, nbofdocinsub) */ function tree_showpad(&$fulltree, $key, $silent = 0) @@ -108,12 +108,12 @@ function tree_showpad(&$fulltree, $key, $silent = 0) * $arrayofcss=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css'); * TODO Replace with jstree plugin instead of treeview plugin. * - * @param array $tab Array of all elements - * @param array $pere Array with parent ids ('rowid'=>,'mainmenu'=>,'leftmenu'=>,'fk_mainmenu'=>,'fk_leftmenu'=>) + * @param array $tab Array of all elements + * @param array{rowid:int,module?:string,fk_menu?:int,title?:string,mainmenu?:string,leftmenu?:string,fk_mainmenu?:string,fk_leftmenu?:string,statut?:int,entry?:string,buttons?:string} $pere Array with parent ids ('rowid'=>,'mainmenu'=>,'leftmenu'=>,'fk_mainmenu'=>,'fk_leftmenu'=>) * @param int $rang Level of element * @param string $iddivjstree Id to use for parent ul element - * @param int $donoresetalreadyloaded Do not reset global array $donoresetalreadyloaded used to avoid to go down on an already processed record - * @param int $showfk 1=show fk_links to parent into label (used by menu editor only) + * @param int<0,1> $donoresetalreadyloaded Do not reset global array $donoresetalreadyloaded used to avoid to go down on an already processed record + * @param int<0,1> $showfk 1=show fk_links to parent into label (used by menu editor only) * @param string $moreparam Add more param on url of elements * @return void */ diff --git a/htdocs/core/lib/xcal.lib.php b/htdocs/core/lib/xcal.lib.php index 4ac67cb3262..834b9aa7a82 100644 --- a/htdocs/core/lib/xcal.lib.php +++ b/htdocs/core/lib/xcal.lib.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 @@ * @param string $format "vcal" or "ical" * @param string $title Title of export * @param string $desc Description of export - * @param array $events_array Array of events ("uid","startdate","duration","enddate","title","summary","category","email","url","desc","author") + * @param array $events_array Array of events ("uid","startdate","summary","url","desc","author","category","image") or Array of WebsitePage * @param string $outputfile Output file * @return int Return integer < 0 if KO, Nb of events in file if OK */ @@ -289,7 +290,7 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile) fwrite($calfileh, "LOCATION:".$location."\n"); fwrite($calfileh, "TRANSP:OPAQUE\n"); fwrite($calfileh, "CLASS:CONFIDENTIAL\n"); - fwrite($calfileh, "DTSTAMP:".dol_print_date($startdatef, "dayhourxcard", 'gmt')."\n"); + fwrite($calfileh, "DTSTAMP:".dol_print_date($startdate, "dayhourxcard", 'gmt')."\n"); fwrite($calfileh, "END:VJOURNAL\n"); } @@ -315,7 +316,7 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile) * @param string $format "rss" * @param string $title Title of export * @param string $desc Description of export - * @param array $events_array Array of events ("uid","startdate","summary","url","desc","author","category","image") or Array of WebsitePage + * @param array $events_array Array of events ("uid","startdate","summary","url","desc","author","category","image") or Array of WebsitePage * @param string $outputfile Output file * @param string $filter (optional) Filter * @param string $url Url (If empty, forge URL for agenda RSS export) @@ -414,7 +415,6 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt $event = $tmpevent; } - $uid = $event["uid"]; $startdate = $event["startdate"]; $summary = $event["summary"]; diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index 2ca9366a4bf..4d9844d4311 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -93,7 +93,7 @@ function print_auguria_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout // Complete param to force leftmenu to '' to close open menu when we click on a link with no leftmenu defined. if ((!preg_match('/mainmenu/i', $param)) && (!preg_match('/leftmenu/i', $param)) && !empty($newTabMenu[$i]['url'])) { - // @phan-suppress-next-line PhanTypeSuspiciousStringExpression + // @phan-suppress-next-line PhanTypeSuspiciousStringExpression,PhanTypeInvalidDimOffset $param .= ($param ? '&' : '').'mainmenu='.$newTabMenu[$i]['mainmenu'].'&leftmenu='; } if ((!preg_match('/mainmenu/i', $param)) && (!preg_match('/leftmenu/i', $param)) && empty($newTabMenu[$i]['url'])) { diff --git a/htdocs/core/modules/facture/doc/pdf_octopus.modules.php b/htdocs/core/modules/facture/doc/pdf_octopus.modules.php index 64c2915c6b7..533ea70e3cd 100644 --- a/htdocs/core/modules/facture/doc/pdf_octopus.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_octopus.modules.php @@ -3215,8 +3215,8 @@ class pdf_octopus extends ModelePDFFactures $pu_ht = $tabprice[3]; return array( - 'progress_prec' => $l->situation_percent, - 'total_ht_without_progress' => $total_ht, + 'progress_prec' => (float) $l->situation_percent, + 'total_ht_without_progress' => (float) $total_ht, 'total_ht' => $l->total_ht, ); } diff --git a/htdocs/core/modules/syslog/mod_syslog_syslog.php b/htdocs/core/modules/syslog/mod_syslog_syslog.php index ee2b58259fa..80706c439c7 100644 --- a/htdocs/core/modules/syslog/mod_syslog_syslog.php +++ b/htdocs/core/modules/syslog/mod_syslog_syslog.php @@ -97,7 +97,7 @@ class mod_syslog_syslog extends LogHandler dol_syslog("admin/syslog: facility ".$facility); return true; } else { - $this->errors[] = $langs->trans("ErrorUnknownSyslogConstant", $facility); + $this->errors[] = $langs->trans("ErrorUnknownSyslogConstant", getDolGlobalString('SYSLOG_FACILITY')); return false; } } diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 328a4c5748f..69f035252b5 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -401,13 +401,13 @@ if (isset($this->situation_cycle_ref) && $this->situation_cycle_ref) { $coldisplay++; $locataxes_array = getLocalTaxesFromRate($line->tva.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''), 0, ($senderissupplier ? $mysoc : $object->thirdparty), ($senderissupplier ? $object->thirdparty : $mysoc)); $tmp = calcul_price_total($line->qty, $line->pu, $line->remise_percent, $line->txtva, -1, -1, 0, 'HT', $line->info_bits, $line->type, ($senderissupplier ? $object->thirdparty : $mysoc), $locataxes_array, 100, $object->multicurrency_tx, $line->multicurrency_subprice); - print ''.price($sign * $tmp[0]).''; + print ''.price($sign * (float) $tmp[0]).''; } else { print ''.$line->situation_percent.'%'; $coldisplay++; $locataxes_array = getLocalTaxesFromRate($line->tva.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''), 0, ($senderissupplier ? $mysoc : $object->thirdparty), ($senderissupplier ? $object->thirdparty : $mysoc)); $tmp = calcul_price_total($line->qty, $line->pu, $line->remise_percent, $line->txtva, -1, -1, 0, 'HT', $line->info_bits, $line->type, ($senderissupplier ? $object->thirdparty : $mysoc), $locataxes_array, 100, $object->multicurrency_tx, $line->multicurrency_subprice); - print ''.price($sign * $tmp[0]).''; + print ''.price($sign * (float) $tmp[0]).''; } } diff --git a/htdocs/datapolicy/lib/datapolicy.lib.php b/htdocs/datapolicy/lib/datapolicy.lib.php index 7d1ffd6ef0f..f30b144b84d 100644 --- a/htdocs/datapolicy/lib/datapolicy.lib.php +++ b/htdocs/datapolicy/lib/datapolicy.lib.php @@ -1,6 +1,7 @@ * Copyright (C) 2019 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 @@ -25,7 +26,7 @@ /** * Prepare admin pages header * - * @return array + * @return array */ function datapolicyAdminPrepareHead() { diff --git a/htdocs/emailcollector/lib/emailcollector.lib.php b/htdocs/emailcollector/lib/emailcollector.lib.php index 492b5b4aa86..3153f2d629e 100644 --- a/htdocs/emailcollector/lib/emailcollector.lib.php +++ b/htdocs/emailcollector/lib/emailcollector.lib.php @@ -89,8 +89,8 @@ function emailcollectorPrepareHead($object) /** * Get parts of a message * - * @param object $structure Structure of message - * @return array|false Array of parts of the message|false if error + * @param stdClass $structure Structure of message + * @return stdClass[]|false Array of parts of the message|false if error */ function getParts($structure) { @@ -100,8 +100,8 @@ function getParts($structure) /** * Array with joined files * - * @param object $part Part of message - * @return object|boolean Definition of message|false in case of error + * @param stdClass $part Part of message + * @return stdclass|boolean Definition of message|false in case of error */ function getDParameters($part) { @@ -112,7 +112,7 @@ function getDParameters($part) * Get attachments of a given mail * * @param integer $jk Number of email - * @param object $mbox object connection imap + * @param \IMAP\Connection $mbox object connection imap * @return array type, filename, pos */ function getAttachments($jk, $mbox) @@ -149,8 +149,8 @@ function getAttachments($jk, $mbox) * @param integer $jk numéro du mail * @param string $fpos position de la pièce jointe * @param integer $type type de la pièce jointe - * @param object $mbox object connection imap - * @return mixed data + * @param \IMAP\Connection $mbox object connection imap + * @return string data */ function getFileData($jk, $fpos, $type, $mbox) { diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 5480618a842..1b59328e13e 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1799,11 +1799,11 @@ class Expedition extends CommonObject $tabprice = calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $localtax1_tx, $localtax2_tx, 0, 'HT', $obj->info_bits, $obj->fk_product_type, $mysoc, $localtax_array); // We force type to 0 $line->desc = $obj->description; // We need ->desc because some code into CommonObject use desc (property defined for other elements) $line->qty = $line->qty_shipped; - $line->total_ht = $tabprice[0]; - $line->total_localtax1 = $tabprice[9]; - $line->total_localtax2 = $tabprice[10]; - $line->total_ttc = $tabprice[2]; - $line->total_tva = $tabprice[1]; + $line->total_ht = (float) $tabprice[0]; + $line->total_localtax1 = (float) $tabprice[9]; + $line->total_localtax2 = (float) $tabprice[10]; + $line->total_ttc = (float) $tabprice[2]; + $line->total_tva = (float) $tabprice[1]; $line->vat_src_code = $obj->vat_src_code; $line->tva_tx = $obj->tva_tx; $line->localtax1_tx = $obj->localtax1_tx; diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 805b414bfe5..f73497dd375 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1997,11 +1997,11 @@ class ExpenseReport extends CommonObject $this->line->localtax1_type = $localtaxes_type[0]; $this->line->localtax2_type = $localtaxes_type[2]; - $this->line->total_ttc = $tmp[2]; - $this->line->total_ht = $tmp[0]; - $this->line->total_tva = $tmp[1]; - $this->line->total_localtax1 = $tmp[9]; - $this->line->total_localtax2 = $tmp[10]; + $this->line->total_ttc = (float) $tmp[2]; + $this->line->total_ht = (float) $tmp[0]; + $this->line->total_tva = (float) $tmp[1]; + $this->line->total_localtax1 = (float) $tmp[9]; + $this->line->total_localtax2 = (float) $tmp[10]; $this->line->fk_expensereport = $this->id; $this->line->qty = $qty; @@ -2104,11 +2104,11 @@ class ExpenseReport extends CommonObject $tmp = calcul_price_total($this->line->qty, $new_current_total_ttc / $this->line->qty, 0, $this->line->vatrate, 0, 0, 0, 'TTC', 0, $type, $seller); $this->line->value_unit = $tmp[5]; - $this->line->total_ttc = $tmp[2]; - $this->line->total_ht = $tmp[0]; - $this->line->total_tva = $tmp[1]; - $this->line->total_localtax1 = $tmp[9]; - $this->line->total_localtax2 = $tmp[10]; + $this->line->total_ttc = (float) $tmp[2]; + $this->line->total_ht = (float) $tmp[0]; + $this->line->total_tva = (float) $tmp[1]; + $this->line->total_localtax1 = (float) $tmp[9]; + $this->line->total_localtax2 = (float) $tmp[10]; return false; } else { @@ -2165,11 +2165,11 @@ class ExpenseReport extends CommonObject $tmp = calcul_price_total($this->line->qty, $new_up, 0, $this->line->vatrate, 0, 0, 0, 'TTC', 0, $type, $seller); $this->line->value_unit = $tmp[5]; - $this->line->total_ttc = $tmp[2]; - $this->line->total_ht = $tmp[0]; - $this->line->total_tva = $tmp[1]; - $this->line->total_localtax1 = $tmp[9]; - $this->line->total_localtax2 = $tmp[10]; + $this->line->total_ttc = (float) $tmp[2]; + $this->line->total_ht = (float) $tmp[0]; + $this->line->total_tva = (float) $tmp[1]; + $this->line->total_localtax1 = (float) $tmp[9]; + $this->line->total_localtax2 = (float) $tmp[10]; return true; } @@ -2277,11 +2277,11 @@ class ExpenseReport extends CommonObject $this->line->localtax1_type = $localtaxes_type[0]; $this->line->localtax2_type = $localtaxes_type[2]; - $this->line->total_ttc = $tmp[2]; - $this->line->total_ht = $tmp[0]; - $this->line->total_tva = $tmp[1]; - $this->line->total_localtax1 = $tmp[9]; - $this->line->total_localtax2 = $tmp[10]; + $this->line->total_ttc = (float) $tmp[2]; + $this->line->total_ht = (float) $tmp[0]; + $this->line->total_tva = (float) $tmp[1]; + $this->line->total_localtax1 = (float) $tmp[9]; + $this->line->total_localtax2 = (float) $tmp[10]; $this->line->fk_ecm_files = $fk_ecm_files; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index c8a9393c19c..6592eee64a2 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2171,16 +2171,16 @@ class CommandeFournisseur extends CommonOrder $this->line->fk_product = $fk_product; $this->line->product_type = $product_type; $this->line->remise_percent = $remise_percent; - $this->line->subprice = $pu_ht; + $this->line->subprice = (float) $pu_ht; $this->line->rang = $rang; $this->line->info_bits = $info_bits; $this->line->vat_src_code = $vat_src_code; - $this->line->total_ht = $total_ht; - $this->line->total_tva = $total_tva; - $this->line->total_localtax1 = $total_localtax1; - $this->line->total_localtax2 = $total_localtax2; - $this->line->total_ttc = $total_ttc; + $this->line->total_ht = (float) $total_ht; + $this->line->total_tva = (float) $total_tva; + $this->line->total_localtax1 = (float) $total_localtax1; + $this->line->total_localtax2 = (float) $total_localtax2; + $this->line->total_ttc = (float) $total_ttc; $this->line->product_type = $type; $this->line->special_code = (!empty($special_code) ? $special_code : 0); $this->line->origin = $origin; @@ -2193,12 +2193,12 @@ class CommandeFournisseur extends CommonOrder // Multicurrency $this->line->fk_multicurrency = $this->fk_multicurrency; $this->line->multicurrency_code = $this->multicurrency_code; - $this->line->multicurrency_subprice = $pu_ht_devise; - $this->line->multicurrency_total_ht = $multicurrency_total_ht; - $this->line->multicurrency_total_tva = $multicurrency_total_tva; - $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; + $this->line->multicurrency_subprice = (float) $pu_ht_devise; + $this->line->multicurrency_total_ht = (float) $multicurrency_total_ht; + $this->line->multicurrency_total_tva = (float) $multicurrency_total_tva; + $this->line->multicurrency_total_ttc = (float) $multicurrency_total_ttc; - $this->line->subprice = $pu_ht; + $this->line->subprice = (float) $pu_ht; $this->line->price = $this->line->subprice; $this->line->remise_percent = $remise_percent; @@ -3057,13 +3057,13 @@ class CommandeFournisseur extends CommonOrder $this->line->localtax1_type = empty($localtaxes_type[0]) ? '' : $localtaxes_type[0]; $this->line->localtax2_type = empty($localtaxes_type[2]) ? '' : $localtaxes_type[2]; $this->line->remise_percent = $remise_percent; - $this->line->subprice = $pu_ht; + $this->line->subprice = (float) $pu_ht; $this->line->info_bits = $info_bits; - $this->line->total_ht = $total_ht; - $this->line->total_tva = $total_tva; - $this->line->total_localtax1 = $total_localtax1; - $this->line->total_localtax2 = $total_localtax2; - $this->line->total_ttc = $total_ttc; + $this->line->total_ht = (float) $total_ht; + $this->line->total_tva = (float) $total_tva; + $this->line->total_localtax1 = (float) $total_localtax1; + $this->line->total_localtax2 = (float) $total_localtax2; + $this->line->total_ttc = (float) $total_ttc; $this->line->product_type = $type; $this->line->special_code = $oldline->special_code; $this->line->rang = $oldline->rang; @@ -3076,12 +3076,12 @@ class CommandeFournisseur extends CommonOrder // Multicurrency $this->line->fk_multicurrency = $this->fk_multicurrency; $this->line->multicurrency_code = $this->multicurrency_code; - $this->line->multicurrency_subprice = $pu_ht_devise; - $this->line->multicurrency_total_ht = $multicurrency_total_ht; - $this->line->multicurrency_total_tva = $multicurrency_total_tva; - $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; + $this->line->multicurrency_subprice = (float) $pu_ht_devise; + $this->line->multicurrency_total_ht = (float) $multicurrency_total_ht; + $this->line->multicurrency_total_tva = (float) $multicurrency_total_tva; + $this->line->multicurrency_total_ttc = (float) $multicurrency_total_ttc; - $this->line->subprice = $pu_ht; + $this->line->subprice = (float) $pu_ht; $this->line->price = $this->line->subprice; $this->line->remise_percent = $remise_percent; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 38d27153d41..508ca50485c 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2247,8 +2247,8 @@ class FactureFournisseur extends CommonInvoice $supplierinvoiceline->desc = $desc; $supplierinvoiceline->ref_supplier = $ref_supplier; - $supplierinvoiceline->qty = ($this->type == self::TYPE_CREDIT_NOTE ? abs((float) $qty) : $qty); // For credit note, quantity is always positive and unit price negative - $supplierinvoiceline->subprice = ($this->type == self::TYPE_CREDIT_NOTE ? -abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise + $supplierinvoiceline->qty = ($this->type == self::TYPE_CREDIT_NOTE ? abs((float) $qty) : (float) $qty); // For credit note, quantity is always positive and unit price negative + $supplierinvoiceline->subprice = ($this->type == self::TYPE_CREDIT_NOTE ? -abs((float) $pu_ht) : (float) $pu_ht); // For credit note, unit price always negative, always positive otherwise $supplierinvoiceline->vat_src_code = $vat_src_code; $supplierinvoiceline->tva_tx = $txtva; @@ -2257,11 +2257,11 @@ class FactureFournisseur extends CommonInvoice $supplierinvoiceline->localtax1_type = empty($localtaxes_type[0]) ? 0 : $localtaxes_type[0]; $supplierinvoiceline->localtax2_type = empty($localtaxes_type[2]) ? 0 : $localtaxes_type[2]; - $supplierinvoiceline->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_ht) : $total_ht); // For credit note and if qty is negative, total is negative - $supplierinvoiceline->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_tva) : $total_tva); // For credit note and if qty is negative, total is negative - $supplierinvoiceline->total_localtax1 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_localtax1) : $total_localtax1); // For credit note and if qty is negative, total is negative - $supplierinvoiceline->total_localtax2 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_localtax2) : $total_localtax2); // For credit note and if qty is negative, total is negative - $supplierinvoiceline->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_ttc) : $total_ttc); // For credit note and if qty is negative, total is negative + $supplierinvoiceline->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs((float) $total_ht) : (float) $total_ht); // For credit note and if qty is negative, total is negative + $supplierinvoiceline->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs((float) $total_tva) : (float) $total_tva); // For credit note and if qty is negative, total is negative + $supplierinvoiceline->total_localtax1 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs((float) $total_localtax1) : (float) $total_localtax1); // For credit note and if qty is negative, total is negative + $supplierinvoiceline->total_localtax2 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs((float) $total_localtax2) : (float) $total_localtax2); // For credit note and if qty is negative, total is negative + $supplierinvoiceline->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs((float) $total_ttc) : (float) $total_ttc); // For credit note and if qty is negative, total is negative $supplierinvoiceline->fk_product = $fk_product; $supplierinvoiceline->product_type = $type; @@ -2283,11 +2283,11 @@ class FactureFournisseur extends CommonInvoice // Multicurrency $supplierinvoiceline->fk_multicurrency = $this->fk_multicurrency; $supplierinvoiceline->multicurrency_code = $this->multicurrency_code; - $supplierinvoiceline->multicurrency_subprice = ($this->type == self::TYPE_CREDIT_NOTE ? -abs($pu_ht_devise) : $pu_ht_devise); // For credit note, unit price always negative, always positive otherwise + $supplierinvoiceline->multicurrency_subprice = ($this->type == self::TYPE_CREDIT_NOTE ? -abs((float) $pu_ht_devise) : (float) $pu_ht_devise); // For credit note, unit price always negative, always positive otherwise - $supplierinvoiceline->multicurrency_total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($multicurrency_total_ht) : $multicurrency_total_ht); // For credit note and if qty is negative, total is negative - $supplierinvoiceline->multicurrency_total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($multicurrency_total_tva) : $multicurrency_total_tva); // For credit note and if qty is negative, total is negative - $supplierinvoiceline->multicurrency_total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($multicurrency_total_ttc) : $multicurrency_total_ttc); // For credit note and if qty is negative, total is negative + $supplierinvoiceline->multicurrency_total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs((float) $multicurrency_total_ht) : (float) $multicurrency_total_ht); // For credit note and if qty is negative, total is negative + $supplierinvoiceline->multicurrency_total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs((float) $multicurrency_total_tva) : (float) $multicurrency_total_tva); // For credit note and if qty is negative, total is negative + $supplierinvoiceline->multicurrency_total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs((float) $multicurrency_total_ttc) : (float) $multicurrency_total_ttc); // For credit note and if qty is negative, total is negative if (is_array($array_options) && count($array_options) > 0) { $supplierinvoiceline->array_options = $array_options; @@ -2447,10 +2447,10 @@ class FactureFournisseur extends CommonInvoice $line->description = $desc; $line->desc = $desc; - $line->qty = ($this->type == self::TYPE_CREDIT_NOTE ? abs((float) $qty) : $qty); // For credit note, quantity is always positive and unit price negative - $line->subprice = ($this->type == self::TYPE_CREDIT_NOTE ? -abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise + $line->qty = ($this->type == self::TYPE_CREDIT_NOTE ? abs((float) $qty) : (float) $qty); // For credit note, quantity is always positive and unit price negative + $line->subprice = ($this->type == self::TYPE_CREDIT_NOTE ? -abs((float) $pu_ht) : (float) $pu_ht); // For credit note, unit price always negative, always positive otherwise $line->pu_ht = $line->subprice; // deprecated - $line->pu_ttc = ($this->type == self::TYPE_CREDIT_NOTE ? -abs($pu_ttc) : $pu_ttc); // For credit note, unit price always negative, always positive otherwise + $line->pu_ttc = ($this->type == self::TYPE_CREDIT_NOTE ? -abs((float) $pu_ttc) : (float) $pu_ttc); // For credit note, unit price always negative, always positive otherwise $line->remise_percent = $remise_percent; $line->ref_supplier = $ref_supplier; @@ -2465,11 +2465,11 @@ class FactureFournisseur extends CommonInvoice $line->localtax1_type = empty($localtaxes_type[0]) ? 0 : $localtaxes_type[0]; $line->localtax2_type = empty($localtaxes_type[2]) ? 0 : $localtaxes_type[2]; - $line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_ht) : $total_ht); - $line->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_tva) : $total_tva); - $line->total_localtax1 = $total_localtax1; - $line->total_localtax2 = $total_localtax2; - $line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_ttc) : $total_ttc); + $line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs((float) $total_ht) : (float) $total_ht); + $line->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs((float) $total_tva) : (float) $total_tva); + $line->total_localtax1 = (float) $total_localtax1; + $line->total_localtax2 = (float) $total_localtax2; + $line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs((float) $total_ttc) : (float) $total_ttc); $line->fk_product = $idproduct; $line->product_type = $product_type; @@ -2485,10 +2485,10 @@ class FactureFournisseur extends CommonInvoice } // Multicurrency - $line->multicurrency_subprice = $pu_ht_devise; - $line->multicurrency_total_ht = $multicurrency_total_ht; - $line->multicurrency_total_tva = $multicurrency_total_tva; - $line->multicurrency_total_ttc = $multicurrency_total_ttc; + $line->multicurrency_subprice = (float) $pu_ht_devise; + $line->multicurrency_total_ht = (float) $multicurrency_total_ht; + $line->multicurrency_total_tva = (float) $multicurrency_total_tva; + $line->multicurrency_total_ttc = (float) $multicurrency_total_ttc; $res = $line->update($notrigger); diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php index 5d7da9a5e91..ace4248fc96 100644 --- a/htdocs/ftp/index.php +++ b/htdocs/ftp/index.php @@ -2,6 +2,7 @@ /* Copyright (C) 2008-2016 Laurent Destailleur * Copyright (C) 2008-2009 Regis Houssin * Copyright (C) 2019-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 @@ -484,9 +485,13 @@ if (!function_exists('ftp_connect')) { // } // $i++; //} - } else { + } elseif (!empty($conn_id)) { $buff = ftp_rawlist($conn_id, $newsectioniso); $contents = ftp_nlist($conn_id, $newsectioniso); // Sometimes rawlist fails but never nlist + } else { + dol_syslog(__FILE__ . ": Unexpected state for ftp connection", LOG_ERR); + $buff = array(); + $contents = array(); } $nboflines = count($contents); diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 4ae77d4114b..7d1af899db7 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -1577,9 +1577,9 @@ function migrate_price_facture($db, $langs, $conf) $total_tva = $result[1]; $total_ttc = $result[2]; - $facligne->total_ht = $total_ht; - $facligne->total_tva = $total_tva; - $facligne->total_ttc = $total_ttc; + $facligne->total_ht = (float) $total_ht; + $facligne->total_tva = (float) $total_tva; + $facligne->total_ttc = (float) $total_ttc; dolibarr_install_syslog("upgrade2: line ".$rowid.": facid=".$obj->facid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." remise_global=".$remise_percent_global." -> ".$total_ht.", ".$total_tva.", ".$total_ttc); print '. '; @@ -1678,9 +1678,9 @@ function migrate_price_propal($db, $langs, $conf) $total_tva = $result[1]; $total_ttc = $result[2]; - $propalligne->total_ht = $total_ht; - $propalligne->total_tva = $total_tva; - $propalligne->total_ttc = $total_ttc; + $propalligne->total_ht = (float) $total_ht; + $propalligne->total_tva = (float) $total_tva; + $propalligne->total_ttc = (float) $total_ttc; dolibarr_install_syslog("upgrade2: Line ".$rowid.": propalid=".$obj->rowid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." remise_global=".$remise_percent_global." -> ".$total_ht.", ".$total_tva.", ".$total_ttc); print '. '; @@ -1762,9 +1762,9 @@ function migrate_price_contrat($db, $langs, $conf) $total_tva = $result[1]; $total_ttc = $result[2]; - $contratligne->total_ht = $total_ht; - $contratligne->total_tva = $total_tva; - $contratligne->total_ttc = $total_ttc; + $contratligne->total_ht = (float) $total_ht; + $contratligne->total_tva = (float) $total_tva; + $contratligne->total_ttc = (float) $total_ttc; dolibarr_install_syslog("upgrade2: Line ".$rowid.": contratdetid=".$obj->rowid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." -> ".$total_ht.", ".$total_tva." , ".$total_ttc); print '. '; @@ -1843,9 +1843,9 @@ function migrate_price_commande($db, $langs, $conf) $total_tva = $result[1]; $total_ttc = $result[2]; - $commandeligne->total_ht = $total_ht; - $commandeligne->total_tva = $total_tva; - $commandeligne->total_ttc = $total_ttc; + $commandeligne->total_ht = (float) $total_ht; + $commandeligne->total_tva = (float) $total_tva; + $commandeligne->total_ttc = (float) $total_ttc; dolibarr_install_syslog("upgrade2: Line ".$rowid." : commandeid=".$obj->rowid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." remise_global=".$remise_percent_global." -> ".$total_ht.", ".$total_tva.", ".$total_ttc); print '. '; @@ -1936,9 +1936,9 @@ function migrate_price_commande_fournisseur($db, $langs, $conf) $total_tva = $result[1]; $total_ttc = $result[2]; - $commandeligne->total_ht = $total_ht; - $commandeligne->total_tva = $total_tva; - $commandeligne->total_ttc = $total_ttc; + $commandeligne->total_ht = (float) $total_ht; + $commandeligne->total_tva = (float) $total_tva; + $commandeligne->total_ttc = (float) $total_ttc; dolibarr_install_syslog("upgrade2: Line ".$rowid.": commandeid=".$obj->rowid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." remise_global=".$remise_percent_global." -> ".$total_ht.", ".$total_tva.", ".$total_ttc); print '. '; diff --git a/htdocs/margin/lib/margins.lib.php b/htdocs/margin/lib/margins.lib.php index abf1958dedb..43480c8a16a 100644 --- a/htdocs/margin/lib/margins.lib.php +++ b/htdocs/margin/lib/margins.lib.php @@ -114,7 +114,7 @@ function marges_prepare_head() * @param float $localtax2_tx Vat rate special 2 (not used) * @param int $fk_pa Id of buying price (prefer set this to 0 and provide $pa_ht instead. With id, buying price may have change) * @param float $pa_ht Buying price without tax - * @return array Array of margin info (buying price, marge rate, marque rate) + * @return array{0:float,1:float,2:float} Array of margin info (buying price, marge rate, marque rate) */ function getMarginInfos($pv_ht, $remise_percent, $tva_tx, $localtax1_tx, $localtax2_tx, $fk_pa, $pa_ht) { diff --git a/htdocs/opensurvey/lib/opensurvey.lib.php b/htdocs/opensurvey/lib/opensurvey.lib.php index cec135abe00..ef82c0e0970 100644 --- a/htdocs/opensurvey/lib/opensurvey.lib.php +++ b/htdocs/opensurvey/lib/opensurvey.lib.php @@ -177,7 +177,7 @@ function get_server_name() * Fonction vérifiant l'existance et la valeur non vide d'une clé d'un tableau * * @param string $name Key to test - * @param array $tableau Array in which searching key ($_POST by default) + * @param ?array $tableau Array in which searching key ($_POST by default) * @return bool True if key exists and return a non empty value */ function issetAndNoEmpty($name, $tableau = null) diff --git a/htdocs/paypal/lib/paypal.lib.php b/htdocs/paypal/lib/paypal.lib.php index 8ba85109cb8..15ed29f8d9f 100644 --- a/htdocs/paypal/lib/paypal.lib.php +++ b/htdocs/paypal/lib/paypal.lib.php @@ -198,7 +198,7 @@ function print_paypal_redirect($paymentAmount, $currencyCodeType, $paymentType, * @param string $phoneNum Phone * @param string $email Email * @param string $desc Description - * @return array Array + * @return array Array */ function callSetExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag, $solutionType, $landingPage, $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum, $email = '', $desc = '') { @@ -303,8 +303,8 @@ function callSetExpressCheckout($paymentAmount, $currencyCodeType, $paymentType, /** * Prepares the parameters for the GetExpressCheckoutDetails API Call. * - * @param string $token Token - * @return array The NVP Collection object of the GetExpressCheckoutDetails Call Response. + * @param string $token Token + * @return array The NVP Collection object of the GetExpressCheckoutDetails Call Response. */ function getDetails($token) { @@ -353,7 +353,7 @@ function getDetails($token) * @param string $ipaddress IP Address * @param string $FinalPaymentAmt Amount * @param string $tag Full tag - * @return array + * @return array */ function confirmPayment($token, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $tag) { @@ -407,7 +407,7 @@ function confirmPayment($token, $paymentType, $currencyCodeType, $payerID, $ipad * creditCardNumber: buyers credit card number without any spaces, dashes or any other characters * expDate: credit card expiration date * cvv2: Card Verification Value - * @return array The NVP Collection object of the DoDirectPayment Call Response. + * @return array The NVP Collection object of the DoDirectPayment Call Response. */ /* function DirectPayment($paymentType, $paymentAmount, $creditCardType, $creditCardNumber, $expDate, $cvv2, $firstName, $lastName, $street, $city, $state, $zip, $countryCode, $currencyCode, $tag) @@ -447,7 +447,7 @@ function DirectPayment($paymentType, $paymentAmount, $creditCardType, $creditCar * * @param string $methodName is name of API method. * @param string $nvpStr is nvp string. - * @return array returns an associative array containing the response from the server. + * @return array returns an associative array containing the response from the server. */ function hash_call($methodName, $nvpStr) { @@ -572,7 +572,7 @@ function hash_call($methodName, $nvpStr) * It is useful to search for a particular key and displaying arrays. * * @param string $nvpstr NVPString - * @return array nvpArray = Associative Array + * @return array nvpArray = Associative Array */ function deformatNVP($nvpstr) { @@ -598,7 +598,7 @@ function deformatNVP($nvpstr) /** * Get API errors * - * @return array Array of errors + * @return string[] Array of errors */ function getApiError() { diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index bb41322b9a7..99796370427 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -4,6 +4,7 @@ * Copyright (C) 2009-2012 Regis Houssin * Copyright (C) 2023 anthony Berton * 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 @@ -573,7 +574,7 @@ if ($source == 'proposal') { $last_main_doc_file = $object->last_main_doc; $diroutput = $conf->societe->multidir_output[$object->thirdparty->entity].'/' - .dol_sanitizeFileName($object->thirdparty->id).'/'; + .dol_sanitizeFileName((string) $object->thirdparty->id).'/'; if ((empty($last_main_doc_file) || !dol_is_file($diroutput .$langs->transnoentitiesnoconv("SepaMandateShort").' '.$object->id."-".dol_sanitizeFileName($object->rum).".pdf")) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 8ccb9a4d40f..9d7d1cbab51 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -690,7 +690,7 @@ class Stripe extends CommonObject $setupintent = null; - if (empty($setupintent)) { + if (empty($setupintent)) { // @phan-suppress-current-line PhanPluginConstantVariableNull $ipaddress = getUserRemoteIP(); $metadata = array('dol_version' => DOL_VERSION, 'dol_entity' => $conf->entity, 'ipaddress' => $ipaddress, 'dol_noidempotency' => (int) $noidempotency_key); if (is_object($object)) { diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 767c31d57b6..6c0a8307e9a 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -593,8 +593,8 @@ class SupplierProposal extends CommonObject $price = $pu; $remise = 0; if ($remise_percent > 0) { - $remise = round(($pu * (float) $remise_percent / 100), 2); - $price = $pu - $remise; + $remise = round(((float) $pu * (float) $remise_percent / 100), 2); + $price = (float) $pu - $remise; } // Insert line @@ -613,14 +613,14 @@ class SupplierProposal extends CommonObject $this->line->localtax2_type = empty($localtaxes_type[2]) ? '' : $localtaxes_type[2]; $this->line->fk_product = $fk_product; $this->line->remise_percent = $remise_percent; - $this->line->subprice = $pu_ht; + $this->line->subprice = (float) $pu_ht; $this->line->rang = $ranktouse; $this->line->info_bits = $info_bits; - $this->line->total_ht = $total_ht; - $this->line->total_tva = $total_tva; - $this->line->total_localtax1 = $total_localtax1; - $this->line->total_localtax2 = $total_localtax2; - $this->line->total_ttc = $total_ttc; + $this->line->total_ht = (float) $total_ht; + $this->line->total_tva = (float) $total_tva; + $this->line->total_localtax1 = (float) $total_localtax1; + $this->line->total_localtax2 = (float) $total_localtax2; + $this->line->total_ttc = (float) $total_ttc; $this->line->product_type = $type; $this->line->special_code = $special_code; $this->line->fk_parent_line = $fk_parent_line; @@ -647,10 +647,10 @@ class SupplierProposal extends CommonObject // Multicurrency $this->line->fk_multicurrency = $this->fk_multicurrency; $this->line->multicurrency_code = $this->multicurrency_code; - $this->line->multicurrency_subprice = $pu_ht_devise; - $this->line->multicurrency_total_ht = $multicurrency_total_ht; - $this->line->multicurrency_total_tva = $multicurrency_total_tva; - $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; + $this->line->multicurrency_subprice = (float) $pu_ht_devise; + $this->line->multicurrency_total_ht = (float) $multicurrency_total_ht; + $this->line->multicurrency_total_tva = (float) $multicurrency_total_tva; + $this->line->multicurrency_total_ttc = (float) $multicurrency_total_ttc; // Mise en option de la ligne if (empty($qty) && empty($special_code)) { @@ -821,13 +821,13 @@ class SupplierProposal extends CommonObject $this->line->localtax1_type = empty($localtaxes_type[0]) ? '' : $localtaxes_type[0]; $this->line->localtax2_type = empty($localtaxes_type[2]) ? '' : $localtaxes_type[2]; $this->line->remise_percent = $remise_percent; - $this->line->subprice = $pu; + $this->line->subprice = (float) $pu; $this->line->info_bits = $info_bits; - $this->line->total_ht = $total_ht; - $this->line->total_tva = $total_tva; - $this->line->total_localtax1 = $total_localtax1; - $this->line->total_localtax2 = $total_localtax2; - $this->line->total_ttc = $total_ttc; + $this->line->total_ht = (float) $total_ht; + $this->line->total_tva = (float) $total_tva; + $this->line->total_localtax1 = (float) $total_localtax1; + $this->line->total_localtax2 = (float) $total_localtax2; + $this->line->total_ttc = (float) $total_ttc; $this->line->special_code = $special_code; $this->line->fk_parent_line = $fk_parent_line; $this->line->skip_update_total = $skip_update_total; @@ -854,10 +854,10 @@ class SupplierProposal extends CommonObject } // Multicurrency - $this->line->multicurrency_subprice = $pu_ht_devise; - $this->line->multicurrency_total_ht = $multicurrency_total_ht; - $this->line->multicurrency_total_tva = $multicurrency_total_tva; - $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; + $this->line->multicurrency_subprice = (float) $pu_ht_devise; + $this->line->multicurrency_total_ht = (float) $multicurrency_total_ht; + $this->line->multicurrency_total_tva = (float) $multicurrency_total_tva; + $this->line->multicurrency_total_ttc = (float) $multicurrency_total_ttc; $result = $this->line->update(); if ($result > 0) { diff --git a/htdocs/user/hierarchy.php b/htdocs/user/hierarchy.php index 6c191f47da3..090bf33c73f 100644 --- a/htdocs/user/hierarchy.php +++ b/htdocs/user/hierarchy.php @@ -137,7 +137,7 @@ if (!is_array($user_arbo) && $user_arbo < 0) { //var_dump($fulltree); // Define data (format for treeview) $data = array(); - $data[0] = array('rowid' => 0, 'fk_menu' => -1, 'title' => "racine", 'mainmenu' => '', 'leftmenu' => '', 'fk_mainmenu' => '', 'fk_leftmenu' => ''); + $data[0] = array('rowid' => 0, 'fk_menu' => -1, 'title' => 'racine', 'mainmenu' => '', 'leftmenu' => '', 'fk_mainmenu' => '', 'fk_leftmenu' => ''); foreach ($fulltree as $key => $val) { $userstatic->id = $val['id']; @@ -255,9 +255,9 @@ if (!is_array($user_arbo) && $user_arbo < 0) { $li = ''.$langs->trans("WarningParentIDDoesNotExistAnymore").''; $entry = '
'.$li.'
'; $data[-2] = array( - 'rowid' => '-2', + 'rowid' => -2, 'fk_menu' => null, - 'statut' => '1', + 'statut' => 1, 'entry' => $entry ); } diff --git a/htdocs/webhook/target_card.php b/htdocs/webhook/target_card.php index 038b6af3267..9c6f33b50b2 100644 --- a/htdocs/webhook/target_card.php +++ b/htdocs/webhook/target_card.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -227,7 +228,8 @@ llxHeader('', $title, $help_url, '', 0, 0, $arrayofjs, $arrayofcss, '', 'mod-web if ($action == 'create') { if (empty($permissiontoadd)) { accessforbidden('NotEnoughPermissions', 0, 1); - exit; + // @phan-suppress-next-line PhanPluginUnreachableCode + exit; // accessforbidden already exits @phpstan-ignore-line } print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("Target")), '', 'object_'.$object->picto); diff --git a/htdocs/webportal/controllers/document.controller.class.php b/htdocs/webportal/controllers/document.controller.class.php index fa8690343ff..2efd83fd953 100644 --- a/htdocs/webportal/controllers/document.controller.class.php +++ b/htdocs/webportal/controllers/document.controller.class.php @@ -1,6 +1,7 @@ + * 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 @@ -16,11 +17,11 @@ * along with this program. If not, see . */ - /** - * \file htdocs/webportal/controllers/document.controller.class.php - * \ingroup webportal - * \brief This file is a controller for documents - */ +/** +* \file htdocs/webportal/controllers/document.controller.class.php +* \ingroup webportal +* \brief This file is a controller for documents +*/ require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; @@ -117,11 +118,9 @@ class DocumentController extends Controller // Security check if (empty($modulepart)) { httponly_accessforbidden('Bad link. Bad value for parameter modulepart', 400); - exit; } if (empty($original_file)) { httponly_accessforbidden('Bad link. Missing identification to find file (original_file)', 400); - exit; } // get original file diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 40eb51f5bfd..3cc5696f86a 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -90,7 +90,6 @@ parameters: - '#(?:(?:Asset::addDepreciationL|Facture(?:(?:(?:Fournisseur)?::add|Fournisseur::update)l))ine\(\)|calcul_price_total|(?:loanCalcMonthlyPaymen|print_paypal_redirec)t) expects float, string given.#' - '#(?:F(?:acture(?:(?:Fournisseur)?Rec::addline\(\))|ichinterRec::addLineRec\(\))|dolMd2Html) expects string\|null,#' - '#::printStdColumnContent\(\) expects string, float(\|(int|array)(\<.*\>)?)* given.#' - - '#::HTML2OpenIDServer\(\) expects string, array given.#' - '# dol_stringtotime expects string, DateTime given.#' - '#expects string, bool\|mysqli_result\|resource given.#' - '#(?: DoliDBPgsql::fetch_row\(\)) expects resource, PgSql\\Result given\.#' @@ -116,6 +115,10 @@ parameters: - '#Property (?:(?:(?:(?:AgendaEven|Cont(?:r?ac))t|Do(?:libarrApiAcces|nation)|ExpenseReport|In(?:tervention|voice)|Order|Pro(?:duct|posal)|S(?:alarie|(?:hip|tockMove)ment|upplier(?:Invoice|Order|Proposal))|T(?:ask|hirdpartie|icket)|Warehouse)s|Webhook|Zapier)::.*) no value type specified in iterable type array#' - '#Property RemiseCheque::\$account_id \(int\) does not accept string\.#' - '#Property Contact::\$roles \(array\) does not accept non-empty-array\.#' + - '# calcul_price_total expects array\{string, int\|string, string, int\|string, string, string\}\|array\{string, int\|string, string, string\}, array\{\} given\.#' + - '#(?: ftp_(?:(?:raw|n)list)) expects FTP.Connection, resource given\.#' + - '#Function getURLContent\(\) should return array#' + - '#SimpleOpenID::HTML2OpenIDServer\(\) expects string#' internalErrorsCountLimit: 50 cache: diff --git a/scripts/invoices/rebuild_merge_pdf.php b/scripts/invoices/rebuild_merge_pdf.php index 3b1af79a369..774d5a78754 100755 --- a/scripts/invoices/rebuild_merge_pdf.php +++ b/scripts/invoices/rebuild_merge_pdf.php @@ -3,6 +3,7 @@ /* * Copyright (C) 2009-2012 Laurent Destailleur * 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 @@ -87,7 +88,7 @@ $datebeforedate = ''; $paymentdateafter = ''; $paymentdatebefore = ''; $paymentonbankid = 0; -$thirdpartiesid = 0; +$thirdpartiesid = array(); foreach ($argv as $key => $value) { $found = false; @@ -215,6 +216,9 @@ foreach ($argv as $key => $value) { rebuild_merge_pdf_usage(); exit(1); } + + $thirdpartiesid = array_map('intval', $thirdpartiesid); + '@phan-var-force int[] $thirdpartiesid'; } // Check if an option and a filter has been provided