Skip to content

Commit

Permalink
Fix some cases of PhanTypeSuspiciousStringExpression (Dolibarr#28751)
Browse files Browse the repository at this point in the history
* Fix PhanTypeSuspiciousStringExpression

* Fix PhanTypeSuspiciousStringExpression

* Fix PhanTypeSuspiciousStringExpression

* Fix PhanTypeSuspiciousStringExpression

* Fix PhanTypeSuspiciousStringExpression

* Fix PhanTypeSuspiciousStringExpression

* Fix PhanTypeSuspiciousStringExpression

* Fix PhanTypeSuspiciousStringExpression

* Fix PhanTypeSuspiciousStringExpression

* Fix PhanTypeSuspiciousStringExpression

* Fix PhanTypeSuspiciousStringExpression

* Fix PhanTypeSuspiciousStringExpression

* Fix PhanTypeSuspiciousStringExpression

---------

Co-authored-by: Laurent Destailleur <[email protected]>
  • Loading branch information
mdeweerd and eldy authored Mar 11, 2024
1 parent 0f2121e commit b72cf19
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 34 deletions.
3 changes: 2 additions & 1 deletion htdocs/accountancy/admin/productaccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Copyright (C) 2014 Juanjo Menent <[email protected]>
* Copyright (C) 2015 Ari Elbaz (elarifr) <[email protected]>
* Copyright (C) 2021 Gauthier VERDOL <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
*
* 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
Expand Down Expand Up @@ -206,7 +207,7 @@
$sql_exists .= " WHERE fk_product = " . ((int) $productid) . " AND entity = " . ((int) $conf->entity);
$resql_exists = $db->query($sql_exists);
if (!$resql_exists) {
$msg .= '<div><span class="error">'.$langs->trans("ErrorDB").' : '.$langs->trans("Product").' '.$productid.' '.$langs->trans("NotVentilatedinAccount").' : id='.$accounting_account_id.'<br> <pre>'.$resql_exists.'</pre></span></div>';
$msg .= '<div><span class="error">'.$langs->trans("ErrorDB").' : '.$langs->trans("Product").' '.$productid.' '.$langs->trans("NotVentilatedinAccount").' : id='.$accounting_account_id.'<br> <pre>'.json_encode($resql_exists).'</pre></span></div>';
$ko++;
} else {
$nb_exists = $db->num_rows($resql_exists);
Expand Down
8 changes: 7 additions & 1 deletion htdocs/admin/system/xdebug.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2009-2014 Laurent Destailleur <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
*
* 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
Expand Down Expand Up @@ -90,7 +91,12 @@
//$client = socket_accept($sock);
$client = socket_connect($socket, $address, $port);
if ($client) {
print "Connection established: ".$client." - address=".$address." port=".$port."<br>\n";
if (is_bool($client)) {
$client_str = 'true';
} else {
$client_str = (string) $client;
}
print "Connection established: ".$client_str." - address=".$address." port=".$port."<br>\n";
print "There is a Remote debug server at this address.<br>\n";
print "<br>\n";
print "To be sure this debugger accepts input from your PHP server and xdebug, be sure to have\n";
Expand Down
5 changes: 3 additions & 2 deletions htdocs/blockedlog/class/blockedlog.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* Copyright (C) 2017 ATM Consulting <[email protected]>
* Copyright (C) 2017-2020 Laurent Destailleur <[email protected]>
* Copyright (C) 2022 charlene benke <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
*
* 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
Expand Down Expand Up @@ -1014,7 +1015,7 @@ public function checkSignature($previoushash = '', $returnarray = 0)
unset($keyforsignature);
return array('checkresult' => $res, 'calculatedsignature' => $signature, 'previoushash' => $previoushash);
} else { // Consume much memory ($keyforsignature is a large var)
return array('checkresult' => $res, 'calculatedsignature' => $signature, 'previoushash' => $previoushash, 'keyforsignature'=>$keyforsignature);
return array('checkresult' => $res, 'calculatedsignature' => $signature, 'previoushash' => $previoushash, 'keyforsignature' => $keyforsignature);
}
} else {
unset($keyforsignature);
Expand Down Expand Up @@ -1227,7 +1228,7 @@ public function alreadyUsed($ignoresystem = 0)
dol_print_error($this->db);
}

dol_syslog("Module Blockedlog alreadyUsed with ignoresystem=".$ignoresystem." is ".$result);
dol_syslog("Module Blockedlog alreadyUsed with ignoresystem=".$ignoresystem." is ".json_encode($result));

return $result;
}
Expand Down
3 changes: 2 additions & 1 deletion htdocs/comm/action/class/actioncomm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Copyright (C) 2015 Marcos García <[email protected]>
* Copyright (C) 2018 Nicolas ZABOURI <[email protected]>
* Copyright (C) 2018-2024 Frédéric France <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
*
* 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
Expand Down Expand Up @@ -2728,7 +2729,7 @@ public function sendEmailsReminder()
return 0;
} else {
$this->db->commit(); // We commit also on error, to have the error message recorded.
$this->error = 'Nb of emails sent : '.$nbMailSend.', '.(!empty($errorsMsg)) ? implode(', ', $errorsMsg) : $error;
$this->error = 'Nb of emails sent : '.$nbMailSend.', '.(!empty($errorsMsg) ? implode(', ', $errorsMsg) : $error);

dol_syslog(__METHOD__." end - ".$this->error, LOG_INFO);

Expand Down
2 changes: 1 addition & 1 deletion htdocs/comm/mailing/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@
setEventMessages($langs->trans("MailSuccessfulySent", $mailfile->getValidAddress($object->email_from, 2), $mailfile->getValidAddress($object->sendto, 2)), null, 'mesgs');
$action = '';
} else {
setEventMessages($langs->trans("ResultKo").'<br>'.$mailfile->error.' '.$result, null, 'errors');
setEventMessages($langs->trans("ResultKo").'<br>'.$mailfile->error.' '.json_encode($result), null, 'errors');
$action = 'test';
}
}
Expand Down
2 changes: 1 addition & 1 deletion htdocs/compta/facture/class/facture.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -5915,7 +5915,7 @@ public function sendEmailsRemindersOnInvoiceDueDate($nbdays = 0, $paymentmode =

return 0;
} else {
$this->error = 'Nb of emails sent : '.$nbMailSend.', '.(!empty($errorsMsg)) ? implode(', ', $errorsMsg) : $error;
$this->error = 'Nb of emails sent : '.$nbMailSend.', '.(!empty($errorsMsg) ? implode(', ', $errorsMsg) : $error);

dol_syslog(__METHOD__." end - ".$this->error, LOG_INFO);

Expand Down
27 changes: 16 additions & 11 deletions htdocs/contrat/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Copyright (C) 2005-2012 Regis Houssin <[email protected]>
* Copyright (C) 2015 Jean-François Ferry <[email protected]>
* Copyright (C) 2019 Nicolas ZABOURI <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
*
* 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
Expand Down Expand Up @@ -154,9 +155,9 @@
while ($i < $num) {
$obj = $db->fetch_object($resql);
if ($obj) {
$nb[$obj->status.true] = $obj->nb;
$nb[$obj->status.((string) true)] = $obj->nb;
if ($obj->status != 5) {
$vals[$obj->status.true] = $obj->nb;
$vals[$obj->status.((string) true)] = $obj->nb;
$totalinprocess += $obj->nb;
}
$total += $obj->nb;
Expand All @@ -175,26 +176,28 @@
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder nohover centpercent">';
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("Services").'</th></tr>'."\n";
$listofstatus = array(0, 4, 4, 5); $bool = false;
$listofstatus = array(0, 4, 4, 5);
$bool = false;
foreach ($listofstatus as $status) {
$dataseries[] = array($staticcontratligne->LibStatut($status, 1, ($bool ? 1 : 0)), (isset($nb[$status.$bool]) ? (int) $nb[$status.$bool] : 0));
$bool_str = (string) $bool;
$dataseries[] = array($staticcontratligne->LibStatut($status, 1, ($bool ? 1 : 0)), (isset($nb[$status.$bool_str]) ? (int) $nb[$status.$bool_str] : 0));
if ($status == ContratLigne::STATUS_INITIAL) {
$colorseries[$status.$bool] = '-'.$badgeStatus0;
$colorseries[$status.$bool_str] = '-'.$badgeStatus0;
}
if ($status == ContratLigne::STATUS_OPEN && !$bool) {
$colorseries[$status.$bool] = $badgeStatus4;
$colorseries[$status.$bool_str] = $badgeStatus4;
}
if ($status == ContratLigne::STATUS_OPEN && $bool) {
$colorseries[$status.$bool] = $badgeStatus1;
$colorseries[$status.$bool_str] = $badgeStatus1;
}
if ($status == ContratLigne::STATUS_CLOSED) {
$colorseries[$status.$bool] = $badgeStatus6;
$colorseries[$status.$bool_str] = $badgeStatus6;
}

if (empty($conf->use_javascript_ajax)) {
print '<tr class="oddeven">';
print '<td>'.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).'</td>';
print '<td class="right"><a href="services_list.php?search_status='.((int) $status).($bool ? '&filter=expired' : '').'">'.($nb[$status.$bool] ? $nb[$status.$bool] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).'</a></td>';
print '<td class="right"><a href="services_list.php?search_status='.((int) $status).($bool ? '&filter=expired' : '').'">'.($nb[$status.$bool_str] ? $nb[$status.$bool_str] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).'</a></td>';
print "</tr>\n";
}
if ($status == 4 && !$bool) {
Expand All @@ -219,12 +222,14 @@

print '</td></tr>';
}
$listofstatus = array(0, 4, 4, 5); $bool = false;
$listofstatus = array(0, 4, 4, 5);
$bool = false;
foreach ($listofstatus as $status) {
$bool_str = (string) $bool;
if (empty($conf->use_javascript_ajax)) {
print '<tr class="oddeven">';
print '<td>'.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).'</td>';
print '<td class="right"><a href="services_list.php?search_status='.((int) $status).($bool ? '&filter=expired' : '').'">'.($nb[$status.$bool] ? $nb[$status.$bool] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).'</a></td>';
print '<td class="right"><a href="services_list.php?search_status='.((int) $status).($bool ? '&filter=expired' : '').'">'.($nb[$status.$bool_str] ? $nb[$status.$bool_str] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).'</a></td>';
if ($status == 4 && !$bool) {
$bool = true;
} else {
Expand Down
3 changes: 2 additions & 1 deletion htdocs/core/boxes/modules_boxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Copyright (C) 2005-2012 Regis Houssin <[email protected]>
* Copyright (C) 2014 Raphaël Doursenaud <[email protected]>
* Copyright (C) 2015 Frederic France <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
*
* 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
Expand Down Expand Up @@ -194,7 +195,7 @@ public function fetch($rowid)
* Standard method to show a box (usage by boxes not mandatory, a box can still use its own showBox function)
*
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @param array<array<array{tr?:string,text?:string,text2?:string,textnoformat?:string,tooltip?:string,logo?:string,url?:string,maxlength?:string}>> $contents Array with properties of box lines
* @param int $nooutput No print, only return string
* @return string
*/
Expand Down
12 changes: 6 additions & 6 deletions htdocs/core/class/menubase.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* Copyright (C) 2007-2009 Laurent Destailleur <[email protected]>
* Copyright (C) 2009-2012 Regis Houssin <[email protected]>
* Copyright (C) 2018-2024 Frédéric France <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
*
* 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
Expand Down Expand Up @@ -511,8 +512,8 @@ public function initAsSpecimen()
* @param string $myleftmenu Value for leftmenu to filter menu to load (always '')
* @param int $type_user 0=Menu for backoffice, 1=Menu for front office
* @param string $menu_handler Filter on name of menu_handler used (auguria, eldy...)
* @param array $tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty)
* @return array Return array with menu entries for top menu
* @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,prefix:string}> $tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty)
* @return 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,prefix:string}> Return array with menu entries for top menu
*/
public function menuTopCharger($mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu)
{
Expand Down Expand Up @@ -541,7 +542,7 @@ public function menuTopCharger($mymainmenu, $myleftmenu, $type_user, $menu_handl
* @param string $myleftmenu Value for leftmenu to filter menu to load (always '')
* @param int $type_user 0=Menu for backoffice, 1=Menu for front office
* @param string $menu_handler Filter on name of menu_handler used (auguria, eldy...)
* @param array $tabMenu Array with menu entries already loaded
* @param array<array{rowid:string,fk_menu:string,module: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,prefix:string}> $tabMenu Array with menu entries already loaded
* @return Menu Menu array for particular mainmenu value or full tabArray
*/
public function menuLeftCharger($newmenu, $mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu)
Expand Down Expand Up @@ -573,7 +574,6 @@ public function menuLeftCharger($newmenu, $mymainmenu, $myleftmenu, $type_user,
if ($val['fk_menu'] == -1 && $val['fk_mainmenu'] == $mainmenu) { // We found a menu entry not linked to parent with good mainmenu
//print 'Try to add menu (current is mainmenu='.$mainmenu.' leftmenu='.$leftmenu.') for '.join(',',$val).' fk_mainmenu='.$val['fk_mainmenu'].' fk_leftmenu='.$val['fk_leftmenu'].'<br>';
//var_dump($this->newmenu->liste);exit;

if (empty($val['fk_leftmenu'])) {
$this->newmenu->add($val['url'], $val['titre'], 0, $val['perms'], $val['target'], $val['mainmenu'], $val['leftmenu'], $val['position'], '', '', '', $val['prefix']);
//var_dump($this->newmenu->liste);
Expand Down Expand Up @@ -624,7 +624,7 @@ public function menuLeftCharger($newmenu, $mymainmenu, $myleftmenu, $type_user,
* @param string $myleftmenu Value for left that defined leftmenu
* @param int $type_user Looks for menu entry for 0=Internal users, 1=External users
* @param string $menu_handler Name of menu_handler used ('auguria', 'eldy'...)
* @param array $tabMenu Array to store new entries found (in most cases, it's empty, but may be already filled)
* @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,prefix:string}> $tabMenu Array to store new entries found (in most cases, it's empty, but may be already filled)
* @return int >0 if OK, <0 if KO
*/
public function menuLoad($mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu)
Expand Down Expand Up @@ -757,7 +757,7 @@ public function menuLoad($mymainmenu, $myleftmenu, $type_user, $menu_handler, &$
/**
* Complete this->newmenu with menu entry found in $tab
*
* @param array $tab Tab array with all menu entries
* @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,prefix:string}> $tab Tab array with all menu entries
* @param int $pere Id of parent
* @param int $level Level
* @return void
Expand Down
10 changes: 6 additions & 4 deletions htdocs/core/menus/standard/auguria.lib.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2010-2022 Laurent Destailleur <[email protected]>
* Copyright (C) 2010-2012 Regis Houssin <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
*
* 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
Expand Down Expand Up @@ -31,7 +32,7 @@
* @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 $tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty)
* @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,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'
Expand All @@ -51,6 +52,7 @@ function print_auguria_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout
// Show personalized menus
$menuArbo = new Menubase($db, 'auguria');
$newTabMenu = $menuArbo->menuTopCharger('', '', $type_user, 'auguria', $tabMenu);
'@phan-var-force 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,prefix:string}> $newTabMenu';

$substitarray = getCommonSubstitutionArray($langs, 0, null, null);

Expand Down Expand Up @@ -307,9 +309,9 @@ function print_end_menu_array_auguria()
* Fill &$menu (example with $forcemainmenu='home' $forceleftmenu='all', return left menu tree of Home)
*
* @param DoliDB $db Database handler
* @param array $menu_array_before Table of menu entries to show before entries of menu handler (menu->liste filled with menu->add)
* @param array $menu_array_after Table of menu entries to show after entries of menu handler (menu->liste filled with menu->add)
* @param array $tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty)
* @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,prefix:string}> $menu_array_before Table of menu entries to show before entries of menu handler (menu->liste filled with menu->add)
* @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,prefix:string}> $menu_array_after Table of menu entries to show after entries of menu handler (menu->liste filled with menu->add)
* @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,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 string $forcemainmenu 'x'=Force mainmenu to mainmenu='x'
Expand Down
Loading

0 comments on commit b72cf19

Please sign in to comment.