Skip to content

Commit

Permalink
Qual: Fix phan notices
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeweerd committed Nov 17, 2024
1 parent b2bad15 commit 6eb4a6b
Show file tree
Hide file tree
Showing 17 changed files with 180 additions and 3,995 deletions.
3,928 changes: 26 additions & 3,902 deletions build/phpstan/phpstan-baseline.neon

Large diffs are not rendered by default.

24 changes: 7 additions & 17 deletions dev/tools/phan/baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
return [
// # Issue statistics:
// PhanUndeclaredProperty : 560+ occurrences
// PhanPossiblyUndeclaredGlobalVariable : 490+ occurrences
// PhanUndeclaredGlobalVariable : 350+ occurrences
// PhanTypeMismatchArgumentProbablyReal : 260+ occurrences
// PhanPossiblyUndeclaredGlobalVariable : 460+ occurrences
// PhanUndeclaredGlobalVariable : 320+ occurrences
// PhanTypeMismatchArgumentProbablyReal : 250+ occurrences
// PhanPluginUnknownArrayMethodReturnType : 180+ occurrences
// PhanTypeMismatchProperty : 140+ occurrences
// PhanPluginUnknownPropertyType : 130+ occurrences
Expand All @@ -22,8 +22,8 @@ return [
// PhanRedefineFunction : 45+ occurrences
// PhanTypeExpectedObjectPropAccess : 45+ occurrences
// PhanTypeMismatchArgumentNullableInternal : 40+ occurrences
// PhanTypeInvalidDimOffset : 35+ occurrences
// PhanPluginEmptyStatementIf : 30+ occurrences
// PhanTypeInvalidDimOffset : 30+ occurrences
// PhanTypeMismatchDimFetch : 30+ occurrences
// PhanUndeclaredConstant : 15+ occurrences
// PhanEmptyForeach : 10+ occurrences
Expand Down Expand Up @@ -115,15 +115,10 @@ return [
'htdocs/compta/facture/class/api_invoices.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeComparisonFromArray', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/compta/facture/class/facture-rec.class.php' => ['PhanUndeclaredProperty'],
'htdocs/compta/facture/class/facture.class.php' => ['PhanUndeclaredProperty'],
'htdocs/compta/facture/note.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/compta/facture/prelevement.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/compta/facture/stats/index.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/compta/facture/tpl/linkedobjectblock.tpl.php' => ['PhanEmptyFQSENInClasslike', 'PhanInvalidFQSENInClasslike', 'PhanTypeMismatchArgumentNullableInternal'],
'htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php' => ['PhanUndeclaredProperty'],
'htdocs/compta/journal/purchasesjournal.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/compta/journal/sellsjournal.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/compta/localtax/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable'],
'htdocs/compta/localtax/clients.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredGlobalVariable'],
'htdocs/compta/localtax/card.php' => ['PhanUndeclaredGlobalVariable'],
'htdocs/compta/localtax/clients.php' => ['PhanTypeExpectedObjectPropAccess'],
'htdocs/compta/localtax/index.php' => ['PhanRedefineFunction'],
'htdocs/compta/localtax/list.php' => ['PhanUndeclaredGlobalVariable'],
'htdocs/compta/paiement.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchDimFetch'],
Expand All @@ -140,7 +135,6 @@ return [
'htdocs/compta/prelevement/line.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/compta/prelevement/orders_list.php' => ['PhanUndeclaredGlobalVariable'],
'htdocs/compta/prelevement/stats.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/compta/resultat/clientfourn.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/compta/resultat/index.php' => ['PhanPluginEmptyStatementIf', 'PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/compta/resultat/result.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/compta/sociales/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredProperty'],
Expand All @@ -156,13 +150,11 @@ return [
'htdocs/compta/stats/supplier_turnover_by_thirdparty.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/compta/tva/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal'],
'htdocs/compta/tva/class/paymentvat.class.php' => ['PhanUndeclaredProperty'],
'htdocs/compta/tva/clients.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeArraySuspiciousNull', 'PhanTypeInvalidDimOffset', 'PhanTypeMismatchDimFetchNullable', 'PhanTypeMismatchProperty', 'PhanUndeclaredGlobalVariable'],
'htdocs/compta/tva/index.php' => ['PhanRedefineFunction', 'PhanUndeclaredGlobalVariable'],
'htdocs/compta/tva/clients.php' => ['PhanTypeArraySuspiciousNull', 'PhanTypeInvalidDimOffset', 'PhanTypeMismatchProperty'],
'htdocs/compta/tva/payments.php' => ['PhanTypeMismatchArgumentNullableInternal'],
'htdocs/compta/tva/quadri_detail.php' => ['PhanTypeArraySuspiciousNull', 'PhanTypeInvalidDimOffset', 'PhanTypeMismatchProperty'],
'htdocs/contact/card.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/contact/consumption.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/contact/list.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/contact/perso.php' => ['PhanTypeMismatchProperty'],
'htdocs/contrat/agenda.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/contrat/card.php' => ['PhanTypeMismatchProperty', 'PhanUndeclaredGlobalVariable'],
Expand Down Expand Up @@ -549,7 +541,6 @@ return [
'htdocs/public/recruitment/view.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'],
'htdocs/public/stripe/ipn.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'],
'htdocs/public/test/test_arrays.php' => ['PhanPluginUndeclaredVariableIsset'],
'htdocs/public/test/test_forms.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/public/ticket/create_ticket.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchDimFetchNullable', 'PhanTypeMismatchProperty'],
'htdocs/public/ticket/view.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/public/webportal/tpl/menu.tpl.php' => ['PhanUndeclaredProperty'],
Expand Down Expand Up @@ -634,7 +625,6 @@ return [
'htdocs/user/class/api_users.class.php' => ['PhanTypeMismatchProperty'],
'htdocs/user/class/user.class.php' => ['PhanUndeclaredProperty'],
'htdocs/user/class/usergroup.class.php' => ['PhanUndeclaredProperty'],
'htdocs/user/param_ihm.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/variants/ajax/get_attribute_values.php' => ['PhanTypeComparisonFromArray'],
'htdocs/variants/class/ProductCombination.class.php' => ['PhanPluginSuspiciousParamPosition'],
'htdocs/variants/combinations.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchProperty'],
Expand Down
3 changes: 2 additions & 1 deletion htdocs/compta/facture/note.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Copyright (C) 2013 Florian Henry <[email protected]>
* Copyright (C) 2017 Ferran Marcet <[email protected]>
* Copyright (C) 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 @@ -54,7 +55,7 @@
$object = new Facture($db);
// Load object
if ($id > 0 || !empty($ref)) {
$object->fetch($id, $ref, '', '', (getDolGlobalString('INVOICE_USE_SITUATION') ? $conf->global->INVOICE_USE_SITUATION : 0));
$object->fetch($id, $ref, '', 0, (getDolGlobalString('INVOICE_USE_SITUATION') ? $conf->global->INVOICE_USE_SITUATION : 0));
}

$permissionnote = $user->hasRight('facture', 'creer'); // Used by the include of actions_setnotes.inc.php
Expand Down
11 changes: 6 additions & 5 deletions htdocs/compta/facture/prelevement.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
}

// Load object
$isdraft = 1;
if ($id > 0 || !empty($ref)) {
$ret = $object->fetch($id, $ref);
$isdraft = (($object->status == FactureFournisseur::STATUS_DRAFT) ? 1 : 0);
Expand Down Expand Up @@ -310,8 +311,8 @@
$filtercreditnote = "fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
}

$absolute_discount = $object->thirdparty->getAvailableDiscounts('', $filterabsolutediscount, 0, 1);
$absolute_creditnote = $object->thirdparty->getAvailableDiscounts('', $filtercreditnote, 0, 1);
$absolute_discount = $object->thirdparty->getAvailableDiscounts(null, $filterabsolutediscount, 0, 1);
$absolute_creditnote = $object->thirdparty->getAvailableDiscounts(null, $filtercreditnote, 0, 1);
$absolute_discount = price2num($absolute_discount, 'MT');
$absolute_creditnote = price2num($absolute_creditnote, 'MT');
} else {
Expand All @@ -323,8 +324,8 @@
$filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
}

$absolute_discount = $object->thirdparty->getAvailableDiscounts('', $filterabsolutediscount);
$absolute_creditnote = $object->thirdparty->getAvailableDiscounts('', $filtercreditnote);
$absolute_discount = $object->thirdparty->getAvailableDiscounts(null, $filterabsolutediscount);
$absolute_creditnote = $object->thirdparty->getAvailableDiscounts(null, $filtercreditnote);
$absolute_discount = price2num($absolute_discount, 'MT');
$absolute_creditnote = price2num($absolute_creditnote, 'MT');
}
Expand Down Expand Up @@ -821,7 +822,7 @@
print img_warning('Error on default bank number for IBAN : '.$langs->trans($companyBankAccount->error));
}
} elseif ($numopen || ($type != 'bank-transfer' && $object->mode_reglement_code == 'PRE') || ($type == 'bank-transfer' && $object->mode_reglement_code == 'VIR')) {
print img_warning($langs->trans("NoDefaultIBANFound"));
print img_warning($langs->trans("NoDefaultIBANFound"));
}

//print '</td></tr>';
Expand Down
7 changes: 6 additions & 1 deletion htdocs/compta/facture/stats/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
//var_dump($data);

$filenamenb = $dir."/invoicesnbinyear-".$year.".png";
$fileurlnb = '';
if ($mode == 'customer') {
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesnbinyear-'.$year.'.png';
}
Expand Down Expand Up @@ -178,6 +179,7 @@
// $data = array(array('Lib',val1,val2,val3),...)

$filenameamount = $dir."/invoicesamountinyear-".$year.".png";
$fileurlamount = '';
if ($mode == 'customer') {
$fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesamountinyear-'.$year.'.png';
}
Expand Down Expand Up @@ -212,6 +214,7 @@

$data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);

$fileurl_avg = '';
if (!$user->hasRight('societe', 'client', 'voir')) {
$filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png';
if ($mode == 'customer') {
Expand Down Expand Up @@ -318,6 +321,8 @@

// Category
if (isModEnabled('category')) {
$cat_type = '';
$cat_label = '';
if ($mode == 'customer') {
$cat_type = Categorie::TYPE_CUSTOMER;
$cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Customer"));
Expand All @@ -327,7 +332,7 @@
$cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Supplier"));
}
print '<tr><td>'.$cat_label.'</td><td>';
$cate_arbo = $form->select_all_categories($cat_type, null, 'parent', null, null, 1);
$cate_arbo = $form->select_all_categories($cat_type, '', 'parent', 0, 0, 1);
print img_picto('', 'category', 'class="pictofixedwidth"');
print $form->multiselectarray('select_categ_categ_id', $cate_arbo, GETPOST('select_categ_categ_id', 'array'), 0, 0, 'widthcentpercentminusx maxwidth300');
//print $formother->select_categories($cat_type, $categ_id, 'categ_id', true);
Expand Down
3 changes: 2 additions & 1 deletion htdocs/compta/journal/purchasesjournal.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,15 @@
$db->query('SET SQL_BIG_SELECTS=1');
}

$tabfac = array();

$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
// les variables
$cptfour = ((getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') != "") ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef"));
$cpttva = (getDolGlobalString('ACCOUNTING_VAT_BUY_ACCOUNT') ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));

$tabfac = array();
$tabht = array();
$tabtva = array();
$tabttc = array();
Expand Down
3 changes: 2 additions & 1 deletion htdocs/compta/journal/sellsjournal.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,10 @@
$db->query('SET SQL_BIG_SELECTS=1');
}

$tabfac = array();

$result = $db->query($sql);
if ($result) {
$tabfac = array();
$tabht = array();
$tabtva = array();
$tablocaltax1 = array();
Expand Down
5 changes: 4 additions & 1 deletion htdocs/compta/localtax/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* Copyright (C) 2011-2014 Juanjo Menent <[email protected]>
* Copyright (C) 2015 Marcos García <[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 @@ -118,14 +119,16 @@
if ($result > 0) {
$result = $accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing)
}
} else {
$accountline = null;
}

if ($result >= 0) {
$db->commit();
header("Location: ".DOL_URL_ROOT.'/compta/localtax/list.php?localTaxType='.$object->ltt);
exit;
} else {
$object->error = $accountline->error;
$object->error = $accountline !== null ? $accountline->error : "No account line / no bank identified found";
$db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
}
Expand Down
49 changes: 29 additions & 20 deletions htdocs/compta/localtax/clients.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
}
$date_start = dol_mktime(0, 0, 0, GETPOSTINT("date_startmonth"), GETPOSTINT("date_startday"), GETPOSTINT("date_startyear"));
$date_end = dol_mktime(23, 59, 59, GETPOSTINT("date_endmonth"), GETPOSTINT("date_endday"), GETPOSTINT("date_endyear"));
$q = 0;
// Quarter
if (empty($date_start) || empty($date_end)) { // We define date_start and date_end
$q = GETPOST("q");
Expand Down Expand Up @@ -124,7 +125,12 @@
accessforbidden('Parameter localTaxType is missing');
}

$builddate = dol_now();
$calc = 0;
$calcmode = "Unknown";
$find = '';
$replace = '';
$period = '';
/*
* View
*/
Expand Down Expand Up @@ -203,6 +209,9 @@
print '<div class="div-table-responsive">';
print '<table class="liste noborder centpercent">';

$x_coll_sum = 0; // Initialize value
$x_paye_sum = 0; // Initialize value

// IRPF that the customer has retained me
if ($calc == 0 || $calc == 2) {
print '<tr class="liste_titre">';
Expand Down Expand Up @@ -231,28 +240,28 @@
$total = 0;
$totalamount = 0;
$i = 1;
foreach ($coll_list as $coll) {
if (($min == 0 || ($min > 0 && $coll->amount > $min)) && ($local == 1 ? $coll->localtax1 : $coll->localtax2) != 0) {
$intra = str_replace($find, $replace, $coll->tva_intra);
foreach ($coll_list as $coll_obj) {
if (($min == 0 || ($min > 0 && $coll_obj->amount > $min)) && ($local == 1 ? $coll_obj->localtax1 : $coll_obj->localtax2) != 0) {
$intra = str_replace($find, $replace, $coll_obj->tva_intra);
if (empty($intra)) {
if ($coll->assuj == '1') {
if ($coll_obj->assuj == '1') {
$intra = $langs->trans('Unknown');
} else {
$intra = '';
}
}
print '<tr class="oddeven">';
print '<td class="nowrap">'.$i."</td>";
$company_static->id = $coll->socid;
$company_static->name = $coll->name;
$company_static->id = $coll_obj->socid;
$company_static->name = $coll_obj->name;
print '<td class="nowrap">'.$company_static->getNomUrl(1).'</td>';
$find = array(' ', '.');
$replace = array('', '');
print '<td class="nowrap">'.$intra.'</td>';
print '<td class="nowrap right">'.price($coll->amount).'</td>';
print '<td class="nowrap right">'.price($local == 1 ? $coll->localtax1 : $coll->localtax2).'</td>';
$totalamount += $coll->amount;
$total += ($local == 1 ? $coll->localtax1 : $coll->localtax2);
print '<td class="nowrap right">'.price($coll_obj->amount).'</td>';
print '<td class="nowrap right">'.price($local == 1 ? $coll_obj->localtax1 : $coll_obj->localtax2).'</td>';
$totalamount += $coll_obj->amount;
$total += ($local == 1 ? $coll_obj->localtax1 : $coll_obj->localtax2);
print "</tr>\n";
$i++;
}
Expand Down Expand Up @@ -296,28 +305,28 @@
$total = 0;
$totalamount = 0;
$i = 1;
foreach ($coll_list as $coll) {
if (($min == 0 || ($min > 0 && $coll->amount > $min)) && ($local == 1 ? $coll->localtax1 : $coll->localtax2) != 0) {
$intra = str_replace($find, $replace, $coll->tva_intra);
foreach ($coll_list as $coll_obj) {
if (($min == 0 || ($min > 0 && $coll_obj->amount > $min)) && ($local == 1 ? $coll_obj->localtax1 : $coll_obj->localtax2) != 0) {
$intra = str_replace($find, $replace, $coll_obj->tva_intra);
if (empty($intra)) {
if ($coll->assuj == '1') {
if ($coll_obj->assuj == '1') {
$intra = $langs->trans('Unknown');
} else {
$intra = '';
}
}
print '<tr class="oddeven">';
print '<td class="nowrap">'.$i."</td>";
$company_static->id = $coll->socid;
$company_static->name = $coll->name;
$company_static->id = $coll_obj->socid;
$company_static->name = $coll_obj->name;
print '<td class="nowrap">'.$company_static->getNomUrl(1).'</td>';
$find = array(' ', '.');
$replace = array('', '');
print '<td class="nowrap">'.$intra."</td>";
print '<td class="nowrap right">'.price($coll->amount).'</td>';
print '<td class="nowrap right">'.price($local == 1 ? $coll->localtax1 : $coll->localtax2).'</td>';
$totalamount += $coll->amount;
$total += ($local == 1 ? $coll->localtax1 : $coll->localtax2);
print '<td class="nowrap right">'.price($coll_obj->amount).'</td>';
print '<td class="nowrap right">'.price($local == 1 ? $coll_obj->localtax1 : $coll_obj->localtax2).'</td>';
$totalamount += $coll_obj->amount;
$total += ($local == 1 ? $coll_obj->localtax1 : $coll_obj->localtax2);
print "</tr>\n";
$i++;
}
Expand Down
4 changes: 2 additions & 2 deletions htdocs/compta/localtax/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
* @param string $date Date
* @return void
*/
function pt($db, $sql, $date)
function localtax_pt($db, $sql, $date)
{
global $conf, $bc, $langs;

Expand Down Expand Up @@ -600,7 +600,7 @@ function pt($db, $sql, $date)
$sql .= " ORDER BY dm ASC, mode ASC";
//print $sql;

pt($db, $sql, $langs->trans("Month"));
localtax_pt($db, $sql, $langs->trans("Month"));


print '</div></div>';
Expand Down
Loading

0 comments on commit 6eb4a6b

Please sign in to comment.