Skip to content

Commit

Permalink
fix phpstan (Dolibarr#31075)
Browse files Browse the repository at this point in the history
* fix phpstan

* fix phpstan

* fix phpstan

* fix phpstan

* fix phpstan

* fix phpstan

* fix phpstan

* fix phpstan

* fix phpstan

* fix phpstan

* fix phpstan

* fix phpstan

* fix phpstan

* fix phpstan

* fix phpstan

* fix phpstan

* fix phpstan

---------

Co-authored-by: Laurent Destailleur <[email protected]>
  • Loading branch information
frederic34 and eldy authored Sep 22, 2024
1 parent ffeb471 commit 000173c
Show file tree
Hide file tree
Showing 83 changed files with 190 additions and 208 deletions.
3 changes: 2 additions & 1 deletion build/generate_filelist_xml.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env php
<?php
/* Copyright (C) 2015-2017 Laurent Destailleur <[email protected]>
* Copyright (C) 2024 Frédéric France <[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 @@ -199,7 +200,7 @@
fputs($fp, '</dolibarr_htdocs_dir>'."\n");

asort($checksumconcat); // Sort list of checksum
//var_dump($checksumconcat);

fputs($fp, '<dolibarr_htdocs_dir_checksum>'."\n");
fputs($fp, md5(join(',', $checksumconcat))."\n");
fputs($fp, '</dolibarr_htdocs_dir_checksum>'."\n");
Expand Down
2 changes: 1 addition & 1 deletion dev/initdata/purge-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<?php
/* Copyright (C) 2016 Laurent Destailleur <[email protected]>
* Copyright (C) 2016 Juanjo Menent <[email protected]>
* Copyright (C) 2024 Frédéric France <[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
* the Free Software Foundation; either version 3 of the License, or
Expand Down Expand Up @@ -225,7 +226,6 @@
$user=new User($db);
}

//var_dump($user->db->database_name);
$ret=$user->fetch('', 'admin');
if (! $ret > 0) {
print 'An admin user with login "admin" must exists to use this script.'."\n";
Expand Down
13 changes: 0 additions & 13 deletions htdocs/accountancy/journal/bankjournal.php
Original file line number Diff line number Diff line change
Expand Up @@ -623,13 +623,6 @@
dol_print_error($db);
}


//var_dump($tabpay);
//var_dump($tabcompany);
//var_dump($tabbq);
//var_dump($tabtp);
//var_dump($tabtype);

// Write bookkeeping
if (!$error && $action == 'writebookkeeping' && $user->hasRight('accounting', 'bind', 'write')) {
$now = dol_now();
Expand Down Expand Up @@ -663,9 +656,6 @@
$db->begin();

// Introduce a protection. Total of tabtp must be total of tabbq
//var_dump($tabpay);
//var_dump($tabtp);
//var_dump($tabbq);exit;

// Bank
if (!$errorforline && is_array($tabbq[$key])) {
Expand Down Expand Up @@ -1388,9 +1378,6 @@ function writebookkeeping() {
$accounttoshowsubledger = length_accounta($k);
if ($accounttoshow != $accounttoshowsubledger) {
if (empty($accounttoshowsubledger) || $accounttoshowsubledger == 'NotDefined') {
//var_dump($tabpay[$key]);
//var_dump($tabtype[$key]);
//var_dump($tabbq[$key]);
//print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
if (!empty($tabcompany[$key]['code_compta'])) {
if (in_array($tabtype[$key], array('payment_various', 'payment_salary'))) {
Expand Down
1 change: 0 additions & 1 deletion htdocs/adherents/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@
}
$arrayfields = dol_sort_array($arrayfields, 'position');
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
//var_dump($arrayfields);exit;

// Security check
$result = restrictedArea($user, 'adherent');
Expand Down
2 changes: 1 addition & 1 deletion htdocs/adherents/note.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <[email protected]>
* Copyright (C) 2004-2014 Laurent Destailleur <[email protected]>
* Copyright (C) 2015 Frederic France <[email protected]>
* Copyright (C) 2015-2024 Frédéric France <[email protected]>
* Copyright (C) 2024 Alexandre Spangaro <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
*
Expand Down
4 changes: 2 additions & 2 deletions htdocs/admin/company_socialnetworks.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright (C) 2011-2017 Philippe Grand <[email protected]>
* Copyright (C) 2015 Alexandre Spangaro <[email protected]>
* Copyright (C) 2017 Rui Strecht <[email protected]>
* Copyright (C) 2020 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2020-2024 Frédéric France <frederic.france@free.fr>
*
* 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 @@ -119,7 +119,7 @@
print "</tr>\n";

$listofnetworks = dol_sort_array($listofnetworks, 'label');
//var_dump($listofnetworks);

foreach ($listofnetworks as $key => $value) {
if (!empty($value['active'])) {
print '<tr class="oddeven">';
Expand Down
1 change: 0 additions & 1 deletion htdocs/admin/dict.php
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,6 @@
} elseif ($search_active == 'no') {
$sql .= " AND ".$db->sanitize($tableprefix)."active = 0";
}
//var_dump($sql);

// Count total nb of records
$nbtotalofrecords = '';
Expand Down
2 changes: 1 addition & 1 deletion htdocs/admin/oauth.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2015-2018 Frederic France <frederic.france@netlogic.fr>
/* Copyright (C) 2015-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2016 Raphaël Doursenaud <[email protected]>
* Copyright (C) 2022 Laurent Destailleur <[email protected]>
*
Expand Down
2 changes: 1 addition & 1 deletion htdocs/admin/oauthlogintokens.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2013-2016 Laurent Destailleur <[email protected]>
* Copyright (C) 2014-2018 Frederic France <frederic.france@netlogic.fr>
* Copyright (C) 2014-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2020 Nicolas ZABOURI <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
*
Expand Down
2 changes: 1 addition & 1 deletion htdocs/admin/system/filecheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* Copyright (C) 2005-2020 Laurent Destailleur <[email protected]>
* Copyright (C) 2007 Rodolphe Quiedeville <[email protected]>
* Copyright (C) 2007-2012 Regis Houssin <[email protected]>
* Copyright (C) 2015-2019 Frederic France <frederic.france@netlogic.fr>
* Copyright (C) 2015-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2017 Nicolas ZABOURI <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
*
Expand Down
6 changes: 3 additions & 3 deletions htdocs/comm/action/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,7 @@
}
echo ' </tr>'."\n";

$todayarray = dol_getdate($now, 'fast');
$todayarray = dol_getdate($now, true);
$todaytms = dol_mktime(0, 0, 0, $todayarray['mon'], $todayarray['mday'], $todayarray['year']);

// In loops, tmpday contains day nb in current month (can be zero or negative for days of previous month)
Expand Down Expand Up @@ -1679,7 +1679,7 @@
}

$today = 0;
$todayarray = dol_getdate($now, 'fast');
$todayarray = dol_getdate($now, true);
if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) {
$today = 1;
}
Expand Down Expand Up @@ -1709,7 +1709,7 @@
// Code to show just one day
$style = 'cal_current_month cal_current_month_oneday';
$today = 0;
$todayarray = dol_getdate($now, 'fast');
$todayarray = dol_getdate($now, true);
if ($todayarray['mday'] == $day && $todayarray['mon'] == $month && $todayarray['year'] == $year) {
$today = 1;
}
Expand Down
2 changes: 1 addition & 1 deletion htdocs/comm/action/pertype.php
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@
}

// Loop on each user to show calendar
$todayarray = dol_getdate($now, 'fast');
$todayarray = dol_getdate($now, true);
$sav = $tmpday;
$showheader = true;
$var = false;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/comm/action/peruser.php
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@
}

// Loop on each user to show calendar
$todayarray = dol_getdate($now, 'fast');
$todayarray = dol_getdate($now, true);
$sav = $tmpday;
$showheader = true;
$var = false;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/comm/propal/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@
if (!empty($product_desc) && getDolGlobalString('MAIN_NO_CONCAT_DESCRIPTION')) {
$desc = $product_desc;
} else {
$desc = dol_concatdesc($desc, $product_desc, '', getDolGlobalString('MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION'));
$desc = dol_concatdesc($desc, $product_desc, false, getDolGlobalString('MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION') ? true : false);
}

// Add custom code and origin country into description
Expand Down
2 changes: 1 addition & 1 deletion htdocs/commande/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@
if (!empty($product_desc) && getDolGlobalString('MAIN_NO_CONCAT_DESCRIPTION')) {
$desc = $product_desc;
} else {
$desc = dol_concatdesc($desc, $product_desc, '', getDolGlobalString('MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION'));
$desc = dol_concatdesc($desc, $product_desc, false, getDolGlobalString('MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION') ? true : false);
}

// Add custom code and origin country into description
Expand Down
2 changes: 1 addition & 1 deletion htdocs/compta/facture/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -2346,7 +2346,7 @@
if (!empty($product_desc) && getDolGlobalString('MAIN_NO_CONCAT_DESCRIPTION')) {
$desc = $product_desc;
} else {
$desc = dol_concatdesc($desc, $product_desc, '', getDolGlobalString('MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION'));
$desc = dol_concatdesc($desc, $product_desc, false, getDolGlobalString('MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION') ? true : false);
}

// Add custom code and origin country into description
Expand Down
11 changes: 10 additions & 1 deletion htdocs/compta/sociales/class/chargesociales.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ class ChargeSociales extends CommonObject
*/
public $date_ech;


/**
* @var string label
*/
public $label;
public $type;
public $type_label;
Expand Down Expand Up @@ -96,6 +98,9 @@ class ChargeSociales extends CommonObject
*/
public $paiementtype;

/**
* @var int ID
*/
public $mode_reglement_id;
public $mode_reglement_code;
public $mode_reglement;
Expand All @@ -115,6 +120,9 @@ class ChargeSociales extends CommonObject
*/
public $total;

/**
* @var float total paid
*/
public $totalpaid;


Expand Down Expand Up @@ -406,6 +414,7 @@ public function update($user, $notrigger = 0)
public function solde($year = 0)
{
global $conf;

$sql = "SELECT SUM(f.amount) as amount";
$sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as f";
$sql .= " WHERE f.entity = ".((int) $conf->entity);
Expand Down
4 changes: 2 additions & 2 deletions htdocs/contrat/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@
if (!empty($product_desc) && getDolGlobalString('MAIN_NO_CONCAT_DESCRIPTION')) {
$desc = $product_desc;
} else {
$desc = dol_concatdesc($desc, $product_desc, '', getDolGlobalString('MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION'));
$desc = dol_concatdesc($desc, $product_desc, false, getDolGlobalString('MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION') ? true : false);
}

$fk_unit = $prod->fk_unit;
Expand Down Expand Up @@ -1680,7 +1680,7 @@
}
// VAT
print '<td class="center">';
print vatrate($objp->tva_tx.($objp->vat_src_code ? (' ('.$objp->vat_src_code.')') : ''), '%', $objp->info_bits);
print vatrate($objp->tva_tx.($objp->vat_src_code ? (' ('.$objp->vat_src_code.')') : ''), true, $objp->info_bits);
print '</td>';
// Price
print '<td class="right">'.($objp->subprice != '' ? price($objp->subprice) : '')."</td>\n";
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/class/html.form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* Copyright (C) 2018 Josep Lluis Amador <[email protected]>
* Copyright (C) 2023 Joachim Kueter <[email protected]>
* Copyright (C) 2023 Nick Fragoulis
* Copyright (C) 2024 MDW <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
* Copyright (C) 2024 William Mead <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/class/utils.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -854,8 +854,8 @@ public function generateDoc($module)
}

// Copy some files into temp directory, so instruction include::ChangeLog.md[] will works inside the asciidoc file.
dol_copy($dirofmodule.'/README.md', $dirofmoduletmp.'/README.md', 0, 1);
dol_copy($dirofmodule.'/ChangeLog.md', $dirofmoduletmp.'/ChangeLog.md', 0, 1);
dol_copy($dirofmodule.'/README.md', $dirofmoduletmp.'/README.md', '0', 1);
dol_copy($dirofmodule.'/ChangeLog.md', $dirofmoduletmp.'/ChangeLog.md', '0', 1);

// Replace into README.md and ChangeLog.md (in case they are included into documentation with tag __README__ or __CHANGELOG__)
$arrayreplacement = array();
Expand Down
10 changes: 5 additions & 5 deletions htdocs/core/lib/pdf.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1925,9 +1925,9 @@ function pdf_getlineref_supplier($object, $i, $outputlangs, $hidedetails = 0)
* Return line vat rate
*
* @param SupplierProposal|CommandeFournisseur|FactureFournisseur|Propal|Facture|Commande|ExpenseReport|StockTransfer $object Object
* @param int $i Current line number
* @param Translate $outputlangs Object langs for output
* @param int<0,2> $hidedetails Hide details (0=no, 1=yes, 2=just special lines)
* @param int $i Current line number
* @param Translate $outputlangs Object langs for output
* @param int<0,2> $hidedetails Hide details (0=no, 1=yes, 2=just special lines)
* @return string
*/
function pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails = 0)
Expand Down Expand Up @@ -1962,7 +1962,7 @@ function pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails = 0)
} else {
$tmpresult = '';
}
$tmpresult .= vatrate(abs($object->lines[$i]->localtax1_tx), 0);
$tmpresult .= vatrate((string) abs($object->lines[$i]->localtax1_tx), 0);
}
}
if (!getDolGlobalString('MAIN_PDF_MAIN_HIDE_THIRD_TAX')) {
Expand All @@ -1972,7 +1972,7 @@ function pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails = 0)
} else {
$tmpresult = '';
}
$tmpresult .= vatrate(abs($object->lines[$i]->localtax2_tx), 0);
$tmpresult .= vatrate((string) abs($object->lines[$i]->localtax2_tx), 0);
}
}
$tmpresult .= '%';
Expand Down
8 changes: 4 additions & 4 deletions htdocs/core/modules/commande/doc/pdf_einstein.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs
if (getDolGlobalString('PDF_LOCALTAX1_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
$totalvat .= $tvacompl;
} else {
$totalvat .= vatrate(abs((float) $tvakey), 1).$tvacompl;
$totalvat .= vatrate((string) abs((float) $tvakey), 1).$tvacompl;
}

$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
Expand Down Expand Up @@ -983,7 +983,7 @@ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs
if (getDolGlobalString('PDF_LOCALTAX2_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
$totalvat .= $tvacompl;
} else {
$totalvat .= vatrate(abs((float) $tvakey), 1).$tvacompl;
$totalvat .= vatrate((string) abs((float) $tvakey), 1).$tvacompl;
}

$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
Expand Down Expand Up @@ -1053,7 +1053,7 @@ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs
if (getDolGlobalString('PDF_LOCALTAX1_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
$totalvat .= $tvacompl;
} else {
$totalvat .= vatrate(abs((float) $tvakey), 1).$tvacompl;
$totalvat .= vatrate((string) abs((float) $tvakey), 1).$tvacompl;
}

$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
Expand Down Expand Up @@ -1093,7 +1093,7 @@ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs
if (getDolGlobalString('PDF_LOCALTAX2_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
$totalvat .= $tvacompl;
} else {
$totalvat .= vatrate(abs((float) $tvakey), 1).$tvacompl;
$totalvat .= vatrate((string) abs((float) $tvakey), 1).$tvacompl;
}

$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
Expand Down
8 changes: 4 additions & 4 deletions htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlan
if (getDolGlobalString('PDF_LOCALTAX1_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
$totalvat .= $tvacompl;
} else {
$totalvat .= vatrate(abs((float) $tvakey), 1).$tvacompl;
$totalvat .= vatrate((string) abs((float) $tvakey), 1).$tvacompl;
}

$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
Expand Down Expand Up @@ -1189,7 +1189,7 @@ protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlan
if (getDolGlobalString('PDF_LOCALTAX2_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
$totalvat .= $tvacompl;
} else {
$totalvat .= vatrate(abs((float) $tvakey), 1).$tvacompl;
$totalvat .= vatrate((string) abs((float) $tvakey), 1).$tvacompl;
}

$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
Expand Down Expand Up @@ -1257,7 +1257,7 @@ protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlan
if (getDolGlobalString('PDF_LOCALTAX1_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
$totalvat .= $tvacompl;
} else {
$totalvat .= vatrate(abs((float) $tvakey), 1).$tvacompl;
$totalvat .= vatrate((string) abs((float) $tvakey), 1).$tvacompl;
}

$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
Expand Down Expand Up @@ -1295,7 +1295,7 @@ protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlan
if (getDolGlobalString('PDF_LOCALTAX2_LABEL_IS_CODE_OR_RATE') == 'nocodenorate') {
$totalvat .= $tvacompl;
} else {
$totalvat .= vatrate(abs((float) $tvakey), 1).$tvacompl;
$totalvat .= vatrate((string) abs((float) $tvakey), 1).$tvacompl;
}

$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
Expand Down
Loading

0 comments on commit 000173c

Please sign in to comment.