From 05e6c8ce11e7fc82e09ada4b13bb16098cf9771b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 18 Oct 2025 19:09:52 +0200 Subject: [PATCH] Fix phpstan (#35828) * clean phpstan baseline * clean baseline * clean baseline * clean baseline * clean baseline --- dev/build/phpstan/phpstan-baseline.neon | 78 ------------------- .../tpl/depreciation_options_view.tpl.php | 1 + htdocs/compta/tva/clients.php | 1 + .../tpl/extrafields_list_print_fields.tpl.php | 3 + .../tpl/extrafields_list_search_sql.tpl.php | 2 + htdocs/core/tpl/filemanager.tpl.php | 11 ++- .../core/tpl/objectlinked_lineimport.tpl.php | 14 ++-- 7 files changed, 23 insertions(+), 87 deletions(-) diff --git a/dev/build/phpstan/phpstan-baseline.neon b/dev/build/phpstan/phpstan-baseline.neon index 7c91286d1ca..c23f77e134e 100644 --- a/dev/build/phpstan/phpstan-baseline.neon +++ b/dev/build/phpstan/phpstan-baseline.neon @@ -1410,12 +1410,6 @@ parameters: count: 1 path: ../../../htdocs/asset/tpl/depreciation_options_edit.tpl.php - - - message: '#^Variable \$db might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/asset/tpl/depreciation_options_view.tpl.php - - message: '#^Variable \$parameters might not be defined\.$#' identifier: variable.undefined @@ -4032,12 +4026,6 @@ parameters: count: 1 path: ../../../htdocs/compta/tva/clients.php - - - message: '#^Variable \$description might not be defined\.$#' - identifier: variable.undefined - count: 8 - path: ../../../htdocs/compta/tva/clients.php - - message: '#^Strict comparison using \=\=\= between true and true will always evaluate to true\.$#' identifier: identical.alwaysTrue @@ -8658,42 +8646,18 @@ parameters: count: 1 path: ../../../htdocs/core/tpl/extrafields_list_array_fields.tpl.php - - - message: '#^Variable \$db might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/core/tpl/extrafields_list_print_fields.tpl.php - - message: '#^Variable \$i might not be defined\.$#' identifier: variable.undefined count: 1 path: ../../../htdocs/core/tpl/extrafields_list_print_fields.tpl.php - - - message: '#^Variable \$obj might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/core/tpl/extrafields_list_print_fields.tpl.php - - message: '#^Variable \$totalarray might not be defined\.$#' identifier: variable.undefined count: 2 path: ../../../htdocs/core/tpl/extrafields_list_print_fields.tpl.php - - - message: '#^Variable \$db might not be defined\.$#' - identifier: variable.undefined - count: 8 - path: ../../../htdocs/core/tpl/extrafields_list_search_sql.tpl.php - - - - message: '#^Variable \$sql might not be defined\.$#' - identifier: variable.undefined - count: 7 - path: ../../../htdocs/core/tpl/extrafields_list_search_sql.tpl.php - - message: '#^Variable \$param might not be defined\.$#' identifier: variable.undefined @@ -8712,36 +8676,6 @@ parameters: count: 1 path: ../../../htdocs/core/tpl/filemanager.tpl.php - - - message: '#^Variable \$action might not be defined\.$#' - identifier: variable.undefined - count: 6 - path: ../../../htdocs/core/tpl/filemanager.tpl.php - - - - message: '#^Variable \$ecmdir might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/core/tpl/filemanager.tpl.php - - - - message: '#^Variable \$filepathnoext might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/core/tpl/filemanager.tpl.php - - - - message: '#^Variable \$module in empty\(\) always exists and is not falsy\.$#' - identifier: empty.variable - count: 1 - path: ../../../htdocs/core/tpl/filemanager.tpl.php - - - - message: '#^Variable \$pageid might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../../htdocs/core/tpl/filemanager.tpl.php - - message: '#^Variable \$websitekey might not be defined\.$#' identifier: variable.undefined @@ -8814,18 +8748,6 @@ parameters: count: 2 path: ../../../htdocs/core/tpl/objectline_view.tpl.php - - - message: '#^Variable \$langs might not be defined\.$#' - identifier: variable.undefined - count: 4 - path: ../../../htdocs/core/tpl/objectlinked_lineimport.tpl.php - - - - message: '#^Variable \$object might not be defined\.$#' - identifier: variable.undefined - count: 3 - path: ../../../htdocs/core/tpl/objectlinked_lineimport.tpl.php - - message: '#^Variable \$langs might not be defined\.$#' identifier: variable.undefined diff --git a/htdocs/asset/tpl/depreciation_options_view.tpl.php b/htdocs/asset/tpl/depreciation_options_view.tpl.php index 6994eeb1f50..59353160a24 100644 --- a/htdocs/asset/tpl/depreciation_options_view.tpl.php +++ b/htdocs/asset/tpl/depreciation_options_view.tpl.php @@ -27,6 +27,7 @@ */ /** + * @var DoliDB $db * @var Form $form * @var HookManager $hookmanager * @var AssetDepreciationOptions $assetdepreciationoptions diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php index 4229cec5b6e..dcd9189c1f3 100644 --- a/htdocs/compta/tva/clients.php +++ b/htdocs/compta/tva/clients.php @@ -155,6 +155,7 @@ $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '. $builddate = dol_now(); +$description = ''; if (getDolGlobalString('TAX_MODE_SELL_PRODUCT') == 'invoice') { $description = $langs->trans("RulesVATDueProducts"); } diff --git a/htdocs/core/tpl/extrafields_list_print_fields.tpl.php b/htdocs/core/tpl/extrafields_list_print_fields.tpl.php index 4328520dfc5..440cb592b34 100644 --- a/htdocs/core/tpl/extrafields_list_print_fields.tpl.php +++ b/htdocs/core/tpl/extrafields_list_print_fields.tpl.php @@ -20,6 +20,8 @@ /** * @var Conf $conf * @var CommonObject $object + * @var stdClass $obj + * @var DoliDB $db * @var ExtraFields $extrafields * * @var string $extrafieldsobjectkey @@ -27,6 +29,7 @@ ' @phan-var-force CommonObject $object +@phan-var-force stdClass $obj '; // Protection to avoid direct call of template diff --git a/htdocs/core/tpl/extrafields_list_search_sql.tpl.php b/htdocs/core/tpl/extrafields_list_search_sql.tpl.php index fb50e5fcd79..30fee094541 100644 --- a/htdocs/core/tpl/extrafields_list_search_sql.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_sql.tpl.php @@ -24,7 +24,9 @@ /** * @var Conf $conf * @var CommonObject $object + * @var DoliDB $db * @var ExtraFields $extrafields + * @var string $sql */ // Protection to avoid direct call of template diff --git a/htdocs/core/tpl/filemanager.tpl.php b/htdocs/core/tpl/filemanager.tpl.php index 8ae866f2194..dad6e61aa56 100644 --- a/htdocs/core/tpl/filemanager.tpl.php +++ b/htdocs/core/tpl/filemanager.tpl.php @@ -23,13 +23,19 @@ /** * @var Conf $conf * @var DoliDB $db + * @var EcmDirectory $ecmdir * @var Form $form * @var HookManager $hookmanager * @var Translate $langs * @var User $user * @var Website $website * - * @var string $module + * @var string $action + * @var ?string $module + * @var int $section + * @var string $filepathnoext + * @var string $pageid + * @var int $formalreadyopen */ // Protection to avoid direct call of template if (empty($conf) || !is_object($conf)) { @@ -42,6 +48,7 @@ if (empty($conf) || !is_object($conf)) { @phan-var-force string $filepathnoext @phan-var-force string $pageid @phan-var-force EcmDirectory $ecmdir +@phan-var-force ?string $module @phan-var-force int $section '; @@ -56,7 +63,7 @@ require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; $langs->load("ecm"); -if (empty($module)) { +if (!isset($module)) { $module = 'ecm'; } diff --git a/htdocs/core/tpl/objectlinked_lineimport.tpl.php b/htdocs/core/tpl/objectlinked_lineimport.tpl.php index c6ac5664b3c..720b8cba1f7 100644 --- a/htdocs/core/tpl/objectlinked_lineimport.tpl.php +++ b/htdocs/core/tpl/objectlinked_lineimport.tpl.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2011-2013 Regis Houssin * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify @@ -15,6 +15,11 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ +/** + * @var Conf $conf + * @var CommonObject $object + * @var Translate $langs + */ // Protection to avoid direct call of template if (empty($conf) || !is_object($conf)) { @@ -24,7 +29,7 @@ if (empty($conf) || !is_object($conf)) { $objectUrl = $object->getNomUrl(0, '', '0', 1); if ($object->element == 'propal') { - $objectUrl = DOL_URL_ROOT.'/comm/propal/card.php?id='.$object->id; + $objectUrl = dolBuildUrl(DOL_URL_ROOT.'/comm/propal/card.php', ['id' => $object->id]); } ?> @@ -94,12 +99,7 @@ $(document).ready(function(){ { $.jnotify("trans('ErrorNoUrl'); ?>", "error", true); } - }); - - - - });