diff --git a/dev/build/phpstan/phpstan-baseline.neon b/dev/build/phpstan/phpstan-baseline.neon index 402c60dd326..57f70f9eef5 100644 --- a/dev/build/phpstan/phpstan-baseline.neon +++ b/dev/build/phpstan/phpstan-baseline.neon @@ -888,12 +888,6 @@ parameters: count: 1 path: ../../../htdocs/asset/card.php - - - message: '#^Property Asset\:\:\$fields \(array\\|string, position\: int, notnull\?\: int, visible\: int\<\-6, 6\>\|string, alwayseditable\?\: int\<0, 1\>\|string, \.\.\.\}\>\) does not accept non\-empty\-array\\|string, position\: int, notnull\?\: int, visible\: int\<\-6, 6\>\|string, alwayseditable\?\: int\<0, 1\>\|string, \.\.\.\}\>\.$#' - identifier: assign.propertyType - count: 1 - path: ../../../htdocs/asset/card.php - - message: '#^Call to function is_callable\(\) with array\{\$this\(AssetDepreciationOptions\), ''validateField''\} will always evaluate to true\.$#' identifier: function.alreadyNarrowedType @@ -1146,12 +1140,6 @@ parameters: count: 1 path: ../../../htdocs/bookmarks/bookmarks.lib.php - - - message: '#^Variable \$result might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/categories/card.php - - message: '#^Loose comparison using \=\= between ''hierarchy'' and ''common'' will always evaluate to false\.$#' identifier: equal.alwaysFalse @@ -1164,12 +1152,6 @@ parameters: count: 1 path: ../../../htdocs/categories/categorie_list.php - - - message: '#^Strict comparison using \=\=\= between array\{type\: string, label\: string, langfile\?\: string, enabled\: int\<0, 2\>\|string, position\: int, notnull\?\: int, visible\: int\<\-6, 6\>\|string, alwayseditable\?\: int\<0, 1\>\|string, \.\.\.\} and null will always evaluate to false\.$#' - identifier: identical.alwaysFalse - count: 1 - path: ../../../htdocs/categories/categorie_list.php - - message: '#^If condition is always true\.$#' identifier: if.alwaysTrue @@ -1302,12 +1284,6 @@ parameters: count: 2 path: ../../../htdocs/comm/action/index.php - - - message: '#^Variable \$socid might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/comm/action/info.php - - message: '#^Call to function is_array\(\) with array\ will always evaluate to true\.$#' identifier: function.alreadyNarrowedType @@ -1980,12 +1956,6 @@ parameters: count: 3 path: ../../../htdocs/compta/cashcontrol/cashcontrol_card.php - - - message: '#^Strict comparison using \=\=\= between array\{type\: string, label\: string, langfile\?\: string, enabled\: int\<0, 2\>\|string, position\: int, notnull\?\: int, visible\: int\<\-6, 6\>\|string, alwayseditable\?\: int\<0, 1\>\|string, \.\.\.\} and null will always evaluate to false\.$#' - identifier: identical.alwaysFalse - count: 1 - path: ../../../htdocs/compta/cashcontrol/cashcontrol_list.php - - message: '#^Call to function method_exists\(\) with \$this\(CashControl\) and ''getLibStatut'' will always evaluate to true\.$#' identifier: function.alreadyNarrowedType @@ -4176,12 +4146,6 @@ parameters: count: 1 path: ../../../htdocs/core/class/html.formother.class.php - - - message: '#^If condition is always false\.$#' - identifier: if.alwaysFalse - count: 1 - path: ../../../htdocs/core/class/html.formprojet.class.php - - message: '#^Variable \$labeltoshow might not be defined\.$#' identifier: variable.undefined @@ -6756,18 +6720,6 @@ parameters: count: 2 path: ../../../htdocs/fourn/commande/card.php - - - message: '#^Variable \$line might not be defined\.$#' - identifier: variable.undefined - count: 3 - path: ../../../htdocs/fourn/commande/card.php - - - - message: '#^Variable \$num might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/fourn/commande/card.php - - message: '#^Right side of && is always false\.$#' identifier: booleanAnd.rightAlwaysFalse @@ -6780,12 +6732,6 @@ parameters: count: 2 path: ../../../htdocs/fourn/commande/dispatch.php - - - message: '#^Variable \$comment might not be defined\.$#' - identifier: variable.undefined - count: 3 - path: ../../../htdocs/fourn/commande/dispatch.php - - message: '#^Variable \$product might not be defined\.$#' identifier: variable.undefined @@ -7314,12 +7260,6 @@ parameters: count: 1 path: ../../../htdocs/hrm/job_card.php - - - message: '#^Strict comparison using \=\=\= between array\{type\: string, label\: string, langfile\?\: string, enabled\: int\<0, 2\>\|string, position\: int, notnull\?\: int, visible\: int\<\-6, 6\>\|string, alwayseditable\?\: int\<0, 1\>\|string, \.\.\.\} and null will always evaluate to false\.$#' - identifier: identical.alwaysFalse - count: 1 - path: ../../../htdocs/hrm/job_list.php - - message: '#^Comparison operation "\<" between int\<0, max\> and 0 is always false\.$#' identifier: smaller.alwaysFalse @@ -7332,12 +7272,6 @@ parameters: count: 1 path: ../../../htdocs/hrm/position.php - - - message: '#^Property Position\:\:\$fields \(array\\|string, position\: int, notnull\?\: int, visible\: int\<\-6, 6\>\|string, alwayseditable\?\: int\<0, 1\>\|string, \.\.\.\}\>\) does not accept non\-empty\-array\\|string, position\: int, notnull\?\: int, visible\: int\<\-6, 6\>\|string, alwayseditable\?\: int\<0, 1\>\|string, \.\.\.\}\>\.$#' - identifier: assign.propertyType - count: 1 - path: ../../../htdocs/hrm/position_agenda.php - - message: '#^If condition is always true\.$#' identifier: if.alwaysTrue @@ -8226,12 +8160,6 @@ parameters: count: 1 path: ../../../htdocs/modulebuilder/template/myobject_list.php - - - message: '#^Strict comparison using \=\=\= between array\{type\: string, label\: string, langfile\?\: string, enabled\: int\<0, 2\>\|string, position\: int, notnull\?\: int, visible\: int\<\-6, 6\>\|string, alwayseditable\?\: int\<0, 1\>\|string, \.\.\.\} and null will always evaluate to false\.$#' - identifier: identical.alwaysFalse - count: 1 - path: ../../../htdocs/modulebuilder/template/myobject_list.php - - message: '#^Negated boolean expression is always true\.$#' identifier: booleanNot.alwaysTrue @@ -8460,12 +8388,6 @@ parameters: count: 1 path: ../../../htdocs/partnership/class/partnership.class.php - - - message: '#^Call to function property_exists\(\) with \$this\(Partnership\) and ''fk_soc'' will always evaluate to true\.$#' - identifier: function.alreadyNarrowedType - count: 1 - path: ../../../htdocs/partnership/class/partnership.class.php - - message: '#^Call to function property_exists\(\) with \$this\(Partnership\) and ''thirdparty'' will always evaluate to true\.$#' identifier: function.alreadyNarrowedType @@ -8505,7 +8427,7 @@ parameters: - message: '#^Negated boolean expression is always true\.$#' identifier: booleanNot.alwaysTrue - count: 2 + count: 1 path: ../../../htdocs/partnership/class/partnership.class.php - @@ -8538,12 +8460,6 @@ parameters: count: 1 path: ../../../htdocs/partnership/partnership_card.php - - - message: '#^Variable \$adht might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/partnership/partnership_card.php - - message: '#^Variable \$soc might not be defined\.$#' identifier: variable.undefined @@ -8556,12 +8472,6 @@ parameters: count: 1 path: ../../../htdocs/partnership/partnership_list.php - - - message: '#^Ternary operator condition is always true\.$#' - identifier: ternary.alwaysTrue - count: 2 - path: ../../../htdocs/partnership/partnership_list.php - - message: '#^Right side of && is always true\.$#' identifier: booleanAnd.rightAlwaysTrue @@ -11586,12 +11496,6 @@ parameters: count: 1 path: ../../../htdocs/webhook/target_card.php - - - message: '#^Strict comparison using \=\=\= between array\{type\: string, label\: string, langfile\?\: string, enabled\: int\<0, 2\>\|string, position\: int, notnull\?\: int, visible\: int\<\-6, 6\>\|string, alwayseditable\?\: int\<0, 1\>\|string, \.\.\.\} and null will always evaluate to false\.$#' - identifier: identical.alwaysFalse - count: 1 - path: ../../../htdocs/webhook/triggerhistory_list.php - - message: '#^Result of && is always false\.$#' identifier: booleanAnd.alwaysFalse diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 40682345aa6..62f3427736b 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -89,7 +89,6 @@ return [ 'htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], 'htdocs/core/modules/delivery/mod_delivery_saphir.php' => ['PhanUndeclaredProperty'], 'htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php' => ['PhanTypeMismatchArgument'], - 'htdocs/core/modules/expedition/doc/pdf_espadon.modules.php' => ['PhanTypeMismatchArgument'], 'htdocs/core/modules/expensereport/doc/pdf_standard_expensereport.modules.php' => ['PhanUndeclaredProperty'], 'htdocs/core/modules/facture/doc/pdf_octopus.modules.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanUndeclaredProperty'], 'htdocs/core/modules/holiday/mod_holiday_immaculate.php' => ['PhanTypeMismatchArgument'], diff --git a/dev/tools/phan/config.php b/dev/tools/phan/config.php index 46d1d9335e9..0bc6b843033 100644 --- a/dev/tools/phan/config.php +++ b/dev/tools/phan/config.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2024-2026 MDW * Copyright (C) 2024-2025 Frédéric France * * This is the phan config file used by .github/workflows/phan.yml @@ -279,6 +279,7 @@ return [ 'dolibarr_main_db_encrypted_pass' => 'string', 'dolibarr_main_db_host' => 'string', 'dolibarr_main_db_pass' => 'string', + 'dolibarr_main_db_type' => '?string', 'dolibarr_main_demo' => 'string', 'dolibarr_main_document_root' => 'string', 'dolibarr_main_url_root' => 'string', diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index cd88e050ded..97382861d7a 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2015-2026 Alexandre Spangaro * Copyright (C) 2015-2020 Florian Henry * Copyright (C) 2018-2025 Frédéric France - * Copyright (C) 2024-2025 MDW + * Copyright (C) 2024-2026 MDW * Copyright (C) 2024 Jose MARTINEZ * Copyright (C) 2025 Nicolas Barrouillet * @@ -2947,7 +2947,7 @@ class BookKeeping extends CommonObject $income_statement_amount = 0; if (getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT')) { - $accounting_groups_used_for_income_statement = array_filter(array_map('trim', explode(',', getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT'))), 'strlen'); + $accounting_groups_used_for_income_statement = array_filter(array_map('trim', explode(',', getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT'))), 'strlen'); // @phpstan-ignore argument.type $pcg_type_filter = array(); foreach ($accounting_groups_used_for_income_statement as $item) { @@ -3073,8 +3073,8 @@ class BookKeeping extends CommonObject } if (!$error && is_object($journal)) { - $accounting_groups_used_for_balance_sheet_account = array_filter(array_map('trim', explode(',', getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT'))), 'strlen'); - $accounting_groups_used_for_income_statement = array_filter(array_map('trim', explode(',', getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT'))), 'strlen'); + $accounting_groups_used_for_balance_sheet_account = array_filter(array_map('trim', explode(',', getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT'))), 'strlen'); // @phpstan-ignore argument.type + $accounting_groups_used_for_income_statement = array_filter(array_map('trim', explode(',', getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT'))), 'strlen'); // @phpstan-ignore argument.type $pcg_type_filter = array(); $tmp = array_merge($accounting_groups_used_for_balance_sheet_account, $accounting_groups_used_for_income_statement); @@ -3217,8 +3217,8 @@ class BookKeeping extends CommonObject $bookkeeping->subledger_label = null; } else { */ - $bookkeeping->subledger_account = null; - $bookkeeping->subledger_label = null; + $bookkeeping->subledger_account = null; + $bookkeeping->subledger_label = null; //} $bookkeeping->numero_compte = $accountingaccount->account_number; @@ -3422,16 +3422,20 @@ class BookKeeping extends CommonObject $echecT = []; foreach ($toselect as $id) { if ($bookkeeping->fetch($id)) { - if ( !getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER')) { + if (!getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER')) { $accountcustcode = '411'; - } else $accountcustcode = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'); + } else { + $accountcustcode = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'); + } - if ( !getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER')) { + if (!getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER')) { $accountsuppcode = '401'; - } else $accountsuppcode = getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'); + } else { + $accountsuppcode = getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'); + } if (strpos($bookkeeping->numero_compte, $accountcustcode) === 0 || strpos($bookkeeping->numero_compte, $accountsuppcode) === 0) { - $echecT[]=$bookkeeping->numero_compte; + $echecT[] = $bookkeeping->numero_compte; continue; } @@ -3468,7 +3472,10 @@ class BookKeeping extends CommonObject if (!empty($echecImplode)) { $nbEchec = count(explode(',', $echecImplode)); - setEventMessages($nbEchec == 1 ? $langs->trans('NoAccountChangedWithAccountNumber') . ' ' . $echecImplode : $langs->trans('NoAccountsChangedWithAccountNumber') . ' ' . $echecImplode, null, 'errors' + setEventMessages( + $nbEchec == 1 ? $langs->trans('NoAccountChangedWithAccountNumber') . ' ' . $echecImplode : $langs->trans('NoAccountsChangedWithAccountNumber') . ' ' . $echecImplode, + null, + 'errors' ); } @@ -3731,7 +3738,6 @@ class BookKeeping extends CommonObject * @param string $code_journal Accounting journal code * @param int $docdate Date of the document * @return int int Return integer -1 if KO, 1 if OK - * */ public function newReturnAccount(array $toselect, $code_journal, $docdate) { @@ -3753,7 +3759,7 @@ class BookKeeping extends CommonObject $alreadyExtourneT = array(); if ($resqlAlreadyExtourne) { while ($obj4 = $this->db->fetch_object($resqlAlreadyExtourne)) { - $alreadyExtourneT []= $obj4->piece_num; + $alreadyExtourneT [] = $obj4->piece_num; } } diff --git a/htdocs/accountancy/closure/index.php b/htdocs/accountancy/closure/index.php index 8b8e64cf625..e56a49e9138 100644 --- a/htdocs/accountancy/closure/index.php +++ b/htdocs/accountancy/closure/index.php @@ -2,7 +2,7 @@ /* Copyright (C) 2019-2023 Open-DSI * Copyright (C) 2024 Frédéric France * Copyright (C) 2025-2026 Alexandre Spangaro - * Copyright (C) 2025 MDW + * Copyright (C) 2025-2026 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 @@ -122,8 +122,8 @@ if (empty($current_fiscal_period) && !empty($first_active_fiscal_period)) { } } -$accounting_groups_used_for_balance_sheet_account = array_filter(array_map('trim', explode(',', getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT'))), 'strlen'); -$accounting_groups_used_for_income_statement = array_filter(array_map('trim', explode(',', getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT'))), 'strlen'); +$accounting_groups_used_for_balance_sheet_account = array_filter(array_map('trim', explode(',', getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_BALANCE_SHEET_ACCOUNT'))), 'strlen'); // @phpstan-ignore argument.type +$accounting_groups_used_for_income_statement = array_filter(array_map('trim', explode(',', getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT'))), 'strlen'); // @phpstan-ignore argument.type /* diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php index 6d7c7b9ad60..626f315b22c 100644 --- a/htdocs/asset/card.php +++ b/htdocs/asset/card.php @@ -2,7 +2,7 @@ /* Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2018-2025 Alexandre Spangaro * Copyright (C) 2024-2025 Frédéric France - * Copyright (C) 2025 MDW + * Copyright (C) 2025-2026 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 @@ -198,7 +198,7 @@ if ($action == 'create') { print ''; } if (GETPOSTISSET('supplier_invoice_id')) { - $object->fields['supplier_invoice_id'] = array('type' => 'integer:FactureFournisseur:fourn/class/fournisseur.facture.class.php:1:entity IN (__SHARED_ENTITIES__)', 'label' => 'SupplierInvoice', 'enabled' => '1', 'noteditable' => 1, 'position' => 280, 'notnull' => 0, 'visible' => 1, 'index' => 1, 'validate' => '1',); + $object->fields['supplier_invoice_id'] = array('type' => 'integer:FactureFournisseur:fourn/class/fournisseur.facture.class.php:1:entity IN (__SHARED_ENTITIES__)', 'label' => 'SupplierInvoice', 'enabled' => '1', 'noteditable' => 1, 'position' => 280, 'notnull' => 0, 'visible' => 1, 'index' => 1, 'validate' => 1,); print ''; } diff --git a/htdocs/categories/categorie_list.php b/htdocs/categories/categorie_list.php index c5e2e989573..c1ce32da04a 100644 --- a/htdocs/categories/categorie_list.php +++ b/htdocs/categories/categorie_list.php @@ -1,7 +1,7 @@ * Copyright (C) 2024-2025 Frédéric France - * Copyright (C) 2025 MDW + * Copyright (C) 2025-2026 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 @@ -282,9 +282,6 @@ foreach ($search as $key => $val) { continue; } $field_spec = $object->fields[$key]; - if ($field_spec === null) { - continue; - } $mode_search = (($object->isInt($field_spec) || $object->isFloat($field_spec)) ? 1 : 0); if ((strpos($field_spec['type'], 'integer:') === 0) || (strpos($field_spec['type'], 'sellist:') === 0) || !empty($field_spec['arrayofkeyval'])) { if ($search[$key] == '-1' || ($search[$key] === '0' && !isset($field_spec['arrayofkeyval']['0']))) { diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index ab35d5e3aa0..9aa1f963be8 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -9,7 +9,7 @@ * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2018-2026 Frédéric France * Copyright (C) 2019 Ferran Marcet - * Copyright (C) 2024-2025 MDW + * Copyright (C) 2024-2026 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 @@ -332,7 +332,7 @@ if (empty($reshook) && $action == 'confirm_clone' && $confirm == 'yes' && $userc //$object->fetch($id); if (!empty($object->socpeopleassigned)) { reset($object->socpeopleassigned); - $object->contact_id = key($object->socpeopleassigned); + $object->contact_id = (int) key($object->socpeopleassigned); } $result = $object->createFromClone($user, GETPOSTINT('socid')); if ($result > 0) { @@ -980,7 +980,7 @@ if (empty($reshook) && $action == 'update' && $usercancreate) { $object->contact_id = GETPOSTINT("contactid"); if (empty($object->contact_id) && !empty($object->socpeopleassigned)) { reset($object->socpeopleassigned); - $object->contact_id = key($object->socpeopleassigned); + $object->contact_id = (int) key($object->socpeopleassigned); } $object->fk_project = GETPOSTINT("projectid"); $taskid = GETPOSTINT('taskid'); @@ -1583,7 +1583,7 @@ if ($action == 'create') { */ // limit date - $repeateventlimitdate = empty($repeateventlimitdate) ? (dol_now() + ((24 * 3600 * 365) + 1)) : $repeateventlimitdate; + $repeateventlimitdate = empty($repeateventlimitdate) ? (dol_now() + ((24 * 3600 * 365) + 1)) : $repeateventlimitdate; print '