diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index df7b61f06c092..cb73d130f84aa 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1,4 +1,5 @@ * Copyright (C) 2003 Jean-Louis Bergamo * Copyright (C) 2004-2024 Laurent Destailleur @@ -21,7 +22,7 @@ * Copyright (C) 2022 Ferran Marcet * Copyright (C) 2022 Charlene Benke * Copyright (C) 2023 Joachim Kueter - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Lenin Rivas * Copyright (C) 2024 Josep Lluís Amador Teruel * Copyright (C) 2024 Benoît PASCAL @@ -9686,9 +9687,9 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, * $mesg = make_substitutions($mesg, $substitutionarray, $langs); * * @param string $text Source string in which we must do substitution - * @param array $substitutionarray Array with key->val to substitute. Example: array('__MYKEY__' => 'MyVal', ...) + * @param array $substitutionarray Array with key->val to substitute. Example: array('__MYKEY__' => 'MyVal', ...) * @param ?Translate $outputlangs Output language - * @param int $converttextinhtmlifnecessary 0=Convert only value into HTML if text is already in HTML + * @param int<0,1> $converttextinhtmlifnecessary 0=Convert only value into HTML if text is already in HTML * 1=Will also convert initial $text into HTML if we try to insert one value that is HTML * @return string Output string after substitutions * @see complete_substitutions_array(), getCommonSubstitutionArray() @@ -9736,7 +9737,7 @@ function make_substitutions($text, $substitutionarray, $outputlangs = null, $con $msgishtml = 1; } } else { - $value = dol_nl2br("$value"); + $value = dol_nl2br((string) $value); } $text = preg_replace('/__\('.preg_quote($reg[1], '/').'\)__/', $value, $text); @@ -9767,7 +9768,7 @@ function make_substitutions($text, $substitutionarray, $outputlangs = null, $con $msgishtml = 1; } } else { - $value = dol_nl2br("$value"); + $value = dol_nl2br((string) $value); } $text = preg_replace('/__\['.preg_quote($keyfound, '/').'\]__/', $value, $text); @@ -9785,7 +9786,7 @@ function make_substitutions($text, $substitutionarray, $outputlangs = null, $con } if (empty($converttextinhtmlifnecessary)) { - $text = str_replace("$key", "$value", $text); // We must keep the " to work when value is 123.5 for example + $text = str_replace((string) $key, (string) $value, $text); // Cast to string is needed when value is 123.5 for example } else { if (! $msgishtml) { $valueishtml = dol_textishtml($value, 1); @@ -9795,9 +9796,9 @@ function make_substitutions($text, $substitutionarray, $outputlangs = null, $con $msgishtml = 1; } } else { - $value = dol_nl2br("$value"); + $value = dol_nl2br((string) $value); } - $text = str_replace("$key", "$value", $text); // We must keep the " to work when value is 123.5 for example + $text = str_replace((string) $key, (string) $value, $text); // Cast to string is needed 123.5 for example } } @@ -9820,7 +9821,7 @@ function make_substitutions($text, $substitutionarray, $outputlangs = null, $con if (isset($lazy_load_arr[1]) && !empty($lazy_load_arr[1])) { $key_to_substitute = $lazy_load_arr[1]; if (preg_match('/' . preg_quote($key_to_substitute, '/') . '/', $text)) { - $param_arr = explode(':', $value); + $param_arr = explode(':', (string) $value); // path:class:method:id if (count($param_arr) == 4) { $path = $param_arr[0]; @@ -9855,7 +9856,7 @@ function make_substitutions($text, $substitutionarray, $outputlangs = null, $con $valuetouseforsubstitution = $tmpobj->$method($id, $key_to_substitute, true); } - $text = str_replace("$key_to_substitute", "$valuetouseforsubstitution", $text); // We must keep the " to work when value is 123.5 for example + $text = str_replace((string) $key_to_substitute, (string) $valuetouseforsubstitution, $text); // Cast to string in case value is 123.5 for example } } } @@ -10665,9 +10666,9 @@ function dol_eval($s, $returnvalue = 1, $hideerrors = 1, $onlysimplestring = '1' // Check if there is dynamic call (first we use black list patterns) if (preg_match('/\$[\w]*\s*\(/', $s)) { if ($returnvalue) { - return 'Bad string syntax to evaluate (mode '.$onlysimplestring.', found a call using of "$abc(" or "$abc (" instead of using the direct name of the function): '.$s; + return 'Bad string syntax to evaluate (mode '.$onlysimplestring.', found a call using "$abc(" or "$abc (" instead of using the direct name of the function): '.$s; } else { - dol_syslog('Bad string syntax to evaluate (mode '.$onlysimplestring.', found a call using of "$abc(" or "$abc (" instead of using the direct name of the function): '.$s, LOG_WARNING); + dol_syslog('Bad string syntax to evaluate (mode '.$onlysimplestring.', found a call using "$abc(" or "$abc (" instead of using the direct name of the function): '.$s, LOG_WARNING); return ''; } } diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index b8499c4730506..76040bb5c0187 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -731,9 +731,9 @@ function print_end_menu_array() * @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 ?array{searchform?:string,bookmarks?:string} $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 + * @return int<0,max> 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) { diff --git a/htdocs/core/menus/standard/eldy_menu.php b/htdocs/core/menus/standard/eldy_menu.php index a7e08363ec65d..b75471e6d8c6e 100644 --- a/htdocs/core/menus/standard/eldy_menu.php +++ b/htdocs/core/menus/standard/eldy_menu.php @@ -148,9 +148,9 @@ public function loadMenu($forcemainmenu = '', $forceleftmenu = '') * 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 'top'|'topnb'|'left'|'leftdropdown'|'jmobile' $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,max> 0 or nb of top menu entries if $mode = 'topnb' */ public function showmenu($mode, $moredata = null) {