From ca850421f093db68ee5e136901eda23ce6e131b8 Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 20 Apr 2026 12:35:28 +0200 Subject: [PATCH] Qual: Fix phpstan notices (#37932) * Qual: Fix phpstan notices # Qual: Fix phpstan notices. - Fix ModeleBoxes::$info_box_contents typing; - Fix validate value to non-string (htdocs/asset/card.php) - Fix type for lines_model in FormMail * Qual: Fix get_tz_array() return typehint * Qual: Fix arguments types to mktime, dol_time --------- Co-authored-by: Laurent Destailleur --- htdocs/asset/card.php | 4 ++-- htdocs/core/boxes/modules_boxes.php | 7 +++---- htdocs/core/class/html.formmail.class.php | 2 +- htdocs/core/lib/date.lib.php | 4 ++-- htdocs/opensurvey/wizard/choix_date.php | 8 ++++---- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php index 6d7c7b9ad60..626f315b22c 100644 --- a/htdocs/asset/card.php +++ b/htdocs/asset/card.php @@ -2,7 +2,7 @@ /* Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2018-2025 Alexandre Spangaro * Copyright (C) 2024-2025 Frédéric France - * Copyright (C) 2025 MDW + * Copyright (C) 2025-2026 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 @@ -198,7 +198,7 @@ if ($action == 'create') { print ''; } if (GETPOSTISSET('supplier_invoice_id')) { - $object->fields['supplier_invoice_id'] = array('type' => 'integer:FactureFournisseur:fourn/class/fournisseur.facture.class.php:1:entity IN (__SHARED_ENTITIES__)', 'label' => 'SupplierInvoice', 'enabled' => '1', 'noteditable' => 1, 'position' => 280, 'notnull' => 0, 'visible' => 1, 'index' => 1, 'validate' => '1',); + $object->fields['supplier_invoice_id'] = array('type' => 'integer:FactureFournisseur:fourn/class/fournisseur.facture.class.php:1:entity IN (__SHARED_ENTITIES__)', 'label' => 'SupplierInvoice', 'enabled' => '1', 'noteditable' => 1, 'position' => 280, 'notnull' => 0, 'visible' => 1, 'index' => 1, 'validate' => 1,); print ''; } diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index d7d85fbe8b6..dff0b0dc257 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -3,7 +3,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Raphaël Doursenaud * Copyright (C) 2015-2025 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2026 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 @@ -52,12 +52,12 @@ class ModeleBoxes // Can't be abstract as it is instantiated to build "empty" bo public $param; /** - * @var array,sublink?:string,subtext?:string,picto?:string,target?:string,td?:string}>|array{text:string,nbcol?:int,limit?:int,graph?:int<0,1>,sublink?:string,subtext?:string,picto?:string,target?:string,td?:string} box info heads. Example: array('text' => $langs->trans("BoxScheduledJobs", $max), 'nbcol' => 4); + * @var array,sublink?:string,subtext?:string,picto?:string,target?:string,td?:string}>|array{text:string,nbcol?:int,limit?:int,graph?:int<0,1>,sublink?:string,subtext?:string,picto?:string,target?:string,td?:string} box info heads. Example: array('text' =>->trans("BoxScheduledJobs",), 'nbcol' => 4); */ public $info_box_head = array(); /** - * @var array,maxlength?:int}>>|array,maxlength?:int}> box info content + * @var array,maxlength?:int}|array{td?:string,textnoformat:string,asis?:int<0,1>,maxlength?:int}>>|array,maxlength?:int}|array{td?:string,textnoformat:string,asis?:int<0,1>,maxlength?:int}> box info content */ public $info_box_contents = array(); @@ -487,7 +487,6 @@ class ModeleBoxes // Can't be abstract as it is instantiated to build "empty" bo * * @param ?string[] $forcedirwidget null=All default directories. This parameter is used by modulebuilder module only. * @return array Array list of widgets - * */ public static function getWidgetsList($forcedirwidget = null) { diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 80ab6189190..2bf8b35d575 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -266,7 +266,7 @@ class FormMail extends Form public $withtoccuser = array(); /** - * @var ModelMail[] + * @var CEmailTemplate[] */ public $lines_model; diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 34eff7dc3c4..9e5ef6f8596 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -4,7 +4,7 @@ * Copyright (C) 2011-2015 Juanjo Menent * Copyright (C) 2017 Ferran Marcet * Copyright (C) 2018-2024 Charlene Benke - * Copyright (C) 2024-2025 MDW + * Copyright (C) 2024-2026 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -31,7 +31,7 @@ /** * Return an array with timezone values * - * @return array,string> Array with timezone values + * @return array,string> Array with timezone values */ function get_tz_array() { diff --git a/htdocs/opensurvey/wizard/choix_date.php b/htdocs/opensurvey/wizard/choix_date.php index 2fb2ac4b67f..4bae05abb1a 100644 --- a/htdocs/opensurvey/wizard/choix_date.php +++ b/htdocs/opensurvey/wizard/choix_date.php @@ -427,7 +427,7 @@ if (issetAndNoEmpty('choixjourajout')) { $nbofchoice = count($_SESSION["totalchoixjour"]); for ($i = 0; $i < $nbofchoice; $i++) { $choixjourajout = GETPOST("choixjourajout"); - if ($_SESSION["totalchoixjour"][$i] == mktime(0, 0, 0, $_SESSION["mois"], $choixjourajout[0], $_SESSION["annee"])) { + if ($_SESSION["totalchoixjour"][$i] == mktime(0, 0, 0, $_SESSION["mois"], (int) $choixjourajout[0], $_SESSION["annee"])) { $journeuf = false; } } @@ -436,9 +436,9 @@ if (issetAndNoEmpty('choixjourajout')) { // If the validation is ok, add a field to the session variables that holds all the dates if ($journeuf && issetAndNoEmpty('choixjourajout') === true) { $choixjourajout = GETPOST("choixjourajout"); - array_push($_SESSION["totalchoixjour"], dol_mktime(0, 0, 0, $_SESSION["mois"], $choixjourajout[0], $_SESSION["annee"])); + array_push($_SESSION["totalchoixjour"], dol_mktime(0, 0, 0, $_SESSION["mois"], (int) $choixjourajout[0], $_SESSION["annee"])); sort($_SESSION["totalchoixjour"]); - $cle = array_search(dol_mktime(0, 0, 0, $_SESSION["mois"], $choixjourajout[0], $_SESSION["annee"]), $_SESSION["totalchoixjour"]); + $cle = array_search(dol_mktime(0, 0, 0, $_SESSION["mois"], (int) $choixjourajout[0], $_SESSION["annee"]), $_SESSION["totalchoixjour"]); //On sauvegarde les heures deja entrées for ($i = 0; $i < $cle; $i++) { @@ -479,7 +479,7 @@ if (issetAndNoEmpty('choixjourretrait')) { for ($i = 0; $i < $nbofchoice; $i++) { $choixjourretrait = GETPOST('choixjourretrait'); - if ($_SESSION["totalchoixjour"][$i] == mktime(0, 0, 0, $_SESSION["mois"], $choixjourretrait[0], $_SESSION["annee"])) { + if ($_SESSION["totalchoixjour"][$i] == mktime(0, 0, 0, $_SESSION["mois"], (int) $choixjourretrait[0], $_SESSION["annee"])) { for ($j = $i; $j < $nbofchoice; $j++) { $k = $j + 1; $_SESSION["horaires$j"] = $_SESSION["horaires$k"];