diff --git a/htdocs/admin/debugbar.php b/htdocs/admin/debugbar.php index 1f0ae7679ca..ce41dd01334 100644 --- a/htdocs/admin/debugbar.php +++ b/htdocs/admin/debugbar.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2007 Rodolphe Quiedeville * Copyright (C) 2013 Juanjo Menent + * 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 @@ -60,7 +61,7 @@ if ($action == 'set') { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { $db->rollback(); - setEventMessages($error, null, 'errors'); + setEventMessages($langs->trans("Error"), null, 'errors'); } } diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php index db18b396bcb..4f2d66f1dc4 100644 --- a/htdocs/admin/fckeditor.php +++ b/htdocs/admin/fckeditor.php @@ -152,7 +152,7 @@ print load_fiche_titre($langs->trans("AdvancedEditor"), $linkback, 'title_setup' print '
'; if (empty($conf->use_javascript_ajax)) { - setEventMessages(array($langs->trans("NotAvailable"), $langs->trans("JavascriptDisabled")), null, 'errors'); + setEventMessages(null, array($langs->trans("NotAvailable"), $langs->trans("JavascriptDisabled")), 'errors'); } else { print ''; print ''; diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index 816699e8989..1cbe46885d7 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -24,9 +24,11 @@ * \brief Code for actions on extrafields admin pages */ + /** @var ExtraFields $extrafields */ $maxsizestring = 255; $maxsizeint = 10; -$mesg = array(); +$mesg = ''; +$mesgs = array(); $extrasize = GETPOST('size', 'intcomma'); $type = GETPOST('type', 'alphanohtml'); @@ -69,61 +71,61 @@ if ($action == 'add') { if (!$type) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); + $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); $action = 'create'; } if ($type == 'varchar' && $extrasize <= 0) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); + $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); $action = 'edit'; } if ($type == 'varchar' && $extrasize > $maxsizestring) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); + $mesgs[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); $action = 'create'; } if ($type == 'int' && $extrasize > $maxsizeint) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); + $mesgs[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); $action = 'create'; } if ($type == 'stars' && ($extrasize < 1 || $extrasize > 10)) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorSizeForStarsType"); + $mesgs[] = $langs->trans("ErrorSizeForStarsType"); $action = 'create'; } if ($type == 'select' && !$param) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForSelectType"); + $mesgs[] = $langs->trans("ErrorNoValueForSelectType"); $action = 'create'; } if ($type == 'sellist' && !$param) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForSelectListType"); + $mesgs[] = $langs->trans("ErrorNoValueForSelectListType"); $action = 'create'; } if ($type == 'checkbox' && !$param) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForCheckBoxType"); + $mesgs[] = $langs->trans("ErrorNoValueForCheckBoxType"); $action = 'create'; } if ($type == 'link' && !$param) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForLinkType"); + $mesgs[] = $langs->trans("ErrorNoValueForLinkType"); $action = 'create'; } if ($type == 'radio' && !$param) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForRadioType"); + $mesgs[] = $langs->trans("ErrorNoValueForRadioType"); $action = 'create'; } if ((($type == 'radio') || ($type == 'checkbox')) && $param) { @@ -136,13 +138,13 @@ if ($action == 'add') { if (count($matches[0]) > 1) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); + $mesgs[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); $action = 'create'; } } else { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); + $mesgs[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); $action = 'create'; } } @@ -153,7 +155,7 @@ if ($action == 'add') { if (strlen(GETPOST('attrname', 'aZ09')) < 3) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorValueLength", $langs->transnoentitiesnoconv("AttributeCode"), 3); + $mesgs[] = $langs->trans("ErrorValueLength", $langs->transnoentitiesnoconv("AttributeCode"), 3); $action = 'create'; } } @@ -163,7 +165,7 @@ if ($action == 'add') { if (in_array(strtoupper(GETPOST('attrname', 'aZ09')), $listofreservedwords)) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorReservedKeyword", GETPOST('attrname', 'aZ09')); + $mesgs[] = $langs->trans("ErrorReservedKeyword", GETPOST('attrname', 'aZ09')); $action = 'create'; } } @@ -233,17 +235,18 @@ if ($action == 'add') { } else { $error++; $mesg = $extrafields->error; - setEventMessages($mesg, null, 'errors'); + $mesgs = array_merge($mesgs, $extrafields->errors); + setEventMessages($mesg, $mesgs, 'errors'); } } else { $error++; $langs->load("errors"); $mesg = $langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters", $langs->transnoentities("AttributeCode")); - setEventMessages($mesg, null, 'errors'); + setEventMessages($mesg, $mesgs, 'errors'); $action = 'create'; } } else { - setEventMessages($mesg, null, 'errors'); + setEventMessages($mesg, $mesgs, 'errors'); } } } @@ -255,55 +258,55 @@ if ($action == 'update') { if (!$type) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); + $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); $action = 'edit'; } if ($type == 'varchar' && $extrasize <= 0) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); + $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); $action = 'edit'; } if ($type == 'varchar' && $extrasize > $maxsizestring) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); + $mesgs[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); $action = 'edit'; } if ($type == 'int' && $extrasize > $maxsizeint) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); + $mesgs[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); $action = 'edit'; } if ($type == 'select' && !$param) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForSelectType"); + $mesgs[] = $langs->trans("ErrorNoValueForSelectType"); $action = 'edit'; } if ($type == 'sellist' && !$param) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForSelectListType"); + $mesgs[] = $langs->trans("ErrorNoValueForSelectListType"); $action = 'edit'; } if ($type == 'stars' && ($extrasize < 1|| $extrasize > 10)) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorSizeForStarsType"); + $mesgs[] = $langs->trans("ErrorSizeForStarsType"); $action = 'edit'; } if ($type == 'checkbox' && !$param) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForCheckBoxType"); + $mesgs[] = $langs->trans("ErrorNoValueForCheckBoxType"); $action = 'edit'; } if ($type == 'radio' && !$param) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorNoValueForRadioType"); + $mesgs[] = $langs->trans("ErrorNoValueForRadioType"); $action = 'edit'; } if ((($type == 'radio') || ($type == 'checkbox')) && $param) { @@ -316,13 +319,13 @@ if ($action == 'update') { if (count($matches[0]) > 1) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); + $mesgs[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); $action = 'edit'; } } else { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); + $mesgs[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); $action = 'edit'; } } @@ -333,7 +336,7 @@ if ($action == 'update') { if (strlen(GETPOST('attrname', 'aZ09')) < 3 && !getDolGlobalString('MAIN_DISABLE_EXTRAFIELDS_CHECK_FOR_UPDATE')) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorValueLength", $langs->transnoentitiesnoconv("AttributeCode"), 3); + $mesgs[] = $langs->trans("ErrorValueLength", $langs->transnoentitiesnoconv("AttributeCode"), 3); $action = 'edit'; } } @@ -343,7 +346,7 @@ if ($action == 'update') { if (in_array(strtoupper(GETPOST('attrname', 'aZ09')), $listofreservedwords) && !getDolGlobalString('MAIN_DISABLE_EXTRAFIELDS_CHECK_FOR_UPDATE')) { $error++; $langs->load("errors"); - $mesg[] = $langs->trans("ErrorReservedKeyword", GETPOST('attrname', 'aZ09')); + $mesgs[] = $langs->trans("ErrorReservedKeyword", GETPOST('attrname', 'aZ09')); $action = 'edit'; } } @@ -416,7 +419,8 @@ if ($action == 'update') { } else { $error++; $mesg = $extrafields->error; - setEventMessages($mesg, null, 'errors'); + $mesgs = array_merge($mesgs, $extrafields->errors); + setEventMessages($mesg, $mesgs, 'errors'); } } else { $error++; @@ -425,7 +429,7 @@ if ($action == 'update') { setEventMessages($mesg, null, 'errors'); } } else { - setEventMessages($mesg, null, 'errors'); + setEventMessages($mesg, $mesgs, 'errors'); } } } @@ -443,6 +447,7 @@ if ($action == 'confirm_delete' && $confirm == "yes") { exit; } else { $mesg = $extrafields->error; + $mesgs = array_merge($mesgs, $extrafields->errors); } } else { $error++; diff --git a/htdocs/expedition/dispatch.php b/htdocs/expedition/dispatch.php index 83961579dd8..696e220e9b5 100644 --- a/htdocs/expedition/dispatch.php +++ b/htdocs/expedition/dispatch.php @@ -1,14 +1,14 @@ - * Copyright (C) 2004-2016 Laurent Destailleur - * Copyright (C) 2005 Eric Seigne - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2010-2021 Juanjo Menent - * Copyright (C) 2014 Cedric Gross - * Copyright (C) 2016 Florian Henry - * Copyright (C) 2017-2022 Ferran Marcet - * Copyright (C) 2018-2022 Frédéric France - * Copyright (C) 2019-2020 Christophe Battarel +/* Copyright (C) 2004-2006 Rodolphe Quiedeville + * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2005 Eric Seigne + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2010-2021 Juanjo Menent + * Copyright (C) 2014 Cedric Gross + * Copyright (C) 2016 Florian Henry + * Copyright (C) 2017-2022 Ferran Marcet + * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2019-2020 Christophe Battarel * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify @@ -202,7 +202,6 @@ if ($action == 'updatelines' && $usercancreate) { } } } - //var_dump($key.' '.$newqty.' '.$idline.' '.$error); if (!$error) { $qtystart = 0; @@ -345,7 +344,7 @@ if ($action == 'updatelines' && $usercancreate) { if ($error > 0) { $db->rollback(); - setEventMessages($error, $errors, 'errors'); + setEventMessages($langs->trans("Error"), $errors, 'errors'); } else { $db->commit(); setEventMessages($langs->trans("ReceptionUpdated"), null); diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index a9e7e846779..7007b5f8430 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -1,15 +1,15 @@ - * Copyright (C) 2004-2023 Laurent Destailleur - * Copyright (C) 2005 Eric Seigne - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2010-2021 Juanjo Menent - * Copyright (C) 2014 Cedric Gross - * Copyright (C) 2016 Florian Henry - * Copyright (C) 2017-2022 Ferran Marcet - * Copyright (C) 2018-2022 Frédéric France - * Copyright (C) 2019-2020 Christophe Battarel - * Copyright (C) 2024 MDW +/* Copyright (C) 2004-2006 Rodolphe Quiedeville + * Copyright (C) 2004-2023 Laurent Destailleur + * Copyright (C) 2005 Eric Seigne + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2010-2021 Juanjo Menent + * Copyright (C) 2014 Cedric Gross + * Copyright (C) 2016 Florian Henry + * Copyright (C) 2017-2022 Ferran Marcet + * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2019-2020 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 @@ -507,7 +507,7 @@ if ($action == 'updateline' && $permissiontoreceive && empty($cancel)) { } if ($error > 0) { $db->rollback(); - setEventMessages($error, $errors, 'errors'); + setEventMessages($langs->trans("Error"), $errors, 'errors'); } else { $db->commit(); } diff --git a/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php b/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php index 2f7826c5ea6..bcbcda04656 100644 --- a/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php @@ -1,7 +1,8 @@ - * Copyright (C) 2014 Marcos García - * Copyright (C) 2024 MDW +/* Copyright (C) 2010-2011 Regis Houssin + * Copyright (C) 2014 Marcos García + * 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 @@ -32,8 +33,10 @@ global $noMoreLinkedObjectBlockAfter; $langs = $GLOBALS['langs']; '@phan-var-force Translate $langs'; +/** @var Translate $langs */ $linkedObjectBlock = $GLOBALS['linkedObjectBlock']; '@phan-var-force CommonObject[] $linkedObjectBlock'; +/** @var CommonObject[] $linkedObjectBlock */ $langs->load("orders"); diff --git a/htdocs/reception/dispatch.php b/htdocs/reception/dispatch.php index 0f152e82cfc..e57bed8ba8d 100644 --- a/htdocs/reception/dispatch.php +++ b/htdocs/reception/dispatch.php @@ -7,7 +7,7 @@ * Copyright (C) 2014 Cedric Gross * Copyright (C) 2016 Florian Henry * Copyright (C) 2017-2022 Ferran Marcet - * Copyright (C) 2018-2022 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2019-2020 Christophe Battarel * Copyright (C) 2024 MDW * @@ -280,7 +280,7 @@ if ($action == 'updatelines' && $permissiontoreceive) { } if ($error > 0) { $db->rollback(); - setEventMessages($error, $errors, 'errors'); + setEventMessages($langs->trans("Error"), $errors, 'errors'); } else { $db->commit(); setEventMessages($langs->trans("ReceptionUpdated"), null); diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 483e829b74e..9b047a57945 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -90,7 +90,7 @@ parameters: - '#(?:ProductFournisseur::logPrice\(\)) expects float\|null#' - '#(?:(?:Asset::addDepreciationL|Facture(?:(?:(?:Fournisseur)?::add|Fournisseur::update)l))ine\(\)|calcul_price_total|(?:loanCalcMonthlyPaymen|print_paypal_redirec)t) expects float, string given.#' - '#EvalMath::trigger\(\) expects string\|null,#' - - '#(?:F(?:acture(?:(?:Fournisseur)?Rec::addline\(\))|ichinterRec::addLineRec\(\))|dolMd2Html|setEventMessages) expects string\|null,#' + - '#(?: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.#'