diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index b29ae8aa8090e..671a266c767c9 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -106,7 +106,7 @@ jobs: ls -l ~/.cache/pre-commit/ - name: Convert Raw Log to Annotations - uses: mdeweerd/logToCheckStyle@2024.3.2 + uses: mdeweerd/logToCheckStyle@v2024.3.4 if: ${{ failure() }} with: in: ${{ env.RAW_LOG }} diff --git a/.github/workflows/windows-ci.yaml b/.github/workflows/windows-ci.yaml index edcb9d392265f..cb46705515679 100644 --- a/.github/workflows/windows-ci.yaml +++ b/.github/workflows/windows-ci.yaml @@ -150,7 +150,7 @@ jobs: for /f "tokens=2 delims==" %%A in ('doskey /m:err') do EXIT /B %%A - name: Convert Raw Log to Annotations - uses: mdeweerd/logToCheckStyle@2024.3.2 + uses: mdeweerd/logToCheckStyle@v2024.3.4 if: ${{ failure() }} with: in: ${{ env.PHPUNIT_LOG }} diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 8c6c44e90f3fb..f39b12620644b 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -10,25 +10,20 @@ return [ // # Issue statistics: // PhanParamSignatureMismatch : 25+ occurrences - // PhanTypeMismatchReturnNullable : 20+ occurrences // PhanPluginSuspiciousParamPosition : 15+ occurrences // PhanUndeclaredConstant : 15+ occurrences // PhanPluginDuplicateExpressionBinaryOp : 10+ occurrences - // PhanTypeArraySuspiciousNull : 10+ occurrences - // PhanTypeMismatchReturn : 10+ occurrences + // PhanTypeMismatchReturn : 8 occurrences // PhanRedefineFunctionInternal : 6 occurrences + // PhanTypeArraySuspiciousNull : 6 occurrences // PhanParamTooMany : 4 occurrences - // PhanTypeMismatchPropertyProbablyReal : 2 occurrences + // PhanTypeMismatchReturnNullable : 3 occurrences // PhanAccessMethodProtected : 1 occurrence // PhanAccessPropertyStaticAsNonStatic : 1 occurrence // PhanNoopStringLiteral : 1 occurrence - // PhanPluginAlwaysReturnFunction : 1 occurrence // Currently, file_suppressions and directory_suppressions are the only supported suppressions 'file_suppressions' => [ - 'htdocs/adherents/class/adherent.class.php' => ['PhanTypeMismatchReturnNullable'], - 'htdocs/adherents/class/adherentstats.class.php' => ['PhanTypeMismatchReturnNullable'], - 'htdocs/adherents/stats/geo.php' => ['PhanTypeArraySuspiciousNull'], 'htdocs/adherents/type.php' => ['PhanPluginDuplicateExpressionBinaryOp'], 'htdocs/admin/receiptprinter.php' => ['PhanRedefineFunctionInternal'], 'htdocs/api/class/api_documents.class.php' => ['PhanPluginDuplicateExpressionBinaryOp'], @@ -36,10 +31,7 @@ return [ 'htdocs/categories/class/api_categories.class.php' => ['PhanAccessMethodProtected'], 'htdocs/categories/viewcat.php' => ['PhanPluginDuplicateExpressionBinaryOp'], 'htdocs/collab/index.php' => ['PhanParamTooMany'], - 'htdocs/comm/action/class/actioncomm.class.php' => ['PhanTypeMismatchReturnNullable'], - 'htdocs/comm/action/index.php' => ['PhanTypeArraySuspiciousNull'], 'htdocs/comm/mailing/card.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/comm/propal/class/api_proposals.class.php' => ['PhanTypeMismatchReturnNullable'], 'htdocs/compta/cashcontrol/cashcontrol_card.php' => ['PhanPluginDuplicateExpressionBinaryOp'], 'htdocs/compta/prelevement/class/bonprelevement.class.php' => ['PhanParamTooMany'], 'htdocs/compta/prelevement/create.php' => ['PhanPluginSuspiciousParamPosition'], @@ -47,24 +39,15 @@ return [ 'htdocs/core/class/commonobject.class.php' => ['PhanTypeMismatchReturnNullable'], 'htdocs/core/class/extrafields.class.php' => ['PhanTypeMismatchReturnNullable'], 'htdocs/core/class/html.form.class.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/core/class/html.formprojet.class.php' => ['PhanTypeMismatchReturnNullable'], - 'htdocs/core/class/smtps.class.php' => ['PhanTypeMismatchReturnNullable'], - 'htdocs/core/class/stats.class.php' => ['PhanTypeMismatchReturnNullable'], 'htdocs/core/db/mysqli.class.php' => ['PhanParamSignatureMismatch'], 'htdocs/core/db/pgsql.class.php' => ['PhanParamSignatureMismatch'], 'htdocs/core/db/sqlite3.class.php' => ['PhanParamSignatureMismatch', 'PhanTypeMismatchReturnNullable'], 'htdocs/core/get_info.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/core/lib/date.lib.php' => ['PhanTypeMismatchReturnNullable'], 'htdocs/core/lib/files.lib.php' => ['PhanPluginDuplicateExpressionBinaryOp'], - 'htdocs/core/lib/functions.lib.php' => ['PhanParamTooMany', 'PhanPluginAlwaysReturnFunction', 'PhanRedefineFunctionInternal'], - 'htdocs/core/lib/functions2.lib.php' => ['PhanTypeMismatchReturnNullable'], - 'htdocs/core/lib/pdf.lib.php' => ['PhanTypeMismatchReturnNullable'], + 'htdocs/core/lib/functions.lib.php' => ['PhanParamTooMany', 'PhanRedefineFunctionInternal'], 'htdocs/core/lib/price.lib.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/core/lib/website.lib.php' => ['PhanTypeMismatchReturnNullable'], - 'htdocs/core/modules/DolibarrModules.class.php' => ['PhanTypeMismatchReturnNullable'], 'htdocs/core/modules/movement/doc/pdf_standard.modules.php' => ['PhanPluginDuplicateExpressionBinaryOp'], 'htdocs/core/modules/mrp/doc/pdf_vinci.modules.php' => ['PhanTypeArraySuspiciousNull'], - 'htdocs/core/modules/societe/modules_societe.class.php' => ['PhanTypeMismatchReturn'], 'htdocs/core/modules/syslog/mod_syslog_file.php' => ['PhanParamSignatureMismatch'], 'htdocs/core/modules/syslog/mod_syslog_syslog.php' => ['PhanParamSignatureMismatch'], 'htdocs/don/class/don.class.php' => ['PhanParamTooMany'], @@ -76,17 +59,12 @@ return [ 'htdocs/mrp/class/mo.class.php' => ['PhanParamSignatureMismatch'], 'htdocs/product/admin/product_tools.php' => ['PhanNoopStringLiteral'], 'htdocs/product/class/product.class.php' => ['PhanTypeMismatchReturn'], - 'htdocs/projet/class/project.class.php' => ['PhanTypeMismatchReturnNullable'], - 'htdocs/projet/class/projectstats.class.php' => ['PhanTypeMismatchReturnNullable'], - 'htdocs/projet/class/task.class.php' => ['PhanTypeMismatchReturnNullable'], 'htdocs/projet/tasks/list.php' => ['PhanTypeArraySuspiciousNull'], 'htdocs/public/payment/paymentok.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/societe/class/companybankaccount.class.php' => ['PhanParamSignatureMismatch'], - 'htdocs/stripe/admin/stripe.php' => ['PhanDeprecatedFunction'], 'htdocs/stripe/class/actions_stripe.class.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/takepos/invoice.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/variants/class/ProductCombination.class.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/website/class/website.class.php' => ['PhanTypeMismatchReturnNullable'], 'internal' => ['PhanUndeclaredConstant'], ], // 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed. diff --git a/dev/translation/dynamic_translation_keys.lst b/dev/translation/dynamic_translation_keys.lst index 6be815d4eca57..47ab2e14a7986 100644 --- a/dev/translation/dynamic_translation_keys.lst +++ b/dev/translation/dynamic_translation_keys.lst @@ -40,6 +40,7 @@ Reservation ACCOUNTING_ACCOUNT_CUSTOMER ACCOUNTING_ACCOUNT_CUSTOMER_Desc ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY +ACCOUNTING_ACCOUNT_EXPENSEREPORT ACCOUNTING_ACCOUNT_SUPPLIER ACCOUNTING_ACCOUNT_SUPPLIER_Desc ACCOUNTING_ACCOUNT_SUSPENSE diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index c6ce7429708af..f71fa705c3f74 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -560,12 +560,13 @@ public function makeSubstitution($text) * Return translated label by the nature of a adherent (physical or moral) * * @param string $morphy Nature of the adherent (physical or moral) - * @param int $addbadge Add badge (1=Full label, 2=First letters only) + * @param int<0,2> $addbadge Add badge (1=Full label, 2=First letters only) * @return string Label */ public function getmorphylib($morphy = '', $addbadge = 0) { global $langs; + $s = ''; // Clean var if (!$morphy) { @@ -573,7 +574,6 @@ public function getmorphylib($morphy = '', $addbadge = 0) } if ($addbadge) { - $s = ''; $labeltoshowm = $langs->trans("Moral"); $labeltoshowp = $langs->trans("Physical"); if ($morphy == 'phy') { diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index f99b20f86d5ef..612f408edd9a3 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -3,6 +3,7 @@ * Copyright (c) 2005-2011 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2023 Waël Almoman + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -168,15 +169,15 @@ public function getAllByYear() /** * Return count of member by status group by adh type, total and average * - * @param int $numberYears Number of years to scan (0 = all) - * @return array Array with total of draft, pending, uptodate, expired, resiliated for each member type + * @param int $numberYears Number of years to scan (0 = all) + * @return array Array with total of draft, pending, uptodate, expired, resiliated for each member type */ public function countMembersByTypeAndStatus($numberYears = 0) { global $user; $now = dol_now(); - $endYear = date('Y'); + $endYear = (int) date('Y'); $startYear = $endYear - $numberYears; $sql = "SELECT t.rowid as fk_adherent_type, t.libelle as label"; @@ -224,7 +225,7 @@ public function countMembersByTypeAndStatus($numberYears = 0) 'members_resiliated' => (int) $objp->members_resiliated ); $totalrow = 0; - foreach ($MembersCountArray[$objp->fk_adherent_type] as $key=>$nb) { + foreach ($MembersCountArray[$objp->fk_adherent_type] as $key => $nb) { if ($key != 'label') { $totalrow += $nb; $totalstatus[$key] += $nb; @@ -244,16 +245,17 @@ public function countMembersByTypeAndStatus($numberYears = 0) /** * Return count of member by status group by adh type, total and average * - * @param int $numberYears Number of years to scan (0 = all) - * @return array Array with total of draft, pending, uptodate, expired, resiliated for each member tag + * @param int $numberYears Number of years to scan (0 = all) + * @return array Array with total of draft, pending, uptodate, expired, resiliated for each member tag */ public function countMembersByTagAndStatus($numberYears = 0) { global $user; $now = dol_now(); - $endYear = date('Y'); + $endYear = (int) date('Y'); $startYear = $endYear - $numberYears; + $MembersCountArray = []; $sql = "SELECT c.rowid as fk_categorie, c.label as label"; $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_DRAFT, "'members_draft'", 'NULL').") as members_draft"; @@ -282,7 +284,6 @@ public function countMembersByTagAndStatus($numberYears = 0) if ($result) { $num = $this->db->num_rows($result); $i = 0; - $MembersCountArray = []; $totalstatus = array( 'label' => 'Total', 'members_draft' => 0, @@ -304,7 +305,7 @@ public function countMembersByTagAndStatus($numberYears = 0) 'members_resiliated' => (int) $objp->members_resiliated ); $totalrow = 0; - foreach ($MembersCountArray[$objp->fk_categorie] as $key=>$nb) { + foreach ($MembersCountArray[$objp->fk_categorie] as $key => $nb) { if ($key != 'label') { $totalrow += $nb; $totalstatus[$key] += $nb; diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index e8d85f21c763d..47bded0df2953 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -6,6 +6,7 @@ * Copyright (C) 2014-2016 Juanjo Menent * Copyright (C) 2018 Alexandre Spangaro * Copyright (C) 2021-2023 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 @@ -203,6 +204,7 @@ } } $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan //var_dump($arrayfields);exit; // Security check diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index f4f77bcaa9da0..09e73b188f864 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1393,7 +1393,7 @@ public function getActions($socid = 0, $fk_element = 0, $elementtype = '', $filt * * @param User $user Object user * @param int $load_state_board Load indicator array this->nb - * @return WorkboardResponse|int Return integer <0 if KO, WorkboardResponse if OK + * @return WorkboardResponse|int<-1,1> Return integer <0 if KO, WorkboardResponse if OK */ public function load_board($user, $load_state_board = 0) { @@ -1462,7 +1462,7 @@ public function load_board($user, $load_state_board = 0) } $this->db->free($resql); - if (empty($load_state_board)) { + if (empty($load_state_board) && $response instanceof WorkboardResponse) { return $response; } else { return 1; diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 6eb5db860568b..3abd25ae840eb 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -177,6 +177,7 @@ $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan $result = restrictedArea($user, 'agenda', 0, '', 'myactions'); if ($user->socid && $socid) { diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index aa1e3d0e9800c..546d40d052df0 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2020 Thibault FOUCART * Copyright (C) 2022 ATM Consulting * Copyright (C) 2022 OpenDSI + * 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 @@ -410,6 +411,7 @@ public function postLines($id, $request_data = null) } $errors = []; + $updateRes = 0; $this->db->begin(); foreach ($request_data as $TData) { diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index e01dd74859eb4..22703534d89b4 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -227,6 +227,7 @@ $object->fields = dol_sort_array($object->fields, 'position'); //$arrayfields['anotherfield'] = array('type'=>'integer', 'label'=>'AnotherField', 'checked'=>1, 'enabled'=>1, 'position'=>90, 'csslist'=>'right'); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan // Security check diff --git a/htdocs/commande/list_det.php b/htdocs/commande/list_det.php index 2046845b8db8f..d9435aea40fb2 100644 --- a/htdocs/commande/list_det.php +++ b/htdocs/commande/list_det.php @@ -231,6 +231,7 @@ $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan if (!$user->hasRight('societe', 'client', 'voir')) { $search_sale = $user->id; @@ -1295,6 +1296,7 @@ // Détail commande if (!empty($arrayfields['rowid']['checked'])) { print_liste_field_titre($arrayfields['rowid']['label'], $_SERVER["PHP_SELF"], 'rowid', '', $param, '', $sortfield, $sortorder); + '@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan } if (!empty($arrayfields['pr.ref']['checked'])) { print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], 'pr.ref', '', $param, '', $sortfield, $sortorder); diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 480c36cd07e73..76a3f8e2abd6a 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -5,6 +5,7 @@ * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2020 Tobias Sekan + * 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 @@ -125,6 +126,7 @@ $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan $permissiontoadd = $user->hasRight('banque', 'modifier'); $permissiontodelete = $user->hasRight('banque', 'configurer'); diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index 8a2aa9178f755..d41e3c2e4a645 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -3,6 +3,7 @@ * Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2018 Frédéric France * Copyright (C) 2020 Tobias Sekan + * 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 @@ -172,6 +173,7 @@ ); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan // Security check $socid = GETPOSTINT("socid"); diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 63e01dac397d0..0c5526d0ae96d 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -9,6 +9,7 @@ * Copyright (C) 2015-2021 Alexandre Spangaro * Copyright (C) 2016 Meziane Sof * Copyright (C) 2023 William Mead + * 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 @@ -161,6 +162,7 @@ $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan if ($socid > 0) { $tmpthirdparty = new Societe($db); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 13995e6cc0b1a..63cee7e87090b 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -293,6 +293,7 @@ $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan if (!$user->hasRight('societe', 'client', 'voir')) { $search_sale = $user->id; diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index 7243c91f3c3fe..c639acd036e79 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -4,6 +4,7 @@ * Copyright (C) 2009-2012 Regis Houssin * Copyright (C) 2014 Alexandre Spangaro * Copyright (C) 2016 Juanjo Menent + * 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 @@ -99,6 +100,7 @@ 'bc.statut' => array('label' => "Status", 'checked' => 1, 'position' => 70) ); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('chequelist')); diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 12c2ec797d8cb..2ae8ee73d74ac 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -9,6 +9,7 @@ * Copyright (C) 2018-2021 Ferran Marcet * Copyright (C) 2018 Charlene Benke * Copyright (C) 2020 Tobias Sekan + * 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 @@ -110,6 +111,7 @@ 'p.statut' => array('label' => "Status", 'checked' => 1, 'position' => 90, 'enabled' => (getDolGlobalString('BILL_ADD_PAYMENT_VALIDATION'))), ); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('paymentlist')); diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 5f07abd308abe..d31e12f575bed 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -7,6 +7,7 @@ * Copyright (C) 2020 Tobias Sekan * Copyright (C) 2021 Gauthier VERDOL * Copyright (C) 2021-2023 Alexandre Spangaro + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -114,6 +115,7 @@ } $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('sclist')); diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 573c3d5028949..68e84da8be24d 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -5,6 +5,7 @@ * Copyright (C) 2011-2019 Alexandre Spangaro * Copyright (C) 2020 Tobias Sekan * Copyright (C) 2021 Gauthier VERDOL + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -95,6 +96,7 @@ } $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('salestaxeslist')); diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index d391b2e8d4b42..c7058f80d684e 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -12,6 +12,7 @@ * Copyright (C) 2019 Frédéric France * Copyright (C) 2019 Josep Lluís Amador * Copyright (C) 2020 Open-Dsi + * 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 @@ -268,6 +269,7 @@ $object->fields = dol_sort_array($object->fields, 'position'); //$arrayfields['anotherfield'] = array('type'=>'integer', 'label'=>'AnotherField', 'checked'=>1, 'enabled'=>1, 'position'=>90, 'csslist'=>'right'); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan if (($id > 0 || !empty($ref)) && $action != 'add') { diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index a9c49bbeaab1f..43c7b8da85b0e 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -9,6 +9,7 @@ * Copyright (C) 2016-2018 Ferran Marcet * Copyright (C) 2019 Nicolas Zabouri * Copyright (C) 2021 Alexandre Spangaro + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -194,6 +195,7 @@ $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan if (!$user->hasRight('societe', 'client', 'voir')) { $search_sale = $user->id; diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index a2542669485fc..c61e72867f2cc 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -7,6 +7,7 @@ * Copyright (C) 2018 Frédéric France * Copyright (C) 2019 Juanjo Menent * Copyright (C) 2023-2024 William Mead + * 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 @@ -139,6 +140,7 @@ $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan $permissiontoread = $user->hasRight('contrat', 'lire'); $permissiontoadd = $user->hasRight('contrat', 'creer'); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b826ea69205e8..41a9a69114dd8 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7269,7 +7269,7 @@ public function showInputField($val, $key, $value, $moreparam = '', $keysuffix = if (!preg_match('/search_/', $keyprefix)) { // If keyprefix is search_ or search_options_, we must just use a simple text field require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, false, ROWS_5, '90%'); - $out = $doleditor->Create(1, '', true, '', '', '', $morecss); + $out = (string) $doleditor->Create(1, '', true, '', '', '', $morecss); } else { $out = ''; } @@ -7277,7 +7277,7 @@ public function showInputField($val, $key, $value, $moreparam = '', $keysuffix = if (!preg_match('/search_/', $keyprefix)) { // If keyprefix is search_ or search_options_, we must just use a simple text field require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, isModEnabled('fckeditor') && $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5, '90%'); - $out = $doleditor->Create(1, '', true, '', '', $moreparam, $morecss); + $out = (string) $doleditor->Create(1, '', true, '', '', $moreparam, $morecss); } else { $out = ''; } diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 9bbc5e750188c..b6f50754c6b87 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2018 Charlene Benke * 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 @@ -686,7 +687,7 @@ public function select_element($table_element, $socid = 0, $morecss = '', $limit * @param string $morecss Add more css * @param int $noadmininfo 0=Add admin info, 1=Disable admin info * @param int $addcombojs 1=Add a js combo - * @return int|string The HTML select list of element or '' if nothing or -1 if KO + * @return int<-1,-1>|string The HTML select list of element or '' if nothing or -1 if KO */ public function selectOpportunityStatus($htmlname, $preselected = '-1', $showempty = 1, $useshortlabel = 0, $showallnone = 0, $showpercent = 0, $morecss = '', $noadmininfo = 0, $addcombojs = 0) { @@ -701,6 +702,7 @@ public function selectOpportunityStatus($htmlname, $preselected = '-1', $showemp if ($resql) { $num = $this->db->num_rows($resql); $i = 0; + $sellist = ''; if ($num > 0) { $sellist = ''; $newcardbutton = ''; -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition')); $newcardbutton .= dolGetButtonTitleSeparator(); $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/variants/card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); @@ -561,7 +563,7 @@ // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters = array('arrayfields'=>$arrayfields); +$parameters = array('arrayfields' => $arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -618,7 +620,7 @@ // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); +$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -757,7 +759,7 @@ // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Other @@ -826,7 +828,7 @@ $db->free($resql); -$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index bd5e25f193245..e8d198f61b3f5 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -1868,6 +1868,8 @@ public function compareFichierModifie($dossierSource, $dossierDestination, $fich $numOfPageDest = $this->extractNumberFromFilename($fileNeeded['name']); $differences = $this->showDifferences($destContent, $sourceContent, array($numOfPageDest,$numOfPageSource)); $differences['file_destination'] = $fileNeeded; + } else { + $differences = array(); } return $differences; } diff --git a/htdocs/workstation/workstation_list.php b/htdocs/workstation/workstation_list.php index 2d1e9d9fefc45..3638739a101cf 100644 --- a/htdocs/workstation/workstation_list.php +++ b/htdocs/workstation/workstation_list.php @@ -2,6 +2,7 @@ /* Copyright (C) 2007-2017 Laurent Destailleur * Copyright (C) 2020 Gauthier VERDOL + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -149,6 +150,7 @@ $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan $permissiontoread = $user->hasRight('workstation', 'workstation', 'read'); $permissiontoadd = $user->hasRight('workstation', 'workstation', 'write'); diff --git a/test/phpunit/DoliDBTest.php b/test/phpunit/DoliDBTest.php index c2a0de05a20b9..adafc6a676c5c 100644 --- a/test/phpunit/DoliDBTest.php +++ b/test/phpunit/DoliDBTest.php @@ -48,6 +48,41 @@ */ class DoliDBTest extends CommonClassTest { + /** + * testDDLUpdateField + * + * @return int + */ + public function testDDLCreateTable() + { + global $conf,$user,$langs,$db; + $conf = $this->savconf; + $user = $this->savuser; + $langs = $this->savlangs; + $db = $this->savdb; + + $namedic = MAIN_DB_PREFIX.'tmptesttabletoremove'; + + $res = $db->DDLDropTable($namedic); + + $columns = array( + 'rowid' => array('type' => 'integer', 'value' => 11, 'AUTO_INCREMENT PRIMARY KEY'), + 'code' => array('type' => 'varchar', 'value' => 255, 'null'=>'NOT NULL'), + 'label' => array('type' => 'varchar', 'value' => 255, 'null'=>'NOT NULL'), + 'position' => array('type' => 'integer', 'value' => 11, 'null'=>'NULL'), + 'use_default' => array('type' => 'varchar', 'value' => 11, 'default'=>'1'), + 'active' => array('type' => 'integer', 'value' => 3) + ); + $primaryKey = 'rowid'; + + print __METHOD__.' db->type = '.$db->type."\n"; + + $res = $db->DDLCreateTable($namedic, $columns, $primaryKey, ""); + + $this->assertEquals(1, $res); + print __METHOD__." result=".$res."\n"; + } + /** * testDDLUpdateField * @@ -84,6 +119,7 @@ public function testDDLUpdateField() $field_desc = array('type'=>'varchar', 'value'=>'16', 'null'=>'NOT NULL', 'default'=>'aaaabbbbccccdddd'); $result = $db->DDLUpdateField($db->prefix().'c_paper_format', 'code', $field_desc); + $this->assertEquals(1, $result); print __METHOD__." result=".$result."\n";