Skip to content

Commit

Permalink
Merge pull request #32572 from mdeweerd/fix_phan_202408.1
Browse files Browse the repository at this point in the history
Qual: Improve phpdoc for phan notices
  • Loading branch information
eldy authored Jan 15, 2025
2 parents 1198ae5 + 0f0073b commit 9ee4a03
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
25 changes: 13 additions & 12 deletions htdocs/core/lib/functions.lib.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/* Copyright (C) 2000-2007 Rodolphe Quiedeville <[email protected]>
* Copyright (C) 2003 Jean-Louis Bergamo <[email protected]>
* Copyright (C) 2004-2024 Laurent Destailleur <[email protected]>
Expand All @@ -21,7 +22,7 @@
* Copyright (C) 2022 Ferran Marcet <[email protected]>
* Copyright (C) 2022 Charlene Benke <[email protected]>
* Copyright (C) 2023 Joachim Kueter <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
* Copyright (C) 2024-2025 MDW <[email protected]>
* Copyright (C) 2024 Lenin Rivas <[email protected]>
* Copyright (C) 2024 Josep Lluís Amador Teruel <[email protected]>
* Copyright (C) 2024 Benoît PASCAL <[email protected]>
Expand Down Expand Up @@ -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<string,string> $substitutionarray Array with key->val to substitute. Example: array('__MYKEY__' => 'MyVal', ...)
* @param array<string,null|string|float|int> $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()
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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
}
}

Expand All @@ -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];
Expand Down Expand Up @@ -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
}
}
}
Expand Down Expand Up @@ -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 '';
}
}
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/menus/standard/eldy.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string,string> $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)
{
Expand Down
6 changes: 3 additions & 3 deletions htdocs/core/menus/standard/eldy_menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string,mixed> $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<string,string> $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)
{
Expand Down

0 comments on commit 9ee4a03

Please sign in to comment.