Skip to content

Commit

Permalink
Qual: Fix some phan notices
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeweerd committed Nov 16, 2024
1 parent 7a84561 commit 52c3b45
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 31 deletions.
16 changes: 5 additions & 11 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 : 500+ occurrences
// PhanPossiblyUndeclaredGlobalVariable : 490+ occurrences
// PhanUndeclaredGlobalVariable : 350+ occurrences
// PhanTypeMismatchArgumentProbablyReal : 270+ occurrences
// PhanTypeMismatchArgumentProbablyReal : 260+ occurrences
// PhanPluginUnknownArrayMethodReturnType : 180+ occurrences
// PhanTypeMismatchProperty : 140+ occurrences
// PhanPluginUnknownPropertyType : 130+ occurrences
Expand All @@ -21,7 +21,7 @@ return [
// PhanPluginUndeclaredVariableIsset : 65+ occurrences
// PhanRedefineFunction : 45+ occurrences
// PhanTypeExpectedObjectPropAccess : 45+ occurrences
// PhanTypeMismatchArgumentNullableInternal : 45+ occurrences
// PhanTypeMismatchArgumentNullableInternal : 40+ occurrences
// PhanTypeInvalidDimOffset : 35+ occurrences
// PhanPluginEmptyStatementIf : 30+ occurrences
// PhanTypeMismatchDimFetch : 30+ occurrences
Expand Down Expand Up @@ -108,19 +108,13 @@ return [
'htdocs/compta/bank/various_payment/document.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'],
'htdocs/compta/bank/various_payment/info.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'],
'htdocs/compta/bank/various_payment/list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchProperty'],
'htdocs/compta/cashcontrol/cashcontrol_card.php' => ['PhanPluginDuplicateExpressionBinaryOp', 'PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/compta/cashcontrol/cashcontrol_card.php' => ['PhanPluginDuplicateExpressionBinaryOp'],
'htdocs/compta/cashcontrol/cashcontrol_list.php' => ['PhanTypeMismatchProperty'],
'htdocs/compta/charges/index.php' => ['PhanTypeMismatchArgumentNullableInternal'],
'htdocs/compta/clients.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable'],
'htdocs/compta/deplacement/stats/index.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/compta/facture/agenda-rec.php' => ['PhanPluginEmptyStatementIf'],
'htdocs/compta/facture/card.php' => ['PhanTypeMismatchProperty', 'PhanUndeclaredProperty'],
'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/contact.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/compta/facture/invoicetemplate_list.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/compta/facture/list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/compta/facture/note.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/compta/facture/prelevement.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/compta/facture/stats/index.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
Expand Down Expand Up @@ -599,7 +593,7 @@ return [
'htdocs/societe/consumption.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/societe/list.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/societe/paymentmodes.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeExpectedObjectPropAccess', 'PhanUndeclaredGlobalVariable'],
'htdocs/societe/price.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/societe/price.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/societe/tpl/linesalesrepresentative.tpl.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/societe/website.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/stripe/class/actions_stripe.class.php' => ['PhanPluginBothLiteralsBinaryOp', 'PhanPluginSuspiciousParamPosition'],
Expand Down
5 changes: 4 additions & 1 deletion htdocs/compta/cashcontrol/cashcontrol_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@
llxHeader('', $langs->trans("CashControl"));


$terminalid = '';
$terminaltouse = '';

if ($action == "create" || $action == "start" || $action == 'close') {
if ($action == 'close') {
$posmodule = $object->posmodule;
Expand All @@ -305,7 +308,7 @@
}
}

if (isset($terminalid) && $terminalid != '') {
if (isset($terminalid) && $terminalid != '' && isset($posmodule)) {
// Calculate $initialbalanceforterminal for terminal 0
foreach ($arrayofpaymentmode as $key => $val) {
if ($key != 'cash') {
Expand Down
6 changes: 3 additions & 3 deletions htdocs/compta/charges/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
$sql .= " OR (cs.periode IS NULL AND cs.date_ech between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')";
$sql .= ")";
}
if (preg_match('/^cs\./', $sortfield) || preg_match('/^c\./', $sortfield) || preg_match('/^pc\./', $sortfield) || preg_match('/^pct\./', $sortfield)) {
if (preg_match('/^(cs?|pct?)\./', (string) $sortfield)) {
$sql .= $db->order($sortfield, $sortorder);
}
//$sql.= $db->plimit($limit+1,$offset);
Expand Down Expand Up @@ -310,7 +310,7 @@
// so we are compatible when period is not mandatory
$sql .= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'";
}
if (preg_match('/^pv\./', $sortfield) || preg_match('/^ptva\./', $sortfield)) {
if (preg_match('/^(pv|ptva)\./', (string) $sortfield)) {
$sql .= $db->order($sortfield, $sortorder);
}

Expand Down Expand Up @@ -465,7 +465,7 @@
// so we are compatible when period is not mandatory
$sql .= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'";
}
if (preg_match('/^pv/', $sortfield)) {
if (preg_match('/^pv/', (string) $sortfield)) {
$sql .= $db->order($sortfield, $sortorder);
}

Expand Down
1 change: 1 addition & 0 deletions htdocs/compta/deplacement/stats/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
$data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);

$filename_avg = '';
$fileurl_avg = '';
if (!$user->hasRight('societe', 'client', 'voir')) {
$filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png';
if ($mode == 'customer') {
Expand Down
17 changes: 9 additions & 8 deletions htdocs/compta/facture/agenda-rec.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2023 Laurent Destailleur <[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 @@ -227,15 +228,15 @@
//$messagingUrl = DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id;
//$morehtmlstatus .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 2);

if (isModEnabled('agenda')) {
/*
if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) {
$morehtmlstatus .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out);
} else {
$morehtmlstatus .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out, '', 0);
}
*/
//if (isModEnabled('agenda')) {
/*
if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) {
$morehtmlstatus .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out);
} else {
$morehtmlstatus .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out, '', 0);
}
*/
//}


if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) {
Expand Down
5 changes: 3 additions & 2 deletions htdocs/compta/facture/contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Copyright (C) 2017 Ferran Marcet <[email protected]>
* Copyright (C) 2023 Christian Foellmann <[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 @@ -63,7 +64,7 @@
$object = new Facture($db);
// Load object
if ($id > 0 || !empty($ref)) {
$ret = $object->fetch($id, $ref, '', '', (getDolGlobalString('INVOICE_USE_SITUATION') ? $conf->global->INVOICE_USE_SITUATION : 0));
$ret = $object->fetch($id, $ref, '', 0, (getDolGlobalString('INVOICE_USE_SITUATION') ? $conf->global->INVOICE_USE_SITUATION : 0));
}
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
$hookmanager->initHooks(array('invoicecontactcard', 'globalcard'));
Expand All @@ -77,7 +78,7 @@
* Actions
*/

$parameters = array('id'=>$id);
$parameters = array('id' => $id);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
Expand Down
2 changes: 1 addition & 1 deletion htdocs/compta/facture/invoicetemplate_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@
// Payment term
if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
print '<td class="tdoverflowmax150">';
$form->form_conditions_reglement('', $objp->fk_cond_reglement, 'none');
$form->form_conditions_reglement(0, $objp->fk_cond_reglement, 'none');
print '</td>'."\n";
if (!$i) {
$totalarray['nbfield']++;
Expand Down
14 changes: 9 additions & 5 deletions htdocs/compta/facture/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,8 @@
$result_sql = $db->query($rsql);
if ($result_sql) {
$numprlv = $db->num_rows($result_sql);
} else {
$numprlv = 0;
}

if ($numprlv > 0) {
Expand Down Expand Up @@ -633,9 +635,11 @@
if (empty($search_company)) {
$search_company = $soc->name;
}
} else {
$soc = null;
}

$title = $langs->trans('BillsCustomers').' '.($socid > 0 ? ' - '.$soc->name : '');
$title = $langs->trans('BillsCustomers').' '.(($socid > 0 && $soc !== null) ? ' - '.$soc->name : '');
$help_url = 'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes';

$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
Expand Down Expand Up @@ -1341,7 +1345,7 @@
include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$moreforfilter .= '<div class="divsearchfield">';
$tmptitle = $langs->trans('IncludingProductWithTag');
$cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
$cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 0, 0, 1);
$moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth300 widthcentpercentminusx', 1);
$moreforfilter .= '</div>';
}
Expand Down Expand Up @@ -1509,7 +1513,7 @@
// Country
if (!empty($arrayfields['country.code_iso']['checked'])) {
print '<td class="liste_titre center">';
print $form->select_country($search_country, 'search_country', '', 0, 'minwidth150imp maxwidth150', 'code2', 1, 0, 1, null, 1);
print $form->select_country($search_country, 'search_country', '', 0, 'minwidth150imp maxwidth150', 'code2', 1, 0, 1, array(), 1);
print '</td>';
}
// Company type
Expand Down Expand Up @@ -2051,10 +2055,10 @@
$multicurrency_remaintopay = 0;
}
if ($facturestatic->type == Facture::TYPE_CREDIT_NOTE && $obj->paye == 1) { // If credit note closed, we take into account the amount not yet consumed
$remaincreditnote = $discount->getAvailableDiscounts($companystatic, '', 'rc.fk_facture_source='.$facturestatic->id);
$remaincreditnote = $discount->getAvailableDiscounts($companystatic, null, 'rc.fk_facture_source='.$facturestatic->id);
$remaintopay = -$remaincreditnote;
$totalallpayments = price2num($facturestatic->total_ttc - $remaintopay);
$multicurrency_remaincreditnote = $discount->getAvailableDiscounts($companystatic, '', 'rc.fk_facture_source='.$facturestatic->id, 0, 0, 1);
$multicurrency_remaincreditnote = $discount->getAvailableDiscounts($companystatic, null, 'rc.fk_facture_source='.$facturestatic->id, 0, 0, 1);
$multicurrency_remaintopay = -$multicurrency_remaincreditnote;
$multicurrency_totalpay = price2num($facturestatic->multicurrency_total_ttc - $multicurrency_remaintopay);
}
Expand Down

0 comments on commit 52c3b45

Please sign in to comment.