fix phpstan (#31565)

* fix phpstan

* fix phpstan

* fix phpstan

* fix phpstan

* fix phpstan

* fix phpstan
This commit is contained in:
Frédéric FRANCE 2024-10-26 13:03:52 +02:00 committed by GitHub
parent 19b653a599
commit 17e69f8a21
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 73 additions and 65 deletions

View File

@ -3,6 +3,7 @@
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* 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');
}
}

View File

@ -152,7 +152,7 @@ print load_fiche_titre($langs->trans("AdvancedEditor"), $linkback, 'title_setup'
print '<br>';
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 '<table class="noborder centpercent">';
print '<tr class="liste_titre">';

View File

@ -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++;

View File

@ -1,14 +1,14 @@
<?php
/* Copyright (C) 2004-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2010-2021 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014 Cedric Gross <c.gross@kreiz-it.fr>
* Copyright (C) 2016 Florian Henry <florian.henry@atm-consulting.fr>
* Copyright (C) 2017-2022 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018-2022 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2019-2020 Christophe Battarel <christophe@altairis.fr>
/* Copyright (C) 2004-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2010-2021 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014 Cedric Gross <c.gross@kreiz-it.fr>
* Copyright (C) 2016 Florian Henry <florian.henry@atm-consulting.fr>
* Copyright (C) 2017-2022 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2019-2020 Christophe Battarel <christophe@altairis.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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);

View File

@ -1,15 +1,15 @@
<?php
/* Copyright (C) 2004-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2023 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2010-2021 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014 Cedric Gross <c.gross@kreiz-it.fr>
* Copyright (C) 2016 Florian Henry <florian.henry@atm-consulting.fr>
* Copyright (C) 2017-2022 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018-2022 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2019-2020 Christophe Battarel <christophe@altairis.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
/* Copyright (C) 2004-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2023 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2010-2021 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014 Cedric Gross <c.gross@kreiz-it.fr>
* Copyright (C) 2016 Florian Henry <florian.henry@atm-consulting.fr>
* Copyright (C) 2017-2022 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2019-2020 Christophe Battarel <christophe@altairis.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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();
}

View File

@ -1,7 +1,8 @@
<?php
/* Copyright (C) 2010-2011 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
/* Copyright (C) 2010-2011 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* 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");

View File

@ -7,7 +7,7 @@
* Copyright (C) 2014 Cedric Gross <c.gross@kreiz-it.fr>
* Copyright (C) 2016 Florian Henry <florian.henry@atm-consulting.fr>
* Copyright (C) 2017-2022 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018-2022 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2019-2020 Christophe Battarel <christophe@altairis.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
@ -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);

View File

@ -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.#'