2
0
forked from Wavyzz/dolibarr

Qual: Fix phan notices (main.inc,master.inc)

This commit is contained in:
MDW
2025-02-04 00:36:09 +01:00
parent b8e083a4a0
commit 5ead746511
2 changed files with 23 additions and 11 deletions

View File

@@ -17,7 +17,7 @@
* Copyright (C) 2021 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2023 Joachim Küter <git-jk@bloxera.com> * Copyright (C) 2023 Joachim Küter <git-jk@bloxera.com>
* Copyright (C) 2023 Eric Seigne <eric.seigne@cap-rel.fr> * Copyright (C) 2023 Eric Seigne <eric.seigne@cap-rel.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -255,7 +255,7 @@ function testSqlAndScriptInject($val, $type)
/** /**
* Return true if security check on parameters are OK, false otherwise. * Return true if security check on parameters are OK, false otherwise.
* *
* @param string|array<string,string> $var Variable name * @param string|array<int|string,string> $var Variable name
* @param int<0,2> $type 1=GET, 0=POST, 2=PHP_SELF * @param int<0,2> $type 1=GET, 0=POST, 2=PHP_SELF
* @param int<0,1> $stopcode 0=No stop code, 1=Stop code (default) if injection found * @param int<0,1> $stopcode 0=No stop code, 1=Stop code (default) if injection found
* @return boolean True if there is no injection. * @return boolean True if there is no injection.
@@ -3133,7 +3133,7 @@ function printDropdownQuickadd($mode = 0)
// Allow the $items of the menu to be manipulated by modules // Allow the $items of the menu to be manipulated by modules
$parameters = array(); $parameters = array();
$hook_items = $items; $hook_items = $items;
$reshook = $hookmanager->executeHooks('menuDropdownQuickaddItems', $parameters, $hook_items); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('menuDropdownQuickaddItems', $parameters, $hook_items); // Note that $action and $object may have been modified by some hooks @phan-suppress-current-line PhanTypeMismatchArgument
if (is_numeric($reshook) && !empty($hookmanager->resArray) && is_array($hookmanager->resArray)) { if (is_numeric($reshook) && !empty($hookmanager->resArray) && is_array($hookmanager->resArray)) {
if ($reshook == 0) { if ($reshook == 0) {
$items['items'] = array_merge($items['items'], $hookmanager->resArray); // add $items['items'] = array_merge($items['items'], $hookmanager->resArray); // add
@@ -3498,7 +3498,7 @@ function left_menu($menu_array_before, $helppagename = '', $notused = '', $menu_
//$textsearch = $langs->trans("Search"); //$textsearch = $langs->trans("Search");
$textsearch = '<span class="fa fa-search paddingright pictofixedwidth"></span>'.$langs->trans("Search"); $textsearch = '<span class="fa fa-search paddingright pictofixedwidth"></span>'.$langs->trans("Search");
$searchform .= $form->selectArrayFilter('searchselectcombo', $arrayresult, $selected, 'accesskey="s"', 1, 0, (getDolGlobalString('MAIN_SEARCHBOX_CONTENT_LOADED_BEFORE_KEY') ? 0 : 1), 'vmenusearchselectcombo', 1, $textsearch, 1, $stringforfirstkey.' s'); $searchform .= $form->selectArrayFilter('searchselectcombo', $arrayresult, (string) $selected, 'accesskey="s"', 1, 0, (getDolGlobalString('MAIN_SEARCHBOX_CONTENT_LOADED_BEFORE_KEY') ? 0 : 1), 'vmenusearchselectcombo', 1, $textsearch, 1, $stringforfirstkey.' s');
} else { } else {
if (is_array($arrayresult)) { if (is_array($arrayresult)) {
// @phan-suppress-next-line PhanEmptyForeach // array is really empty in else case. // @phan-suppress-next-line PhanEmptyForeach // array is really empty in else case.

View File

@@ -10,7 +10,7 @@
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -45,6 +45,14 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
* @var string $dolibarr_main_url_root_alt * @var string $dolibarr_main_url_root_alt
*/ */
'
@phan-var-force ?string $dolibarr_main_db_prefix
@phan-var-force ?string $dolibarr_main_db_encryption
@phan-var-force ?string $dolibarr_main_db_cryptkey
@phan-var-force ?string $dolibarr_main_limit_users
@phan-var-force ?string $dolibarr_main_url_root_alt
';
if (!function_exists('is_countable')) { if (!function_exists('is_countable')) {
/** /**
* function is_countable (to remove when php version supported will be >= 7.3) * function is_countable (to remove when php version supported will be >= 7.3)
@@ -99,7 +107,7 @@ if (!empty($dolibarr_main_document_root_alt)) {
foreach ($values as $value) { foreach ($values as $value) {
$conf->file->dol_document_root['alt'.($i++)] = (string) $value; $conf->file->dol_document_root['alt'.($i++)] = (string) $value;
} }
$values = preg_split('/[;,]/', $dolibarr_main_url_root_alt); $values = preg_split('/[;,]/', (string) $dolibarr_main_url_root_alt);
$i = 0; $i = 0;
foreach ($values as $value) { foreach ($values as $value) {
if (preg_match('/^http(s)?:/', $value)) { if (preg_match('/^http(s)?:/', $value)) {
@@ -178,14 +186,16 @@ unset($conf->db->pass); // This is to avoid password to be shown in memory/swap
/* /*
* Object $user * Object $user
*/ */
if (!defined('NOREQUIREUSER')) { if (!defined('NOREQUIREUSER') && $db !== null) {
$user = new User($db); $user = new User($db);
} }
/* /*
* Create the global $hookmanager object * Create the global $hookmanager object
*/ */
$hookmanager = new HookManager($db); if ($db !== null) {
$hookmanager = new HookManager($db);
}
/* /*
@@ -212,10 +222,12 @@ if (!is_numeric($conf->entity)) {
} }
// Here we read database (llx_const table) and define conf var $conf->global->XXX. // Here we read database (llx_const table) and define conf var $conf->global->XXX.
//print "We work with data into entity instance number '".$conf->entity."'"; //print "We work with data into entity instance number '".$conf->entity."'";
$conf->setValues($db); if ($db !== null) {
$conf->setValues($db);
}
// Create object $mysoc (A thirdparty object that contains properties of companies managed by Dolibarr. // Create object $mysoc (A thirdparty object that contains properties of companies managed by Dolibarr.
if (!defined('NOREQUIREDB') && !defined('NOREQUIRESOC')) { if (!defined('NOREQUIREDB') && !defined('NOREQUIRESOC') && $db != null) {
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
$mysoc = new Societe($db); $mysoc = new Societe($db);