diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 1fef6d775bf..75c6db13818 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -540,7 +540,6 @@ return [ 'htdocs/core/extrafieldsinimport.inc.php' => ['PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredGlobalVariable'], 'htdocs/core/filemanagerdol/connectors/php/connector.lib.php' => ['PhanPluginConstantVariableNull', 'PhanPluginUnknownArrayFunctionParamType'], 'htdocs/core/get_info.php' => ['PhanPluginSuspiciousParamPosition'], - 'htdocs/core/get_menudiv.php' => ['PhanRedefinedClassReference'], 'htdocs/core/lib/accounting.lib.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanTypeInvalidLeftOperandOfNumericOp'], 'htdocs/core/lib/admin.lib.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/core/lib/agenda.lib.php' => ['PhanPluginConstantVariableNull', 'PhanPluginUnknownArrayFunctionParamType', 'PhanTypeMismatchArgumentProbablyReal'], @@ -581,11 +580,6 @@ return [ 'htdocs/core/lib/usergroups.lib.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/core/lib/website.lib.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgumentNullableInternal'], 'htdocs/core/lib/xcal.lib.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPossiblyUndeclaredVariable', 'PhanUndeclaredProperty'], - 'htdocs/core/menus/standard/auguria.lib.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanUndeclaredProperty'], - 'htdocs/core/menus/standard/auguria_menu.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType', 'PhanRedefineClass'], - 'htdocs/core/menus/standard/eldy.lib.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPossiblyUndeclaredVariable'], - 'htdocs/core/menus/standard/eldy_menu.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType', 'PhanRedefineClass', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/core/menus/standard/empty.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType', 'PhanRedefineClass'], 'htdocs/core/modules/DolibarrModules.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/core/modules/action/doc/pdf_standard_actions.class.php' => ['PhanPluginUnknownPropertyType', 'PhanUndeclaredMethod'], 'htdocs/core/modules/action/modules_action.php' => ['PhanPluginUnknownArrayMethodReturnType'], @@ -776,7 +770,6 @@ return [ 'htdocs/datapolicy/class/datapolicycron.class.php' => ['PhanPluginUnknownPropertyType'], 'htdocs/debugbar/class/DataCollector/DolConfigCollector.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/debugbar/class/DataCollector/DolExceptionsCollector.php' => ['PhanPluginUnknownArrayMethodReturnType'], - 'htdocs/debugbar/class/DataCollector/DolLogsCollector.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanRedefinedClassReference'], 'htdocs/debugbar/class/DataCollector/DolMemoryCollector.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/debugbar/class/DataCollector/DolPhpCollector.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/debugbar/class/DataCollector/DolQueryCollector.php' => ['PhanPluginUnknownArrayMethodReturnType'], @@ -957,7 +950,6 @@ return [ 'htdocs/loan/note.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/loan/payment/payment.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/loan/schedule.php' => ['PhanTypeInvalidLeftOperandOfNumericOp', 'PhanUndeclaredGlobalVariable'], - 'htdocs/main.inc.php' => ['PhanEmptyForeach', 'PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanPossiblyUndeclaredVariable', 'PhanRedefineFunction', 'PhanRedefinedClassReference', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/margin/customerMargins.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/margin/productMargins.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/master.inc.php' => ['PhanUndeclaredGlobalVariable'], diff --git a/htdocs/core/get_menudiv.php b/htdocs/core/get_menudiv.php index 928a316df01..27ae3b462f0 100644 --- a/htdocs/core/get_menudiv.php +++ b/htdocs/core/get_menudiv.php @@ -285,9 +285,12 @@ if (!class_exists('MenuManager')) { include_once DOL_DOCUMENT_ROOT."/core/menus/standard/".$file_menu; } } +// @phan-suppress-next-line PhanRedefinedClassReference $menumanager = new MenuManager($db, empty($user->socid) ? 0 : 1); +// @phan-suppress-next-line PhanRedefinedClassReference $menumanager->loadMenu('all', 'all'); // Load this->tabMenu with sql menu entries //var_dump($menumanager);exit; +// @phan-suppress-next-line PhanRedefinedClassReference $menumanager->showmenu('jmobile'); print ''; diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index 1305771d998..3f0aad13e43 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -29,13 +29,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; /** * Core function to output top menu auguria * - * @param DoliDB $db Database handler - * @param string $atarget Target (Example: '' or '_top') - * @param int $type_user 0=Menu for backoffice, 1=Menu for front office + * @param DoliDB $db Database handler + * @param string $atarget Target (Example: '' or '_top') + * @param int $type_user 0=Menu for backoffice, 1=Menu for front office * @param array,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,level:int,prefix:string}> $tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) - * @param Menu $menu Object Menu to return back list of menu entries - * @param int $noout 1=Disable output (Initialise &$menu only). - * @param string $mode 'top', 'topnb', 'left', 'jmobile' + * @param Menu $menu Object Menu to return back list of menu entries + * @param int<0,1> $noout 1=Disable output (Initialise &$menu only). + * @param string $mode 'top', 'topnb', 'left', 'jmobile' * @return int 0 */ function print_auguria_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 0, $mode = '') @@ -220,14 +220,14 @@ function print_start_menu_entry_auguria($idsel, $classname, $showmode) /** * Output menu entry * - * @param string $text Text - * @param int $showmode 0 = hide, 1 = allowed or 2 = not allowed - * @param string $url Url - * @param string $id Id - * @param string $idsel Id sel - * @param string $classname Class name - * @param string $atarget Target - * @param array $menuval All the $menuval array + * @param string $text Text + * @param int<0,2> $showmode 0 = hide, 1 = allowed or 2 = not allowed + * @param string $url Url + * @param string $id Id + * @param string $idsel Id sel + * @param string $classname Class name + * @param string $atarget Target + * @param array{rowid:string,fk_menu:string,langs:string,enabled:int<0,2>,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,level:int,prefix:string}|array{} $menuval The full $menuval array * @return void */ function print_text_menu_entry_auguria($text, $showmode, $url, $id, $idsel, $classname, $atarget, $menuval = array()) @@ -314,11 +314,11 @@ function print_end_menu_array_auguria() * @param array,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,level:int,prefix:string}> $menu_array_after Table of menu entries to show after entries of menu handler (menu->liste filled with menu->add) * @param array,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,level:int,prefix:string}> $tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) * @param Menu $menu Object Menu to return back list of menu entries - * @param int $noout Disable output (Initialise &$menu only). + * @param int<0,1> $noout Disable output (Initialise &$menu only). * @param string $forcemainmenu 'x'=Force mainmenu to mainmenu='x' * @param string $forceleftmenu 'all'=Force leftmenu to '' (= all). If value come being '', we change it to value in session and 'none' if not defined in session. - * @param array $moredata An array with more data to output - * @param int $type_user 0=Menu for backoffice, 1=Menu for front office + * @param ?array $moredata An array with more data to output + * @param int<0,1> $type_user 0=Menu for backoffice, 1=Menu for front office * @return int Nb of menu entries */ function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$tabMenu, &$menu, $noout = 0, $forcemainmenu = '', $forceleftmenu = '', $moredata = null, $type_user = 0) @@ -500,10 +500,10 @@ function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$t $reshook = $hookmanager->executeHooks('menuLeftMenuItems', $parameters, $hook_items); // Note that $action and $object may have been modified by some hooks if (is_numeric($reshook)) { - if ($reshook == 0 && !empty($hookmanager->results)) { - $menu_array[] = $hookmanager->results; // add + if ($reshook == 0 && !empty($hookmanager->resArray)) { + $menu_array[] = $hookmanager->resArray; // add } elseif ($reshook == 1) { - $menu_array = $hookmanager->results; // replace + $menu_array = $hookmanager->resArray; // replace } // @todo Sort menu items by 'position' value @@ -689,9 +689,9 @@ function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$t * Function to test if an entry is enabled or not * * @param string $type_user 0=We need backoffice menu, 1=We need frontoffice menu - * @param array $menuentry Array for menu entry - * @param array $listofmodulesforexternal Array with list of modules allowed to external users - * @return int 0=Hide, 1=Show, 2=Show gray + * @param array{rowid:string,fk_menu:string,langs:string,enabled:int<0,2>,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,level:int,prefix:string} $menuentry Array for menu entry + * @param string[] $listofmodulesforexternal Array with list of modules allowed to external users + * @return int<0,2> 0=Hide, 1=Show, 2=Show gray */ function dol_auguria_showmenu($type_user, &$menuentry, &$listofmodulesforexternal) { @@ -703,7 +703,7 @@ function dol_auguria_showmenu($type_user, &$menuentry, &$listofmodulesforexterna return 0; // Entry disabled by condition } if ($type_user && $menuentry['module']) { - $tmploops = explode('|', $menuentry['module']); + $tmploops = explode('|', (string) $menuentry['module']); $found = 0; foreach ($tmploops as $tmploop) { if (in_array($tmploop, $listofmodulesforexternal)) { diff --git a/htdocs/core/menus/standard/auguria_menu.php b/htdocs/core/menus/standard/auguria_menu.php index f35a334931b..5416dfad1f0 100644 --- a/htdocs/core/menus/standard/auguria_menu.php +++ b/htdocs/core/menus/standard/auguria_menu.php @@ -27,6 +27,8 @@ /** * Class to manage menu Auguria + * + * @phan-suppress PhanRedefineClass */ class MenuManager { @@ -36,12 +38,12 @@ class MenuManager public $db; /** - * @var int Put 0 for internal users, 1 for external users + * @var int<0,1> 0 for internal users, 1 for external users */ public $type_user; /** - * @var string To store default target to use onto links + * @var string Default target to use for links */ public $atarget = ""; @@ -55,9 +57,18 @@ class MenuManager */ public $menu; + /** + * @var array,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,level:int,prefix:string}> + */ public $menu_array; + /** + * @var array,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,level:int,prefix:string}> + */ public $menu_array_after; + /** + * @var array,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,level:int,prefix:string}> + */ public $tabMenu; @@ -65,7 +76,7 @@ class MenuManager * Constructor * * @param DoliDB $db Database handler - * @param int $type_user Type of user + * @param int<0,1> $type_user Type of user */ public function __construct($db, $type_user) { @@ -141,9 +152,9 @@ class MenuManager * Show menu. * Menu defined in sql tables were stored into $this->tabMenu BEFORE this is called. * - * @param string $mode 'top', 'topnb', 'left', 'jmobile' (used to get full xml ul/li menu) - * @param array $moredata An array with more data to output - * @return int 0 or nb of top menu entries if $mode = 'topnb' + * @param string $mode 'top', 'topnb', 'left', 'jmobile' (used to get full xml ul/li menu) + * @param ?array $moredata An array with more data to output + * @return int<0,max> 0 or nb of top menu entries if $mode = 'topnb' */ public function showmenu($mode, $moredata = null) { diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index a3f6a341221..2987a34f589 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -726,11 +726,11 @@ function print_end_menu_array() * @param array,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,level?:int,prefix:string}> $menu_array_after Table of menu entries to show after entries of menu handler (menu->liste filled with menu->add) * @param array,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,level?:int,prefix:string}> $tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) * @param Menu $menu Object Menu to return back list of menu entries - * @param int $noout Disable output (Initialise &$menu only). + * @param int<0,1> $noout Disable output (Initialise &$menu only). * @param string $forcemainmenu 'x'=Force mainmenu to mainmenu='x' * @param string $forceleftmenu 'all'=Force leftmenu to '' (= all). If value come being '', we change it to value in session and 'none' if not defined in session. - * @param array $moredata An array with more data to output - * @param int $type_user 0=Menu for backoffice, 1=Menu for front office + * @param ?array $moredata An array with more data to output + * @param int<0,1> $type_user 0=Menu for backoffice, 1=Menu for front office * @return int Nb of menu entries */ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabMenu, &$menu, $noout = 0, $forcemainmenu = '', $forceleftmenu = '', $moredata = null, $type_user = 0) @@ -1777,6 +1777,7 @@ function get_left_menu_accountancy($mainmenu, &$newmenu, $usemenuhider = 1, $lef if ($nature) { $langs->load('accountancy'); $journallabel = ''; + $journallabelwithoutspan = ''; if ($objp->label) { $journallabelwithoutspan = $langs->trans($objp->label); $journallabel = '('.$langs->trans($objp->label).')'; // Label of bank account in llx_accounting_journal diff --git a/htdocs/core/menus/standard/eldy_menu.php b/htdocs/core/menus/standard/eldy_menu.php index 6b97dc69a74..220be3817f7 100644 --- a/htdocs/core/menus/standard/eldy_menu.php +++ b/htdocs/core/menus/standard/eldy_menu.php @@ -26,6 +26,8 @@ /** * Class to manage menu Eldy + * + * @phan-suppress PhanRedefineClass */ class MenuManager { @@ -54,9 +56,18 @@ class MenuManager */ public $menu; + /** + * @var array,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,level:int,prefix:string}> + */ public $menu_array; + /** + * @var array,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,level:int,prefix:string}> + */ public $menu_array_after; + /** + * @var array,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,level:int,prefix:string}> + */ public $tabMenu; @@ -64,7 +75,7 @@ class MenuManager * Constructor * * @param DoliDB $db Database handler - * @param int $type_user Type of user + * @param int<0,1> $type_user Type of user */ public function __construct($db, $type_user) { @@ -137,9 +148,9 @@ class MenuManager * Show menu. * Menu defined in sql tables were stored into $this->tabMenu BEFORE this is called. * - * @param string $mode 'top', 'topnb', 'left', 'leftdropdown', 'jmobile' (used to get full xml ul/li menu) - * @param array $moredata An array with more data to output - * @return int 0 or nb of top menu entries if $mode = 'topnb' + * @param string $mode 'top', 'topnb', 'left', 'leftdropdown', 'jmobile' (used to get full xml ul/li menu) + * @param ?array $moredata An array with more data to output + * @return int 0 or nb of top menu entries if $mode = 'topnb' */ public function showmenu($mode, $moredata = null) { diff --git a/htdocs/core/menus/standard/empty.php b/htdocs/core/menus/standard/empty.php index 1a5fea91f01..f00a785d93c 100644 --- a/htdocs/core/menus/standard/empty.php +++ b/htdocs/core/menus/standard/empty.php @@ -23,6 +23,8 @@ /** * Class to manage empty menu + * + * @phan-suppress PhanRedefineClass */ class MenuManager { @@ -31,26 +33,47 @@ class MenuManager */ public $db; - public $type_user = 0; // Put 0 for internal users, 1 for external users - public $atarget = ""; // To store default target to use onto links + /** + * @var int<0,1> 0 for internal users, 1 for external users + */ + public $type_user = 0; + /** + * @var string Default target to use in links + */ + public $atarget = ""; + /** + * @var string + */ public $name = "empty"; /** * @var Menu */ public $menu; + /** + * @var array,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,level:int,prefix:string}> + */ public $menu_array_after; + /** + * @var array,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,level:int,prefix:string}> + */ public $tabMenu; + /** + * @var Menu + */ public $topmenu; + /** + * @var Menu + */ public $leftmenu; /** * Constructor * * @param DoliDB $db Database handler - * @param int $type_user Type of user + * @param int<0,1> $type_user Type of user */ public function __construct($db, $type_user) { @@ -76,9 +99,9 @@ class MenuManager /** * Show menu * - * @param string $mode 'top', 'left', 'jmobile' - * @param array $moredata An array with more data to output - * @return int|string 0 or nb of top menu entries if $mode = 'topnb', string inc ase of bad parameter + * @param string $mode 'top', 'left', 'jmobile' + * @param ?array $moredata An array with more data to output + * @return int<0,max>|string 0 or nb of top menu entries if $mode = 'topnb', string inc ase of bad parameter */ public function showmenu($mode, $moredata = null) { @@ -508,7 +531,7 @@ function print_start_menu_entry_empty($idsel, $classname, $showmode) * @param string $idsel Id sel * @param string $classname Class name * @param string $atarget Target - * @param array $menuval All the $menuval array + * @param array{}|array{rowid:string,fk_menu:string,langs:string,enabled:int<0,2>,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,level?:int,prefix:string} $menuval All the $menuval array * @return void */ function print_text_menu_entry_empty($text, $showmode, $url, $id, $idsel, $classname, $atarget, $menuval = array()) diff --git a/htdocs/debugbar/class/DataCollector/DolLogsCollector.php b/htdocs/debugbar/class/DataCollector/DolLogsCollector.php index e62175d14f3..e0a12753fb2 100644 --- a/htdocs/debugbar/class/DataCollector/DolLogsCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolLogsCollector.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 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 @@ -65,7 +66,7 @@ class DolLogsCollector extends MessagesCollector /** * Return widget settings * - * @return array Array + * @return array Array */ public function getWidgets() { @@ -91,7 +92,7 @@ class DolLogsCollector extends MessagesCollector /** * Return collected data * - * @return array Array of collected data + * @return array{count:int,messages:string[]} Array of collected data */ public function collect() { @@ -111,6 +112,7 @@ class DolLogsCollector extends MessagesCollector foreach ($log_levels as $level_key => $level) { if (strpos(strtolower($line), strtolower($level_key)) == 20) { $this->nboflines++; + // Use parent method to add the message $this->addMessage($line, $level, false); } } @@ -155,9 +157,9 @@ class DolLogsCollector extends MessagesCollector /** * Get latest file lines * - * @param string $file File - * @param int $lines Lines - * @return array Array + * @param string $file File + * @param int $lines Lines + * @return string[] Array */ protected function tailFile($file, $lines) { @@ -192,8 +194,8 @@ class DolLogsCollector extends MessagesCollector /** * Search a string for log entries into the log file. Used when debug bar scan log file (very slow). * - * @param string $file File - * @return array Lines of logs + * @param string $file File + * @return list Lines of log entries */ public function getLogs($file) { @@ -218,10 +220,11 @@ class DolLogsCollector extends MessagesCollector /** * Get the log levels from psr/log. * - * @return array Array of log level + * @return array Array of log level */ public function getLevels() { + // @phan-suppress-next-line PhanRedefinedClassReference // Psr/LogLevel also provided by Sabre setup $class = new ReflectionClass(new LogLevel()); $levels = $class->getConstants(); $levels['ERR'] = 'error'; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index f5b45400876..92a0ae05757 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -485,6 +485,7 @@ if (isModEnabled('debugbar') && !GETPOST('dol_use_jmobile') && empty($_SESSION[' } $conf->global->MAIN_HTML_HEADER .= $renderer->renderHead(); + '@phan-var-force array{time:DebugBar\DataCollector\TimeDataCollector} $debugbar'; $debugbar['time']->startMeasure('pageaftermaster', 'Page generation (after environment init)'); } @@ -791,6 +792,8 @@ if (!defined('NOLOGIN')) { // At the end of this phase, the variable $login is defined. $resultFetchUser = ''; $test = true; + $dol_authmode = null; + if (!isset($_SESSION["dol_login"])) { // It is not already authenticated and it requests the login / password include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; @@ -939,10 +942,8 @@ if (!defined('NOLOGIN')) { $login = ''; } - $dol_authmode = ''; - if ($login) { - $dol_authmode = $conf->authmode; // This properties is defined only when logged, to say what mode was successfully used + $dol_authmode = $conf->authmode; // This property is defined only when logged, to say what mode was successfully used $dol_tz = empty($_POST["tz"]) ? (empty($_SESSION["tz"]) ? '' : $_SESSION["tz"]) : $_POST["tz"]; $dol_tz_string = empty($_POST["tz_string"]) ? (empty($_SESSION["tz_string"]) ? '' : $_SESSION["tz_string"]) : $_POST["tz_string"]; $dol_tz_string = preg_replace('/\s*\(.+\)$/', '', $dol_tz_string); @@ -1019,7 +1020,7 @@ if (!defined('NOLOGIN')) { exit; } - $resultFetchUser = $user->fetch('', $login, '', 1, ($entitytotest > 0 ? $entitytotest : -1)); // value for $login was retrieved previously when checking password. + $resultFetchUser = $user->fetch(0, $login, '', 1, ($entitytotest > 0 ? $entitytotest : -1)); // value for $login was retrieved previously when checking password. if ($resultFetchUser <= 0 || $user->isNotIntoValidityDateRange()) { dol_syslog('User not found or not valid, connection refused'); session_destroy(); @@ -1088,7 +1089,7 @@ if (!defined('NOLOGIN')) { $entity = isset($_SESSION["dol_entity"]) ? $_SESSION["dol_entity"] : 0; dol_syslog("- This is an already logged session. _SESSION['dol_login']=".$login." _SESSION['dol_entity']=".$entity, LOG_DEBUG); - $resultFetchUser = $user->fetch('', $login, '', 1, ($entity > 0 ? $entity : -1)); + $resultFetchUser = $user->fetch(0, $login, '', 1, ($entity > 0 ? $entity : -1)); //var_dump(dol_print_date($user->flagdelsessionsbefore, 'dayhour', 'gmt')." ".dol_print_date($_SESSION["dol_logindate"], 'dayhour', 'gmt')); @@ -1142,7 +1143,7 @@ if (!defined('NOLOGIN')) { // Hooks on failed login $action = ''; $hookmanager->initHooks(array('login')); - $parameters = array('dol_authmode' => (isset($dol_authmode) ? $dol_authmode : ''), 'dol_loginmesg' => $_SESSION["dol_loginmesg"]); + $parameters = array('dol_authmode' => (string) $dol_authmode, 'dol_loginmesg' => $_SESSION["dol_loginmesg"]); $reshook = $hookmanager->executeHooks('afterLoginFailed', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { $error++; @@ -1538,6 +1539,7 @@ if (!defined('NOREQUIREMENU')) { if (GETPOST('menu', 'alpha')) { $file_menu = GETPOST('menu', 'alpha'); // example: menu=eldy_menu.php } + if (!class_exists('MenuManager')) { $menufound = 0; $dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']); @@ -1553,7 +1555,9 @@ if (!defined('NOREQUIREMENU')) { include_once DOL_DOCUMENT_ROOT."/core/menus/standard/".$file_menu; } } + // @phan-suppress-next-line PhanRedefinedClassReference $menumanager = new MenuManager($db, empty($user->socid) ? 0 : 1); + // @phan-suppress-next-line PhanRedefinedClassReference $menumanager->loadMenu(); } @@ -1580,14 +1584,15 @@ if (!function_exists("llxHeader")) { * @param string $target Target to use on links * @param int<0,1> $disablejs More content into html header * @param int<0,1> $disablehead More content into html header - * @param array|string $arrayofjs Array of complementary js files - * @param array|string $arrayofcss Array of complementary css files + * @param string[]|string $arrayofjs Array of complementary js files + * @param string[]|string $arrayofcss Array of complementary css files * @param string $morequerystring Query string to add to the link "print" to get same parameters (use only if autodetect fails) * @param string $morecssonbody More CSS on body tag. For example 'classforhorizontalscrolloftabs'. * @param string $replacemainareaby Replace call to main_area() by a print of this string * @param int $disablenofollow Disable the "nofollow" on meta robot header * @param int $disablenoindex Disable the "noindex" on meta robot header * @return void + * @phan-suppress PhanRedefineFunction (Also defined in htdocs/asterisk/wrapper) */ function llxHeader($head = '', $title = '', $help_url = '', $target = '', $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '', $morequerystring = '', $morecssonbody = '', $replacemainareaby = '', $disablenofollow = 0, $disablenoindex = 0) { @@ -1639,7 +1644,7 @@ if (!function_exists("llxHeader")) { } if (empty($conf->dol_hide_leftmenu) && !GETPOST('dol_openinpopup', 'aZ09')) { - left_menu(array(), $help_url, '', array(), 1, $title, 1); // $menumanager is retrieved with a global $menumanager inside this function + left_menu('', $help_url, '', array(), 1, $title, 1); // $menumanager is retrieved with a global $menumanager inside this function } // main area @@ -2262,7 +2267,9 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead // Show menu entries print '
'."\n"; + // @phan-suppress-next-line PhanRedefinedClassReference $menumanager->atarget = $target; + // @phan-suppress-next-line PhanRedefinedClassReference $menumanager->showmenu('top', array('searchform' => $searchform)); // This contains a \n print "
\n"; @@ -2556,7 +2563,8 @@ function top_menu_user($hideloginname = 0, $urllogout = '') if (!empty($user->admin)) { $dropdownBody .= '
'.$langs->trans("Administrator").': '.yn($user->admin); } - if (!empty($user->socid)) { // Add thirdparty for external users + $company = ''; + if (!empty($user->socid)) { // Add third party for external users $thirdpartystatic = new Societe($db); $thirdpartystatic->fetch($user->socid); $companylink = ' '.$thirdpartystatic->getNomUrl(2); // picto only of company @@ -2576,6 +2584,7 @@ function top_menu_user($hideloginname = 0, $urllogout = '') $dropdownBody .= '
'.$langs->trans("ConnectedSince").': '.dol_print_date($user->datelastlogin, "dayhour", 'tzuser'); $dropdownBody .= '
'.$langs->trans("PreviousConnexion").': '.dol_print_date($user->datepreviouslogin, "dayhour", 'tzuser'); $dropdownBody .= '
'.$langs->trans("CurrentTheme").': '.$conf->theme; + // @phan-suppress-next-line PhanRedefinedClassReference $dropdownBody .= '
'.$langs->trans("CurrentMenuManager").': '.(isset($menumanager) ? $menumanager->name : 'unknown'); $langFlag = picto_from_langcode($langs->getDefaultLang()); $dropdownBody .= '
'.$langs->trans("CurrentUserLanguage").': '.($langFlag ? $langFlag.' ' : '').$langs->getDefaultLang(); @@ -2662,6 +2671,7 @@ function top_menu_user($hideloginname = 0, $urllogout = '') '.$userDropDownImage.'

'.$profilName.'
'; + $title = ''; if ($user->datelastlogin) { $title = $langs->trans("ConnectedSince").' : '.dol_print_date($user->datelastlogin, "dayhour", 'tzuser'); if ($user->datepreviouslogin) { @@ -3141,6 +3151,7 @@ function top_menu_search() $defaultAction = ''; $buttonList = '