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 18, 2024
1 parent d558075 commit c3ef8e0
Show file tree
Hide file tree
Showing 26 changed files with 136 additions and 82 deletions.
33 changes: 5 additions & 28 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 : 460+ occurrences
// PhanPossiblyUndeclaredGlobalVariable : 390+ occurrences
// PhanUndeclaredGlobalVariable : 320+ occurrences
// PhanTypeMismatchArgumentProbablyReal : 250+ occurrences
// PhanTypeMismatchArgumentProbablyReal : 240+ occurrences
// PhanPluginUnknownArrayMethodReturnType : 180+ occurrences
// PhanTypeMismatchProperty : 140+ occurrences
// PhanPluginUnknownPropertyType : 130+ occurrences
Expand All @@ -22,9 +22,9 @@ return [
// PhanRedefineFunction : 45+ occurrences
// PhanTypeExpectedObjectPropAccess : 45+ occurrences
// PhanTypeMismatchArgumentNullableInternal : 40+ occurrences
// PhanPluginEmptyStatementIf : 30+ occurrences
// PhanTypeInvalidDimOffset : 30+ occurrences
// PhanTypeMismatchDimFetch : 30+ occurrences
// PhanPluginEmptyStatementIf : 15+ occurrences
// PhanUndeclaredConstant : 15+ occurrences
// PhanEmptyForeach : 10+ occurrences
// PhanPluginUnknownObjectMethodCall : 10+ occurrences
Expand Down Expand Up @@ -119,35 +119,12 @@ return [
'htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php' => ['PhanUndeclaredProperty'],
'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'],
'htdocs/compta/paiement/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredProperty'],
'htdocs/compta/paiement/cheque/card.php' => ['PhanUndeclaredGlobalVariable'],
'htdocs/compta/paiement.php' => ['PhanTypeMismatchDimFetch'],
'htdocs/compta/paiement/card.php' => ['PhanUndeclaredProperty'],
'htdocs/compta/paiement/cheque/list.php' => ['PhanTypeMismatchProperty', 'PhanUndeclaredGlobalVariable'],
'htdocs/compta/paiement/list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredGlobalVariable'],
'htdocs/compta/paiement_charge.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/compta/paiement_vat.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/compta/payment_vat/card.php' => ['PhanUndeclaredGlobalVariable'],
'htdocs/compta/prelevement/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/compta/prelevement/demandes.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/compta/prelevement/factures.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/compta/prelevement/line.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/compta/prelevement/orders_list.php' => ['PhanUndeclaredGlobalVariable'],
'htdocs/compta/prelevement/stats.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/compta/resultat/index.php' => ['PhanPluginEmptyStatementIf', 'PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/compta/resultat/result.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/compta/sociales/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredProperty'],
'htdocs/compta/sociales/list.php' => ['PhanPluginUndeclaredVariableIsset'],
'htdocs/compta/sociales/payments.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/compta/stats/byratecountry.php' => ['PhanPluginEmptyStatementIf'],
'htdocs/compta/stats/cabyprodserv.php' => ['PhanPluginEmptyStatementIf', 'PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/compta/stats/cabyuser.php' => ['PhanPluginEmptyStatementIf', 'PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/compta/stats/casoc.php' => ['PhanPluginEmptyStatementIf', 'PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/compta/stats/index.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/compta/stats/supplier_turnover.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/compta/stats/supplier_turnover_by_prodserv.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'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' => ['PhanTypeArraySuspiciousNull', 'PhanTypeInvalidDimOffset', 'PhanTypeMismatchProperty'],
Expand Down
7 changes: 7 additions & 0 deletions htdocs/compta/paiement.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@
$paiement->note_private = GETPOST('comment', 'alpha');
$paiement->fk_account = GETPOSTINT('accountid');

$paiement_id = 0;
if (!$error) {
// Create payment and update this->multicurrency_amounts if this->amounts filled or
// this->amounts if this->multicurrency_amounts filled.
Expand Down Expand Up @@ -648,6 +649,7 @@ function callForResult(imgId)
$totalrecu = 0;
$totalrecucreditnote = 0;
$totalrecudeposits = 0;
$sign = 1;

while ($i < $num) {
$objp = $db->fetch_object($resql);
Expand All @@ -670,6 +672,10 @@ function callForResult(imgId)

// Multicurrency Price
$tooltiponmulticurrencyfullamount = '';
$multicurrency_remaintopay = '';
$multicurrency_payment = 0;
$multicurrency_creditnotes = 0;
$multicurrency_deposits = 0;
if (isModEnabled('multicurrency')) {
$multicurrency_payment = $invoice->getSommePaiement(1);
$multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1);
Expand Down Expand Up @@ -909,6 +915,7 @@ function callForResult(imgId)
$preselectedchoice = $addwarning ? 'no' : 'yes';

print '<br>';
$text = '';
if (!empty($totalpayment)) {
$text = $langs->trans('ConfirmCustomerPayment', $totalpayment, $langs->transnoentitiesnoconv("Currency".$conf->currency));
}
Expand Down
5 changes: 4 additions & 1 deletion htdocs/compta/paiement/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@
print '<tr><td>'.$langs->trans('Amount').'</td><td>'.price($object->amount, 0, $langs, 0, -1, -1, $conf->currency).'</td></tr>';

$disable_delete = 0;
$bankline = null;

// Bank account
if (isModEnabled("bank")) {
$bankline = new AccountLine($db);
Expand Down Expand Up @@ -392,7 +394,7 @@
print '<tr>';
print '<td>'.$langs->trans('BankTransactionLine').'</td>';
print '<td>';
if ($object->fk_account > 0) {
if ($object->fk_account > 0 && $bankline !== null) {
print $bankline->getNomUrl(1, 0, 'showconciliatedandaccounted');
} else {
$langs->load("admin");
Expand Down Expand Up @@ -442,6 +444,7 @@
print '<tr><td class="tdtop">'.$langs->trans("StripePaymentId").'</td><td class="wordbreak">';
if (isModEnabled('stripe') && in_array($object->ext_payment_site, array('Stripe', 'StripeLive'))) {
$tmp1 = explode('@', $object->ext_payment_id);
$site_account_payment = '';
if (!empty($tmp1[1])) {
$site_account_payment = $tmp1[1]; // pk_live_...
}
Expand Down
3 changes: 2 additions & 1 deletion htdocs/compta/paiement/cheque/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Copyright (C) 2013 Philippe Grand <[email protected]>
* Copyright (C) 2015-2016 Alexandre Spangaro <[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 @@ -203,7 +204,7 @@
header("Location: index.php");
exit;
} else {
setEventMessages($paiement->error, $paiement->errors, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
}

Expand Down
2 changes: 2 additions & 0 deletions htdocs/compta/paiement_charge.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* Copyright (C) 2004-2014 Laurent Destailleur <[email protected]>
* Copyright (C) 2016-2024 Frédéric France <[email protected]>
* Copyright (C) 2022 Alexandre Spangaro <[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 @@ -201,6 +202,7 @@
$sql = "SELECT sum(p.amount) as total";
$sql .= " FROM ".MAIN_DB_PREFIX."paiementcharge as p";
$sql .= " WHERE p.fk_charge = ".((int) $chid);
$sumpaid = 0;
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
Expand Down
1 change: 1 addition & 0 deletions htdocs/compta/paiement_vat.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
$sql = "SELECT sum(p.amount) as total";
$sql .= " FROM ".MAIN_DB_PREFIX."payment_vat as p";
$sql .= " WHERE p.fk_tva = ".((int) $chid);
$sumpaid = 0;
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
Expand Down
2 changes: 2 additions & 0 deletions htdocs/compta/payment_vat/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@
}
}

$outputlangs = $langs;

// Validate social contribution
/*
if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->tax->charges->creer)
Expand Down
7 changes: 5 additions & 2 deletions htdocs/compta/prelevement/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Copyright (C) 2005-2010 Laurent Destailleur <[email protected]>
* Copyright (C) 2010-2016 Juanjo Menent <[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 @@ -245,7 +246,7 @@
print '<form name="setdate_trans" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setdate_trans">';
print $form->selectDate($object->date_trans ? $object->date_trans : -1, 'date_trans', 0, 0, "setdate_trans");
print $form->selectDate($object->date_trans ? $object->date_trans : -1, 'date_trans', 0, 0, 0, "setdate_trans");
print '<input type="submit" class="button button-edit smallpaddingimp valign middle" value="'.$langs->trans('Modify').'">';
print '</form>';
} else {
Expand Down Expand Up @@ -564,12 +565,14 @@
if (!$salaryBonPl) {
$thirdparty = new Societe($db);
$thirdparty->fetch($obj->socid);
$name = $thirdparty->getNomUrl(1);
} else {
$userSalary = new User($db);
$userSalary->fetch($obj->fk_user);
$name = $userSalary->getNomUrl(-1);
}
print '<td class="tdoverflowmax150">';
print(!$salaryBonPl ? $thirdparty->getNomUrl(1) : $userSalary->getNomUrl(-1));
print($name);
print "</td>\n";

print '<td class="right"><span class="amount">'.price($obj->amount)."</span></td>\n";
Expand Down
2 changes: 2 additions & 0 deletions htdocs/compta/prelevement/demandes.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Copyright (C) 2005-2009 Regis Houssin <[email protected]>
* Copyright (C) 2011-2012 Juanjo Menent <[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 @@ -215,6 +216,7 @@
}
// Count total nb of records
$nbtotalofrecords = '';
$resql = null;
if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
$resql = $db->query($sql);
$nbtotalofrecords = $db->num_rows($resql);
Expand Down
5 changes: 5 additions & 0 deletions htdocs/compta/prelevement/factures.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Copyright (C) 2005-2009 Regis Houssin <[email protected]>
* Copyright (C) 2010-2012 Juanjo Menent <[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 @@ -329,6 +330,10 @@

$totalinvoices = 0;
$totalamount_requested = 0;
$salarytmp = null;
$usertmp = null;
$invoicetmpcustomer = null;
$invoicetmpsupplier = null;

if ($salaryBonPl) {
$salarytmp = new Salary($db);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/compta/prelevement/line.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@

if ($action == 'confirm_rejet' && $permissiontoadd) {
if (GETPOST("confirm") == 'yes') {
$datarej = null;
$daterej = null;
if (GETPOSTINT('remonth')) {
$daterej = dol_mktime(0, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'));
}
Expand Down
3 changes: 3 additions & 0 deletions htdocs/compta/prelevement/orders_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Copyright (C) 2010-2012 Juanjo Menent <[email protected]>
* Copyright (C) 2024 Alexandre Spangaro <[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 @@ -118,6 +119,8 @@
$TMsg = array();
$db->begin();
$objecttmp = new BonPrelevement($db);
$nbignored = 0;
$nbok = 0;
foreach ($toselect as $toselectid) {
$result = $objecttmp->fetch($toselectid);
if ($result > 0) {
Expand Down
3 changes: 3 additions & 0 deletions htdocs/compta/prelevement/stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Copyright (C) 2005-2009 Regis Houssin <[email protected]>
* Copyright (C) 2010-2011 Juanjo Menent <[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 @@ -79,6 +80,8 @@
$sql .= " AND pb.type = 'debit-order'";
}
$sql .= " AND pb.entity = ".$conf->entity;
$total = 0;
$nbtotal = 0;
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
Expand Down
Loading

0 comments on commit c3ef8e0

Please sign in to comment.