diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 18af391bf36..e38b39ba2e0 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -10,10 +10,10 @@ return [ // # Issue statistics: // PhanUndeclaredProperty : 460+ occurrences - // PhanTypeMismatchArgument : 280+ occurrences + // PhanTypeMismatchArgument : 230+ occurrences // PhanTypeMismatchProperty : 100+ occurrences // PhanUndeclaredGlobalVariable : 100+ occurrences - // PhanTypeMismatchArgumentNullable : 90+ occurrences + // PhanTypeMismatchArgumentNullable : 70+ occurrences // PhanTypeExpectedObjectPropAccess : 20+ occurrences // PhanTypeInvalidDimOffset : 20+ occurrences // PhanTypeMismatchDimFetch : 15+ occurrences @@ -40,33 +40,10 @@ return [ 'htdocs/accountancy/class/accountancyexport.class.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'], 'htdocs/adherents/list.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/admin/agenda_other.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/admin/agenda_reminder.php' => ['PhanTypeMismatchArgumentNullable'], - 'htdocs/admin/barcode.php' => ['PhanTypeMismatchArgument'], 'htdocs/admin/bom.php' => ['PhanTypeMismatchArgument'], - 'htdocs/admin/company.php' => ['PhanTypeMismatchArgument'], 'htdocs/admin/defaultvalues.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/admin/eventorganization.php' => ['PhanTypeMismatchArgument'], - 'htdocs/admin/expensereport_rules.php' => ['PhanTypeMismatchArgument'], - 'htdocs/admin/external_rss.php' => ['PhanTypeMismatchArgument'], - 'htdocs/admin/hrm.php' => ['PhanTypeMismatchArgument'], - 'htdocs/admin/knowledgemanagement.php' => ['PhanTypeMismatchArgument'], - 'htdocs/admin/mails.php' => ['PhanTypeMismatchArgument'], - 'htdocs/admin/mails_emailing.php' => ['PhanTypeMismatchArgumentNullable'], - 'htdocs/admin/mails_passwordreset.php' => ['PhanTypeMismatchArgumentNullable'], - 'htdocs/admin/mails_senderprofile_list.php' => ['PhanTypeMismatchArgument'], - 'htdocs/admin/mails_templates.php' => ['PhanTypeMismatchArgumentNullable'], - 'htdocs/admin/mails_ticket.php' => ['PhanTypeMismatchArgumentNullable'], - 'htdocs/admin/menus/index.php' => ['PhanTypeMismatchArgument'], - 'htdocs/admin/multicurrency.php' => ['PhanTypeMismatchArgument'], - 'htdocs/admin/receiptprinter.php' => ['PhanTypeMismatchArgument'], - 'htdocs/admin/system/filecheck.php' => ['PhanTypeMismatchArgument'], - 'htdocs/admin/system/modules.php' => ['PhanTypeMismatchArgument'], - 'htdocs/admin/taxes.php' => ['PhanTypeMismatchArgumentNullable'], - 'htdocs/admin/ticket.php' => ['PhanTypeMismatchArgument'], - 'htdocs/admin/tools/export.php' => ['PhanTypeMismatchArgument'], 'htdocs/api/class/api_documents.class.php' => ['PhanPluginDuplicateExpressionBinaryOp'], 'htdocs/api/class/api_setup.class.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchReturn'], - 'htdocs/asset/admin/setup.php' => ['PhanTypeMismatchArgument'], 'htdocs/asset/class/asset.class.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanTypeInvalidDimOffset'], 'htdocs/asset/class/assetdepreciationoptions.class.php' => ['PhanTypeInvalidDimOffset'], 'htdocs/asset/class/assetmodel.class.php' => ['PhanUndeclaredProperty'], @@ -285,11 +262,9 @@ return [ 'htdocs/ecm/search.php' => ['PhanTypeMismatchArgument'], 'htdocs/emailcollector/class/emailcollector.class.php' => ['PhanUndeclaredProperty'], 'htdocs/eventorganization/class/conferenceorboothattendee.class.php' => ['PhanUndeclaredMethod', 'PhanUndeclaredProperty'], - 'htdocs/eventorganization/conferenceorbooth_card.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/eventorganization/conferenceorbooth_contact.php' => ['PhanTypeMismatchArgument'], 'htdocs/eventorganization/conferenceorbooth_document.php' => ['PhanTypeMismatchArgument'], 'htdocs/eventorganization/conferenceorbooth_list.php' => ['PhanTypeMismatchArgument'], - 'htdocs/eventorganization/conferenceorboothattendee_card.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/eventorganization/conferenceorboothattendee_list.php' => ['PhanTypeMismatchArgument'], 'htdocs/eventorganization/core/actions_massactions_mail.inc.php' => ['PhanUndeclaredProperty'], 'htdocs/expedition/ajax/searchfrombarcode.php' => ['PhanTypeMismatchArgument'], @@ -342,7 +317,7 @@ return [ 'htdocs/hrm/core/tpl/objectline_view.tpl.php' => ['PhanUndeclaredProperty'], 'htdocs/hrm/evaluation_card.php' => ['PhanTypeMismatchArgument'], 'htdocs/hrm/job_card.php' => ['PhanUndeclaredGlobalVariable'], - 'htdocs/hrm/skill_card.php' => ['PhanTypeExpectedObjectPropAccess', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], + 'htdocs/hrm/skill_card.php' => ['PhanTypeExpectedObjectPropAccess', 'PhanUndeclaredProperty'], 'htdocs/imports/import.php' => ['PhanTypeMismatchArgument'], 'htdocs/intracommreport/card.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/knowledgemanagement/class/knowledgerecord.class.php' => ['PhanUndeclaredProperty'], @@ -352,7 +327,6 @@ return [ 'htdocs/loan/note.php' => ['PhanUndeclaredProperty'], 'htdocs/loan/payment/payment.php' => ['PhanUndeclaredProperty'], 'htdocs/mrp/class/mo.class.php' => ['PhanTypeMismatchProperty'], - 'htdocs/mrp/mo_movements.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/mrp/tpl/linkedobjectblock.tpl.php' => ['PhanUndeclaredProperty'], 'htdocs/multicurrency/class/api_multicurrencies.class.php' => ['PhanTypeMismatchArgument'], 'htdocs/multicurrency/class/multicurrency.class.php' => ['PhanTypeExpectedObjectPropAccess'], @@ -379,7 +353,6 @@ return [ 'htdocs/product/stock/stats/mo.php' => ['PhanUndeclaredProperty'], 'htdocs/product/stock/stats/reception.php' => ['PhanUndeclaredProperty'], 'htdocs/product/stock/stocktransfer/class/stocktransferline.class.php' => ['PhanUndeclaredProperty'], - 'htdocs/product/stock/stocktransfer/stocktransfer_card.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/product/stock/tpl/stockcorrection.tpl.php' => ['PhanUndeclaredProperty'], 'htdocs/product/stock/tpl/stocktransfer.tpl.php' => ['PhanUndeclaredProperty'], 'htdocs/projet/admin/project.php' => ['PhanTypeMismatchArgumentProbablyReal'], diff --git a/htdocs/admin/agenda_reminder.php b/htdocs/admin/agenda_reminder.php index 14821a3da45..a92f5cfb6c6 100644 --- a/htdocs/admin/agenda_reminder.php +++ b/htdocs/admin/agenda_reminder.php @@ -1,6 +1,6 @@ - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -284,6 +284,7 @@ if (getDolGlobalString('AGENDA_REMINDER_EMAIL')) { } else { $selected = json_decode(getDolGlobalString('AGENDA_DEFAULT_REMINDER_EVENT_TYPES', '')); } + // Assuming $selected is correct type: @phan-suppress-next-line PhanTypeMismatchArgumentNullable print $formactions->select_type_actions($selected, "AGENDA_DEFAULT_REMINDER_EVENT_TYPES", "systemauto", 0, -1, 1, 1); print ''; } diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index f425524f3cc..179a45069e8 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2011-2013 Juanjo Menent - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -474,7 +474,7 @@ if (isModEnabled('product')) { print ''; print ''.$langs->trans("SetDefaultBarcodeTypeProducts").''; print ''; - print $formbarcode->selectBarcodeType(getDolGlobalString('PRODUIT_DEFAULT_BARCODE_TYPE'), "PRODUIT_DEFAULT_BARCODE_TYPE", 1); + print $formbarcode->selectBarcodeType(getDolGlobalInt('PRODUIT_DEFAULT_BARCODE_TYPE'), "PRODUIT_DEFAULT_BARCODE_TYPE", 1); print ''; print ' '; print ''; @@ -485,7 +485,7 @@ if (isModEnabled('societe')) { print ''; print ''.$langs->trans("SetDefaultBarcodeTypeThirdParties").''; print ''; - print $formbarcode->selectBarcodeType(getDolGlobalString('GENBARCODE_BARCODETYPE_THIRDPARTY'), "GENBARCODE_BARCODETYPE_THIRDPARTY", 1); + print $formbarcode->selectBarcodeType(getDolGlobalInt('GENBARCODE_BARCODETYPE_THIRDPARTY'), "GENBARCODE_BARCODETYPE_THIRDPARTY", 1); print ''; print ' '; print ''; diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index dfb611b3891..d901fc6704d 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -466,7 +466,7 @@ print ''."\n"; // Country print ''; print img_picto('', 'globe-americas', 'class="pictofixedwidth"'); -print $form->select_country($mysoc->country_id, 'country_id', '', 0); +print $form->select_country((string) $mysoc->country_id, 'country_id', '', 0); print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print ''."\n"; diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index 41139f937e5..2aff61e40ca 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -234,7 +234,7 @@ if ($action == 'edit') { $tmp = explode(':', $val['type']); print img_picto('', 'category', 'class="pictofixedwidth"'); - print $formother->select_categories($tmp[1], getDolGlobalString($constname), $constname, 0, $langs->trans('CustomersProspectsCategoriesShort')); + print $formother->select_categories($tmp[1], getDolGlobalInt($constname), $constname, 0, $langs->trans('CustomersProspectsCategoriesShort')); } elseif (preg_match('/thirdparty_type/', $val['type'])) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; $formcompany = new FormCompany($db); @@ -250,7 +250,7 @@ if ($action == 'edit') { print dolJSToSetRandomPassword($constname, 'generate_token'.$constname); } elseif ($val['type'] == 'product') { if (isModEnabled("product") || isModEnabled("service")) { - $selected = getDolGlobalString($constname); + $selected = getDolGlobalInt($constname); print img_picto('', 'product', 'class="pictofixedwidth"'); print $form->select_produits($selected, $constname, '', 0, 0, 1, 2, '', 0, array(), 0, '1', 0, 'maxwidth500 widthcentpercentminusx', 0, '', null, 1); } @@ -295,7 +295,7 @@ if ($action == 'edit') { $tmp = explode(':', $val['type']); $labelemailtemplate = getDolGlobalString($constname); if ($labelemailtemplate && $labelemailtemplate != '-1') { - $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname)); + $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalInt($constname)); if (is_numeric($template) && $template < 0) { setEventMessages($formmail->error, $formmail->errors, 'errors'); } else { @@ -306,9 +306,9 @@ if ($action == 'edit') { } } } elseif (preg_match('/category:/', $val['type'])) { - if (getDolGlobalString($constname)) { + if (getDolGlobalInt($constname)) { $c = new Categorie($db); - $result = $c->fetch(getDolGlobalString($constname)); + $result = $c->fetch(getDolGlobalInt($constname)); if ($result < 0) { setEventMessages(null, $c->errors, 'errors'); } @@ -331,7 +331,7 @@ if ($action == 'edit') { } } elseif ($val['type'] == 'product') { $product = new Product($db); - $idproduct = getDolGlobalString($constname); + $idproduct = getDolGlobalInt($constname); if ($idproduct > 0) { $resprod = $product->fetch($idproduct); if ($resprod > 0) { diff --git a/htdocs/admin/expensereport_rules.php b/htdocs/admin/expensereport_rules.php index 0fcfb94d63b..16904280368 100644 --- a/htdocs/admin/expensereport_rules.php +++ b/htdocs/admin/expensereport_rules.php @@ -3,7 +3,7 @@ * Copyright (C) 2017 ATM Consulting * Copyright (C) 2017 Pierre-Henry Favre * Copyright (C) 2018-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 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 @@ -292,7 +292,7 @@ foreach ($rules as $rule) { echo ''; if ($action == 'edit' && $object->id == $rule->id) { - echo $form->selectExpense($object->fk_c_type_fees, 'fk_c_type_fees', 0, 1, 1); + echo $form->selectExpense((string) $object->fk_c_type_fees, 'fk_c_type_fees', 0, 1, 1); } else { if ($rule->fk_c_type_fees == -1) { echo $langs->trans('AllExpenseReport'); diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php index 991a0553406..9a8e79bae72 100644 --- a/htdocs/admin/external_rss.php +++ b/htdocs/admin/external_rss.php @@ -7,7 +7,7 @@ * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2020 Tobias Sekan - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -138,7 +138,7 @@ if (GETPOST("delete")) { // Supprime boite box_external_rss de definition des boites $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."boxes_def"; - $sql .= " WHERE file = 'box_external_rss.php' AND note LIKE '".$db->escape(GETPOSTINT("norss"))." %'"; + $sql .= " WHERE file = 'box_external_rss.php' AND note LIKE '".$db->escape((string) GETPOSTINT("norss"))." %'"; $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/admin/hrm.php b/htdocs/admin/hrm.php index de8dfabaa18..d50b20987ee 100644 --- a/htdocs/admin/hrm.php +++ b/htdocs/admin/hrm.php @@ -559,7 +559,7 @@ if ($action == 'edit') { $tmp = explode(':', $val['type']); print img_picto('', 'category', 'class="pictofixedwidth"'); - print $formother->select_categories($tmp[1], getDolGlobalString($constname), $constname, 0, $langs->trans('CustomersProspectsCategoriesShort')); + print $formother->select_categories($tmp[1], getDolGlobalInt($constname), $constname, 0, $langs->trans('CustomersProspectsCategoriesShort')); } elseif (preg_match('/thirdparty_type/', $val['type'])) { require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php'; $formcompany = new FormCompany($db); @@ -575,7 +575,7 @@ if ($action == 'edit') { print dolJSToSetRandomPassword($constname, 'generate_token' . $constname); } elseif ($val['type'] == 'product') { if (isModEnabled('product') || isModEnabled('service')) { - $selected = getDolGlobalString($constname); + $selected = getDolGlobalInt($constname); $form->select_produits($selected, $constname, '', 0); } } else { @@ -617,14 +617,14 @@ if ($action == 'edit') { $tmp = explode(':', $val['type']); - $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname)); + $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalInt($constname)); if ($template < 0) { setEventMessages(null, $formmail->errors, 'errors'); } print $langs->trans($template->label); } elseif (preg_match('/category:/', $val['type'])) { $c = new Categorie($db); - $result = $c->fetch(getDolGlobalString($constname)); + $result = $c->fetch(getDolGlobalInt($constname)); if ($result < 0) { setEventMessages(null, $c->errors, 'errors'); } @@ -646,7 +646,7 @@ if ($action == 'edit') { } } elseif ($val['type'] == 'product') { $product = new Product($db); - $resprod = $product->fetch(getDolGlobalString($constname)); + $resprod = $product->fetch(getDolGlobalInt($constname)); if ($resprod > 0) { print $product->ref; } elseif ($resprod < 0) { diff --git a/htdocs/admin/knowledgemanagement.php b/htdocs/admin/knowledgemanagement.php index 953f7958bd7..00424425c18 100644 --- a/htdocs/admin/knowledgemanagement.php +++ b/htdocs/admin/knowledgemanagement.php @@ -265,7 +265,7 @@ if ($action == 'edit') { $tmp = explode(':', $val['type']); print img_picto('', 'category', 'class="pictofixedwidth"'); - print $formother->select_categories($tmp[1], getDolGlobalString($constname), $constname, 0, $langs->trans('CustomersProspectsCategoriesShort')); + print $formother->select_categories($tmp[1], getDolGlobalInt($constname), $constname, 0, $langs->trans('CustomersProspectsCategoriesShort')); } elseif (preg_match('/thirdparty_type/', $val['type'])) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; $formcompany = new FormCompany($db); @@ -308,7 +308,7 @@ if ($action == 'edit') { $tmp = explode(':', $val['type']); - $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname)); + $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalInt($constname)); if ($template < 0) { setEventMessages(null, $formmail->errors, 'errors'); } diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 48a17e1fdf7..2bb44c8a99c 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -5,7 +5,7 @@ * Copyright (C) 2016 Jonathan TISSEAU * Copyright (C) 2023 Anthony Berton * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 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 @@ -951,7 +951,7 @@ if ($action == 'edit') { } elseif (getDolGlobalString('MAIN_MAIL_DEFAULT_FROMTYPE') === 'company') { print $langs->trans('CompanyEmail').' '.dol_escape_htmltag('<'.$mysoc->email.'>'); } else { - $id = preg_replace('/senderprofile_/', '', getDolGlobalString('MAIN_MAIL_DEFAULT_FROMTYPE')); + $id = (int) preg_replace('/senderprofile_/', '', getDolGlobalString('MAIN_MAIL_DEFAULT_FROMTYPE')); if ($id > 0) { include_once DOL_DOCUMENT_ROOT.'/core/class/emailsenderprofile.class.php'; $emailsenderprofile = new EmailSenderProfile($db); diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php index df3946e1bf7..a1dd3fa09f0 100644 --- a/htdocs/admin/mails_emailing.php +++ b/htdocs/admin/mails_emailing.php @@ -4,6 +4,7 @@ * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2016 Jonathan TISSEAU * Copyright (C) 2024-2025 Frédéric France + * Copyright (C) 2025 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 @@ -747,11 +748,11 @@ if ($action == 'edit') { include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $mail = new CMailFile('', '', '', '', array(), array(), array(), '', '', 0, 0, '', '', '', $trackid, $sendcontext); - $result = $mail->check_server_port($server, $port); + $result = $mail->check_server_port((string) $server, (int) $port); if ($result) { - print '
'.$langs->trans("ServerAvailableOnIPOrPort", $server, $port).'
'; + print '
'.$langs->trans("ServerAvailableOnIPOrPort", (string) $server, (string) $port).'
'; } else { - $errormsg = $langs->trans("ServerNotAvailableOnIPOrPort", $server, $port); + $errormsg = $langs->trans("ServerNotAvailableOnIPOrPort", (string) $server, (string) $port); if ($mail->error) { $errormsg .= ' - '.$mail->error; diff --git a/htdocs/admin/mails_passwordreset.php b/htdocs/admin/mails_passwordreset.php index 6433b63486c..e82e69e47c5 100644 --- a/htdocs/admin/mails_passwordreset.php +++ b/htdocs/admin/mails_passwordreset.php @@ -4,6 +4,7 @@ * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2016 Jonathan TISSEAU * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 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 @@ -798,11 +799,11 @@ if ($action == 'edit') { include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $mail = new CMailFile('', '', '', '', array(), array(), array(), '', '', 0, 0, '', '', '', $trackid, $sendcontext); - $result = $mail->check_server_port($server, $port); + $result = $mail->check_server_port((string) $server, (int) $port); if ($result) { - print '
'.$langs->trans("ServerAvailableOnIPOrPort", $server, $port).'
'; + print '
'.$langs->trans("ServerAvailableOnIPOrPort", (string) $server, (string) $port).'
'; } else { - $errormsg = $langs->trans("ServerNotAvailableOnIPOrPort", $server, $port); + $errormsg = $langs->trans("ServerNotAvailableOnIPOrPort", (string) $server, (string) $port); if ($mail->error) { $errormsg .= ' - '.$mail->error; diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index a586d8407bb..7bc4d49b6f5 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -2,7 +2,7 @@ /* Copyright (C) 2007-2017 Laurent Destailleur * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 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 @@ -759,13 +759,13 @@ while ($i < $imaxinloop) { if (!empty($arrayfields['t.'.$key]['checked'])) { print '$key)) { - print ' title="'.dol_escape_htmltag($object->$key).'"'; + print ' title="'.dol_escape_htmltag((string) $object->$key).'"'; } print '>'; if ($key == 'status') { print $object->getLibStatut(5); } elseif ($key == 'rowid') { - print $object->showOutputField($val, $key, $object->id, ''); + print $object->showOutputField($val, $key, (string) $object->id, ''); } else { print $object->showOutputField($val, $key, $object->$key, ''); } diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index e6fefde8be8..d3ce6b98013 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -696,7 +696,7 @@ $titlepicto = 'title_setup'; $url = DOL_URL_ROOT.'/admin/mails_templates.php?action=create'; $newcardbutton = ''; -$newcardbutton .= dolGetButtonTitle($langs->trans('NewEMailTemplate'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewEMailTemplate'), '', 'fa fa-plus-circle', $url, '', (int) $permissiontoadd); if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) { diff --git a/htdocs/admin/mails_ticket.php b/htdocs/admin/mails_ticket.php index 6666861cf89..ef05ad1246d 100644 --- a/htdocs/admin/mails_ticket.php +++ b/htdocs/admin/mails_ticket.php @@ -4,6 +4,7 @@ * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2016 Jonathan TISSEAU * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 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 @@ -740,11 +741,11 @@ if ($action == 'edit') { include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $mail = new CMailFile('', '', '', '', array(), array(), array(), '', '', 0, 0, '', '', '', $trackid, $sendcontext); - $result = $mail->check_server_port($server, $port); + $result = $mail->check_server_port((string) $server, (int) $port); if ($result) { - print '
'.$langs->trans("ServerAvailableOnIPOrPort", $server, $port).'
'; + print '
'.$langs->trans("ServerAvailableOnIPOrPort", (string) $server, (string) $port).'
'; } else { - $errormsg = $langs->trans("ServerNotAvailableOnIPOrPort", $server, $port); + $errormsg = $langs->trans("ServerNotAvailableOnIPOrPort", (string) $server, (string) $port); if ($mail->error) { $errormsg .= ' - '.$mail->error; diff --git a/htdocs/admin/menus/index.php b/htdocs/admin/menus/index.php index ff2fd1944a3..82adeb82823 100644 --- a/htdocs/admin/menus/index.php +++ b/htdocs/admin/menus/index.php @@ -3,7 +3,7 @@ * Copyright (C) 2007-2012 Laurent Destailleur * Copyright (C) 2009-2012 Regis Houssin * Copyright (C) 2019-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 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 @@ -105,7 +105,7 @@ if ($action == 'up') { $sql .= " AND m.menu_handler='".$db->escape($menu_handler_to_search)."'"; $sql .= " AND m.entity = ".$conf->entity; $sql .= " AND m.type = '".$db->escape($current['type'])."'"; - $sql .= " AND m.fk_menu = '".$db->escape($current['fk_menu'])."'"; + $sql .= " AND m.fk_menu = '".$db->escape((string) $current['fk_menu'])."'"; $sql .= " ORDER BY m.position, m.rowid"; dol_syslog("admin/menus/index.php ".$sql); $result = $db->query($sql); @@ -156,7 +156,7 @@ if ($action == 'up') { $sql .= " AND m.menu_handler='".$db->escape($menu_handler_to_search)."'"; $sql .= " AND m.entity = ".$conf->entity; $sql .= " AND m.type = '".$db->escape($current['type'])."'"; - $sql .= " AND m.fk_menu = '".$db->escape($current['fk_menu'])."'"; + $sql .= " AND m.fk_menu = '".$db->escape((string) $current['fk_menu'])."'"; $sql .= " ORDER BY m.position, m.rowid"; dol_syslog("admin/menus/index.php ".$sql); $result = $db->query($sql); diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index 1df42a44853..75196d20408 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -1,7 +1,7 @@ * Copyright (C) 2015 ATM Consulting - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software: you can redistribute it and/or modify @@ -96,7 +96,7 @@ if ($action == 'add_currency') { if (!$error) { if ($currency->create($user) > 0) { - if ($currency->addRate($rate)) { + if ($currency->addRate((float) $rate)) { setEventMessages($langs->trans('RecordSaved'), array()); } else { setEventMessages($langs->trans('ErrorAddRateFail'), array(), 'errors'); @@ -119,7 +119,7 @@ if ($action == 'add_currency') { } if (!$error) { if ($currency->fetch($fk_multicurrency) > 0) { - $result = $currency->updateRate($rate); + $result = $currency->updateRate((float) $rate); if ($result < 0) { setEventMessages(null, $currency->errors, 'errors'); } diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php index 66ecf18434e..39afe8540fb 100644 --- a/htdocs/admin/receiptprinter.php +++ b/htdocs/admin/receiptprinter.php @@ -3,7 +3,7 @@ * Copyright (C) 2015-2024 Frédéric France * Copyright (C) 2016 Juanjo Menent * Copyright (C) 2020 Andreu Bisquerra Gaya - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Abbes Bahfir * * This program is free software; you can redistribute it and/or modify @@ -379,9 +379,9 @@ if ($mode == 'config' && $user->admin) { if ($action == 'editprinter' && $printer->listprinters[$line]['rowid'] == $printerid) { print ''; print ''; - $ret = $printer->selectTypePrinter($printer->listprinters[$line]['fk_type']); + $ret = $printer->selectTypePrinter((string) $printer->listprinters[$line]['fk_type']); print ''.$printer->resprint.''; - $ret = $printer->selectProfilePrinter($printer->listprinters[$line]['fk_profile']); + $ret = $printer->selectProfilePrinter((string) $printer->listprinters[$line]['fk_profile']); print ''.$printer->profileresprint.''; print ''; print ''; diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index dc06c693897..dbb9e5a2e77 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -4,7 +4,7 @@ * Copyright (C) 2007-2012 Regis Houssin * Copyright (C) 2015-2024 Frédéric France * Copyright (C) 2017 Nicolas ZABOURI - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 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 @@ -302,7 +302,7 @@ if (empty($error) && !empty($xml)) { $out .= ''.dol_escape_htmltag($file['filename']).''."\n"; $out .= ''; if (!empty($file['expectedsize'])) { - $out .= dol_print_size($file['expectedsize']); + $out .= dol_print_size((int) $file['expectedsize']); } $out .= ''."\n"; $out .= ''.dol_escape_htmltag($file['expectedmd5']).''."\n"; @@ -343,7 +343,7 @@ if (empty($error) && !empty($xml)) { $out .= ''.dol_escape_htmltag($file['md5']).''."\n"; $out .= ''; if ($file['expectedsize']) { - $out .= dol_print_size($file['expectedsize']); + $out .= dol_print_size((int) $file['expectedsize']); } $out .= ''."\n"; $size = dol_filesize(DOL_DOCUMENT_ROOT.'/'.$file['filename']); @@ -396,7 +396,7 @@ if (empty($error) && !empty($xml)) { $out .= ' '.$form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helprm'.$i); } $out .= ''."\n"; - $out .= ''.dol_escape_htmltag($file['expectedmd5']).''."\n"; // @phan-suppress-current-line PhanTypeInvalidDimOffset + $out .= ''.dol_escape_htmltag((string) $file['expectedmd5']).''."\n"; // @phan-suppress-current-line PhanTypeInvalidDimOffset $out .= ''.dol_escape_htmltag($file['md5']).''."\n"; $size = dol_filesize(DOL_DOCUMENT_ROOT.'/'.$file['filename']); $totalsize += $size; diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php index c991bdaf220..bbf74632456 100644 --- a/htdocs/admin/system/modules.php +++ b/htdocs/admin/system/modules.php @@ -2,7 +2,7 @@ /* Copyright (C) 2005-2009 Laurent Destailleur * Copyright (C) 2007 Rodolphe Quiedeville * Copyright (C) 2010-2012 Regis Houssin - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -68,15 +68,14 @@ $object = new stdClass(); // Definition of fields for lists $arrayfields = array( - 'name' => array('label' => $langs->trans("Modules"), 'checked' => 1, 'position' => 10), - 'version' => array('label' => $langs->trans("Version"), 'checked' => 1, 'position' => 20), - 'id' => array('label' => $langs->trans("IdModule"), 'checked' => 1, 'position' => 30), - 'module_position' => array('label' => $langs->trans("Position"), 'checked' => 1, 'position' => 35), - 'permission' => array('label' => $langs->trans("IdPermissions"), 'checked' => 1, 'position' => 40) + 'name' => array('label' => $langs->trans("Modules"), 'checked' => '1', 'position' => 10), + 'version' => array('label' => $langs->trans("Version"), 'checked' => '1', 'position' => 20), + 'id' => array('label' => $langs->trans("IdModule"), 'checked' => '1', 'position' => 30), + 'module_position' => array('label' => $langs->trans("Position"), 'checked' => '1', 'position' => 35), + 'permission' => array('label' => $langs->trans("IdPermissions"), 'checked' => '1', 'position' => 40) ); $arrayfields = dol_sort_array($arrayfields, 'position'); -'@phan-var-force array,position:int}> $arrayfields'; $param = ''; $info_admin = ''; diff --git a/htdocs/admin/taxes.php b/htdocs/admin/taxes.php index d70217c985e..5247e69aa57 100644 --- a/htdocs/admin/taxes.php +++ b/htdocs/admin/taxes.php @@ -6,7 +6,7 @@ * Copyright (C) 2015-2022 Alexandre Spangaro * Copyright (C) 2023 Joachim Kueter * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 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,10 +110,10 @@ if ($action == 'update') { $valuebuyservice = 'payment'; break; default: - $valuesellproduct = null; - $valuebuyproduct = null; - $valuesellservice = null; - $valuebuyservice = null; + $valuesellproduct = ''; + $valuebuyproduct = ''; + $valuesellservice = ''; + $valuebuyservice = ''; break; } diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index 3feb6223eda..481e03995e4 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -3,7 +3,7 @@ * Copyright (C) 2016 Christophe Battarel * Copyright (C) 2022-2023 Udo Tamm * Copyright (C) 2023 Alexandre Spangaro - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * Copyright (C) 2024-2025 Benjamin Falière * @@ -359,7 +359,7 @@ foreach ($dirmodels as $reldir) { } print ''; - print $formcategory->textwithpicto('', $htmltooltip, 1, 0); + print $formcategory->textwithpicto('', $htmltooltip, 1, '0'); print ''; print ''; @@ -510,7 +510,7 @@ foreach ($dirmodels as $reldir) { print ''; - print $formcategory->textwithpicto('', $htmltooltip, 1, 0); + print $formcategory->textwithpicto('', $htmltooltip, 1, '0'); print ''; print "\n"; diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php index e22207e3f84..08661302c82 100644 --- a/htdocs/admin/tools/export.php +++ b/htdocs/admin/tools/export.php @@ -4,6 +4,7 @@ * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2021 Regis Houssin * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 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 @@ -147,7 +148,7 @@ if ($what == 'mysql') { } if (!$errormsg) { - $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file, 0, 0, $lowmemorydump); + $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file, 0, 0, (int) $lowmemorydump); $errormsg = $utils->error; $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; $_SESSION["commandbackuptorun"] = $utils->result['commandbackuptorun']; @@ -156,7 +157,7 @@ if ($what == 'mysql') { // MYSQL NO BIN if ($what == 'mysqlnobin') { - $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file, 0, 0, $lowmemorydump); + $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file, 0, 0, (int) $lowmemorydump); $errormsg = $utils->error; $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; @@ -186,7 +187,7 @@ if ($what == 'postgresql') { } if (!$errormsg) { - $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file, 0, 0, $lowmemorydump); + $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file, 0, 0, (int) $lowmemorydump); $errormsg = $utils->error; $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; $_SESSION["commandbackuptorun"] = $utils->result['commandbackuptorun']; diff --git a/htdocs/asset/admin/setup.php b/htdocs/asset/admin/setup.php index 4930864aa71..d361ca541f7 100644 --- a/htdocs/asset/admin/setup.php +++ b/htdocs/asset/admin/setup.php @@ -518,7 +518,7 @@ if ($action == 'edit') { $tmp = explode(':', $val['type']); print img_picto('', 'category', 'class="pictofixedwidth"'); - print $formother->select_categories($tmp[1], getDolGlobalString($constname), $constname, 0, $langs->trans('CustomersProspectsCategoriesShort')); + print $formother->select_categories($tmp[1], getDolGlobalInt($constname), $constname, 0, $langs->trans('CustomersProspectsCategoriesShort')); } elseif (preg_match('/thirdparty_type/', $val['type'])) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; $formcompany = new FormCompany($db); @@ -534,7 +534,7 @@ if ($action == 'edit') { print dolJSToSetRandomPassword($constname, 'generate_token'.$constname); } elseif ($val['type'] == 'product') { if (isModEnabled("product") || isModEnabled("service")) { - $selected = getDolGlobalString($constname); + $selected = getDolGlobalInt($constname); $form->select_produits($selected, $constname, '', 0); } } elseif ($val['type'] == 'accountancy_code') { @@ -542,7 +542,7 @@ if ($action == 'edit') { if (isModEnabled('accounting')) { require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; $formaccounting = new FormAccounting($db); - print $formaccounting->select_account($selected, $constname, 1, array(), 1, 1, 'minwidth150 maxwidth300', 1); + print $formaccounting->select_account($selected, $constname, 1, array(), 1, 1, 'minwidth150 maxwidth300', '1'); } else { print ''; } @@ -608,7 +608,7 @@ if ($action == 'edit') { $tmp = explode(':', $val['type']); - $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname)); + $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalInt($constname)); if ($template < 0) { setEventMessages(null, $formmail->errors, 'errors'); } diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index 90e2b45993b..bd4c357ddee 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -514,7 +514,7 @@ class dolReceiptPrinter extends Printer * Function to add a printer template in db * * @param string $name Template name - * @param int $template Template + * @param string $template Template * @return int 0 if OK; >0 if KO */ public function addTemplate($name, $template) @@ -523,7 +523,7 @@ class dolReceiptPrinter extends Printer $error = 0; $sql = "INSERT INTO ".$this->db->prefix()."printer_receipt_template"; $sql .= " (name, template, entity) VALUES ('".$this->db->escape($name)."'"; - $sql .= ", '".$this->db->escape((string) $template)."', ".$conf->entity.")"; + $sql .= ", '".$this->db->escape($template)."', ".$conf->entity.")"; $resql = $this->db->query($sql); if (!$resql) { $error++; @@ -557,7 +557,7 @@ class dolReceiptPrinter extends Printer * Function to Update a printer template in db * * @param string $name Template name - * @param int $template Template + * @param string $template Template * @param int $templateid Template id * @return int 0 if OK; >0 if KO */ @@ -568,7 +568,7 @@ class dolReceiptPrinter extends Printer $sql = "UPDATE ".$this->db->prefix()."printer_receipt_template"; $sql .= " SET name='".$this->db->escape($name)."'"; - $sql .= ", template='".$this->db->escape((string) $template)."'"; + $sql .= ", template='".$this->db->escape($template)."'"; $sql .= " WHERE rowid=".((int) $templateid); $resql = $this->db->query($sql); if (!$resql) {