From d154af4e41012874a13f9a549fddcb9e42c80945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 29 Sep 2024 13:03:58 +0200 Subject: [PATCH 1/5] fix phpstan (#31180) * fix phpstan * fix phpstan * fix phpstan * fix phpstan --------- Co-authored-by: Laurent Destailleur --- htdocs/blockedlog/class/blockedlog.class.php | 2 +- htdocs/core/class/html.form.class.php | 60 ++++++++++---------- phpstan.neon.dist | 2 +- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index dc5ce2b5729..b559ee84096 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -1220,7 +1220,7 @@ class BlockedLog require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $fingerprint = dol_hash(print_r($mysoc, true).getRandomPassword(1), '5'); + $fingerprint = dol_hash(print_r($mysoc, true).getRandomPassword(true), '5'); dolibarr_set_const($db, 'BLOCKEDLOG_ENTITY_FINGERPRINT', $fingerprint, 'chaine', 0, 'Numeric Unique Fingerprint', $conf->entity); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e705ea36bc8..a7bd8a5b5c7 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4653,17 +4653,17 @@ class Form * Return list of payment methods * Constant MAIN_DEFAULT_PAYMENT_TYPE_ID can used to set default value but scope is all application, probably not what you want. * - * @param string $selected Id or code or preselected payment mode - * @param string $htmlname Name of select field - * @param string $filtertype To filter on field type in llx_c_paiement ('CRDT' or 'DBIT' or array('code'=>xx,'label'=>zz)) - * @param int $format 0=id+label, 1=code+code, 2=code+label, 3=id+code - * @param int $empty 1=can be empty, 0 otherwise - * @param int $noadmininfo 0=Add admin info, 1=Disable admin info - * @param int $maxlength Max length of label - * @param int $active Active or not, -1 = all - * @param string $morecss Add more CSS on select tag - * @param int $nooutput 1=Return string, do not send to output - * @return string|void String for the HTML select component + * @param string $selected Id or code or preselected payment mode + * @param string $htmlname Name of select field + * @param string $filtertype To filter on field type in llx_c_paiement ('CRDT' or 'DBIT' or array('code'=>xx,'label'=>zz)) + * @param int $format 0=id+label, 1=code+code, 2=code+label, 3=id+code + * @param int $empty 1=can be empty, 0 otherwise + * @param int $noadmininfo 0=Add admin info, 1=Disable admin info + * @param int $maxlength Max length of label + * @param int $active Active or not, -1 = all + * @param string $morecss Add more CSS on select tag + * @param int<0,1> $nooutput 1=Return string, do not send to output + * @return string|void String for the HTML select component */ public function select_types_paiements($selected = '', $htmlname = 'paiementtype', $filtertype = '', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss = '', $nooutput = 0) { @@ -5120,7 +5120,7 @@ class Form * @param string $moreattrib To add more attribute on select * @param int $showcurrency Show currency in label * @param string $morecss More CSS - * @param int $nooutput 1=Return string, do not send to output + * @param int<0,1> $nooutput 1=Return string, do not send to output * @return int|string If noouput=0: Return integer <0 if error, Num of bank account found if OK (0, 1, 2, ...), If nooutput=1: Return a HTML select string. */ public function select_comptes($selected = '', $htmlname = 'accountid', $status = 0, $filtre = '', $useempty = 0, $moreattrib = '', $showcurrency = 0, $morecss = '', $nooutput = 0) @@ -5882,7 +5882,7 @@ class Form * @param int $discard_closed Discard closed projects (0=Keep,1=hide completely except $selected,2=Disable) * @param int $maxlength Max length * @param int $forcefocus Force focus on field (works with javascript only) - * @param int $nooutput No print is done. String is returned. + * @param int<0,1> $nooutput No print is done. String is returned. * @param string $textifnoproject Text to show if no project * @param string $morecss More CSS * @return string Return html content @@ -5940,7 +5940,7 @@ class Form * @param int $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters) * 0 : use default deposit percentage from entry * > 0 : force deposit percentage (for example, from company object) - * @param int $nooutput No print is done. String is returned. + * @param int<0,1> $nooutput No print is done. String is returned. * @return string HTML output or '' */ public function form_conditions_reglement($page, $selected = '', $htmlname = 'cond_reglement_id', $addempty = 0, $type = '', $filtertype = -1, $deposit_percent = -1, $nooutput = 0) @@ -6065,7 +6065,7 @@ class Form * @param string $htmlname Html name of date input fields or 'none' * @param int $displayhour Display hour selector * @param int $displaymin Display minutes selector - * @param int $nooutput 1=No print output, return string + * @param int<0,1> $nooutput 1=No print output, return string * @param string $type 'direct-debit' or 'bank-transfer' * @return string * @see selectDate() @@ -6154,7 +6154,7 @@ class Form * @param int $active Active or not, -1 = all * @param int $addempty 1=Add empty entry * @param string $type Type ('direct-debit' or 'bank-transfer') - * @param int $nooutput 1=Return string, no output + * @param int<0,1> $nooutput 1=Return string, no output * @return string HTML output or '' */ public function form_modes_reglement($page, $selected = '', $htmlname = 'mode_reglement_id', $filtertype = '', $active = 1, $addempty = 0, $type = '', $nooutput = 0) @@ -6446,7 +6446,7 @@ class Form * @param int<0,1> $showtype Show third party type in combolist (customer, prospect or supplier) * @param int<0,1> $forcecombo Force to use combo box * @param array}> $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) - * @param int $nooutput No print output. Return it only. + * @param int<0,1> $nooutput No print output. Return it only. * @param int[] $excludeids Exclude IDs from the select combo * @param string $textifnothirdparty Text to show if no thirdparty * @return string HTML output or '' @@ -6948,7 +6948,7 @@ class Form * @param string $form_name Not used * @param int $d 1=Show days, month, years * @param int $addnowlink Add a link "Now" - * @param int $nooutput Do not output html string but return it + * @param int<0,1> $nooutput Do not output html string but return it * @param int $disabled Disable input fields * @param int $fullday When a checkbox with this html name is on, hour and day are set with 00:00 or 23:59 * @param string $addplusone Add a link "+1 hour". Value must be name of another select_date field. @@ -7508,7 +7508,7 @@ class Form * If 'text' input hour is in text and input min is a text, * If 'textselect' input hour is in text and input min is a combo * @param integer $minunderhours If 1, show minutes selection under the hours - * @param int $nooutput Do not output html string but return it + * @param int<0,1> $nooutput Do not output html string but return it * @return string HTML component */ public function select_duration($prefix, $iSecond = '', $disabled = 0, $typehour = 'select', $minunderhours = 0, $nooutput = 0) @@ -9536,8 +9536,8 @@ class Form * @param CommonObject $object Object we want to show links to * @param string[] $restrictlinksto Restrict links to some elements, for example array('order') or array('supplier_order'). null or array() if no restriction. * @param string[] $excludelinksto Do not show links of this type, for example array('order') or array('supplier_order'). null or array() if no exclusion. - * @param int $nooutput 1=Return array with content instead of printing it. - * @return string|array HTML block or array with htmlblock (depending on $nooutput value) + * @param int<0,1> $nooutput 1=Return array with content instead of printing it. + * @return array{linktoelem:string,htmltoenteralink:string}|string HTML block */ public function showLinkToObjectBlock($object, $restrictlinksto = array(), $excludelinksto = array(), $nooutput = 0) { @@ -9766,18 +9766,18 @@ class Form if ($linktoelemlist) { $linktoelem = ' - '; } else { $linktoelem = ''; } @@ -9792,7 +9792,7 @@ class Form }); }); - '; + '; } if ($nooutput) { diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 4044a33546d..0d72459e616 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -70,7 +70,7 @@ parameters: - '#\$httpStatusCode of class Luracast\\Restler\\RestException constructor expects string, int given.#' - '#(?:(?:s(?:(?:et_error_handl|pl_autoload_regist)er)|array_filter)) expects \(callable#' - '# (dol_print_date|correctExifImageOrientation) expects bool\|string#' - - '# (getRandomPassword|vatrate|DolEditor constructor) expects bool, int#' + - '# (vatrate|DolEditor constructor) expects bool, int#' - '# SMTPs::(getFrom|getErrorsTo|getReplyTo)\(\) expects bool, string given.#' - '# (dolibarr_set_const|getLocalTaxesFromRate) expects int\|string#' - '#::(options)\(\) expects int\|string#' From cab697f557f9aab9a4cc7fce2d722e7cbf9a52ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 29 Sep 2024 13:07:21 +0200 Subject: [PATCH 2/5] fix phpstan (#31183) * fix phpstan * fix phpstan --- htdocs/core/lib/ldap.lib.php | 11 +++++------ phpstan.neon.dist | 1 - 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/ldap.lib.php b/htdocs/core/lib/ldap.lib.php index a3ea72226a1..9b5c039372e 100644 --- a/htdocs/core/lib/ldap.lib.php +++ b/htdocs/core/lib/ldap.lib.php @@ -1,7 +1,8 @@ - * Copyright (C) 2006-2021 Regis Houssin - * Copyright (C) 2024 MDW +/* Copyright (C) 2006 Laurent Destailleur + * Copyright (C) 2006-2021 Regis Houssin + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -125,15 +126,13 @@ function show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass) * @param array<'count'|int|string,int|string|array> $result Array to show. This array is already encoded into charset_output * @param int $level Level * @param int $count Count - * @param string $var Var + * @param bool $var Var deprecated (replaced by css oddeven) * @param int<0,1> $hide Hide * @param int $subcount Subcount * @return int */ function show_ldap_content($result, $level, $count, $var, $hide = 0, $subcount = 0) { - global $bc, $conf; - $count--; if ($count == 0) { return -1; // To stop loop diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 0d72459e616..4510d0c9e7c 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -94,7 +94,6 @@ parameters: - '#::HTML2OpenIDServer\(\) expects string, array given.#' - '#create_line\(\) expects string, float given.#' - '# dol_stringtotime expects string, DateTime given.#' - - '# show_ldap_content expects string, true given.#' - '#expects string, bool\|mysqli_result\|resource given.#' - '#( |::)((multi)?selectarray)\(\) expects array#' - '# (reWriteAllMenus|check_authentication) expects array#' From 741cca5eb4f18dcc22e2af4cd64034419b87a7e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 29 Sep 2024 13:07:40 +0200 Subject: [PATCH 3/5] fix phpstan (#31184) * fix phpstan * fix phpstan --- htdocs/projet/admin/project.php | 2 +- htdocs/stripe/admin/stripe.php | 2 +- phpstan.neon.dist | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/projet/admin/project.php b/htdocs/projet/admin/project.php index 328c3490b6c..a1e2c984e58 100644 --- a/htdocs/projet/admin/project.php +++ b/htdocs/projet/admin/project.php @@ -274,7 +274,7 @@ print ' '."\n"; print ''; print ''.$langs->trans("ManageOpportunitiesStatus").''; print ''; -print ajax_constantonoff("PROJECT_USE_OPPORTUNITIES", null, null, 0, 0, 1); +print ajax_constantonoff("PROJECT_USE_OPPORTUNITIES", array(), null, 0, 0, 1); print ''; print ""; print ''; diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 9c31175b1ab..c00d7a0d09c 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -593,7 +593,7 @@ print ''; print ''; print $langs->trans("SecurityTokenIsUnique").''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('PAYMENT_SECURITY_TOKEN_UNIQUE', null, null, 0, 0, 1); + print ajax_constantonoff('PAYMENT_SECURITY_TOKEN_UNIQUE', array(), null, 0, 0, 1); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("PAYMENT_SECURITY_TOKEN_UNIQUE", $arrval, $conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE); diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 4510d0c9e7c..f42d7d93380 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -101,7 +101,6 @@ parameters: - '# dolGetButtonTitle expects array Date: Sun, 29 Sep 2024 13:08:11 +0200 Subject: [PATCH 4/5] fix phpstan (#31185) * fix phpstan * fix phpstan --- htdocs/societe/project.php | 4 ++-- phpstan.neon.dist | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/societe/project.php b/htdocs/societe/project.php index a12272c94ab..3781788b03f 100644 --- a/htdocs/societe/project.php +++ b/htdocs/societe/project.php @@ -6,7 +6,7 @@ * Copyright (C) 2007 Patrick Raguin * Copyright (C) 2010 Juanjo Menent * Copyright (C) 2015 Marcos García - * Copyright (C) 2021 Frédéric France + * Copyright (C) 2021-2024 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -176,7 +176,7 @@ if ($socid) { print dol_get_fiche_end(); print '
'; - $params = ''; + $params = array(); $backtopage = $_SERVER['PHP_SELF'].'?socid='.$object->id; $newcardbutton = dolGetButtonTitle($langs->trans("NewProject"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?action=create&socid='.$object->id.'&backtopageforcancel='.urlencode($backtopage), '', 1, $params); diff --git a/phpstan.neon.dist b/phpstan.neon.dist index f42d7d93380..d985f2d1474 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -98,7 +98,6 @@ parameters: - '#( |::)((multi)?selectarray)\(\) expects array#' - '# (reWriteAllMenus|check_authentication) expects array#' - '#::(_validateMyObject|select_company)\(\) expects array Date: Sun, 29 Sep 2024 13:09:09 +0200 Subject: [PATCH 5/5] Qual: Add centpecent to codespell, fix css (#31178) # Qual: Add centpecent to codespell, fix css Try to prevent misspelling in css by adding centpecent. Fix corresponding cases Co-authored-by: Laurent Destailleur --- dev/tools/codespell/codespell-dict.txt | 1 + htdocs/categories/viewcat.php | 10 +++++----- htdocs/comm/propal/card.php | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/dev/tools/codespell/codespell-dict.txt b/dev/tools/codespell/codespell-dict.txt index 2334fd03327..776e9c5413a 100644 --- a/dev/tools/codespell/codespell-dict.txt +++ b/dev/tools/codespell/codespell-dict.txt @@ -8,6 +8,7 @@ aplhanothtml->alphanohtml aploha->alpha aplohanothtml->alphanohtml aplphanothtml->alphanohtml +centpecent->centpercent choosed->chosen cumuled->cumulative dokument->document diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 8c23bf972e9..a11f5309b1a 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -816,7 +816,7 @@ if ($type == Categorie::TYPE_MEMBER) { // @phan-suppress-next-line PhanPluginSuspiciousParamOrder print_barre_liste($langs->trans("Member"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'members', 0, $newcardbutton, '', $limit); - print ''."\n"; + print '
'."\n"; print ''."\n"; if (count($members) > 0) { @@ -1000,7 +1000,7 @@ if ($type == Categorie::TYPE_ACCOUNT) { // @phan-suppress-next-line PhanPluginSuspiciousParamOrder print_barre_liste($langs->trans("Account"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bank_account', 0, $newcardbutton, '', $limit); - print '
'.$langs->trans("Name").'
'."\n"; + print '
'."\n"; print ''."\n"; if (count($accounts) > 0) { @@ -1090,7 +1090,7 @@ if ($type == Categorie::TYPE_PROJECT) { // @phan-suppress-next-line PhanPluginSuspiciousParamOrder print_barre_liste($langs->trans("Project"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'project', 0, $newcardbutton, '', $limit); - print '
'.$langs->trans("Ref").'
'."\n"; + print '
'."\n"; print ''."\n"; if (count($objects) > 0) { @@ -1179,7 +1179,7 @@ if ($type == Categorie::TYPE_USER) { // @phan-suppress-next-line PhanPluginSuspiciousParamOrder print_barre_liste($langs->trans("Users"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'user', 0, '', '', $limit); - print '
'.$langs->trans("Ref").'
'."\n"; + print '
'."\n"; print ''."\n"; if (count($users) > 0) { @@ -1245,7 +1245,7 @@ if ($type == Categorie::TYPE_WAREHOUSE) { // @phan-suppress-next-line PhanPluginSuspiciousParamOrder print_barre_liste($langs->trans("Warehouses"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'stock', 0, $newcardbutton, '', $limit); - print '
'.$langs->trans("Users").' '.$num.'
'."\n"; + print '
'."\n"; print ''."\n"; if (count($objects) > 0) { diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 628bad3cb13..c988dcef24c 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2714,7 +2714,7 @@ if ($action == 'create') { // Payment term print '
'.$langs->trans("Ref").'
'; - print '
'; + print ''; if ($action != 'editconditions' && $usercancreate && $caneditfield) {
'; print $langs->trans('PaymentConditionsShort'); print '