From a776c1b42aa90d1bc486712d1fafe2439f6fb699 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 19 Nov 2024 01:54:30 +0100 Subject: [PATCH] Qual: Fix phan notices # Qual: Fix phan notices Fix phan notices up to htdocs\core\ajax\selectsearchbox.php. --- dev/tools/phan/baseline.txt | 35 ++++++-------------- htdocs/compta/tva/card.php | 6 +++- htdocs/compta/tva/clients.php | 6 ++-- htdocs/compta/tva/payments.php | 2 +- htdocs/compta/tva/quadri_detail.php | 2 +- htdocs/contact/card.php | 10 +++--- htdocs/contact/consumption.php | 17 +++++++--- htdocs/contact/perso.php | 2 +- htdocs/contrat/agenda.php | 3 +- htdocs/contrat/card.php | 8 ++--- htdocs/contrat/messaging.php | 3 +- htdocs/contrat/services_list.php | 4 +-- htdocs/core/actions_addupdatedelete.inc.php | 3 +- htdocs/core/actions_comments.inc.php | 7 ++++ htdocs/core/actions_lineupdown.inc.php | 7 +++- htdocs/core/actions_linkedfiles.inc.php | 5 +++ htdocs/core/actions_massactions.inc.php | 3 +- htdocs/core/actions_sendmails.inc.php | 8 +++-- htdocs/core/actions_setmoduleoptions.inc.php | 8 ++--- htdocs/core/ajax/ajaxdirpreview.php | 2 ++ htdocs/core/ajax/ajaxdirtree.php | 3 +- htdocs/core/ajax/selectobject.php | 8 +++-- htdocs/core/ajax/selectsearchbox.php | 4 ++- 23 files changed, 93 insertions(+), 63 deletions(-) diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index edf4ee7efb1d2..209abe87e077c 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -10,15 +10,15 @@ return [ // # Issue statistics: // PhanUndeclaredProperty : 560+ occurrences - // PhanPossiblyUndeclaredGlobalVariable : 390+ occurrences - // PhanUndeclaredGlobalVariable : 310+ occurrences - // PhanTypeMismatchArgumentProbablyReal : 240+ occurrences + // PhanPossiblyUndeclaredGlobalVariable : 370+ occurrences + // PhanUndeclaredGlobalVariable : 300+ occurrences + // PhanTypeMismatchArgumentProbablyReal : 230+ occurrences // PhanPluginUnknownArrayMethodReturnType : 180+ occurrences // PhanTypeMismatchProperty : 140+ occurrences // PhanPluginUnknownPropertyType : 130+ occurrences // PhanPluginUnknownArrayMethodParamType : 120+ occurrences // PhanPossiblyUndeclaredVariable : 110+ occurrences - // PhanPluginUndeclaredVariableIsset : 65+ occurrences + // PhanPluginUndeclaredVariableIsset : 60+ occurrences // PhanRedefineFunction : 45+ occurrences // PhanTypeExpectedObjectPropAccess : 45+ occurrences // PhanTypeMismatchArgumentNullableInternal : 40+ occurrences @@ -26,15 +26,15 @@ return [ // PhanTypeMismatchDimFetch : 30+ occurrences // PhanPluginEmptyStatementIf : 15+ occurrences // PhanUndeclaredConstant : 15+ occurrences - // PhanEmptyForeach : 10+ occurrences // PhanPluginUnknownObjectMethodCall : 10+ occurrences - // PhanTypeArraySuspiciousNull : 10+ occurrences // PhanTypeComparisonFromArray : 10+ occurrences // PhanTypeMismatchDimFetchNullable : 10+ occurrences // PhanUndeclaredMethod : 10+ occurrences - // PhanPluginBothLiteralsBinaryOp : 8 occurrences + // PhanEmptyForeach : 9 occurrences + // PhanPluginBothLiteralsBinaryOp : 7 occurrences // PhanPluginDuplicateExpressionBinaryOp : 7 occurrences // PhanPluginSuspiciousParamPosition : 7 occurrences + // PhanTypeArraySuspiciousNull : 7 occurrences // PhanPossiblyNullTypeMismatchProperty : 5 occurrences // PhanParamTooMany : 4 occurrences // PhanPluginDuplicateArrayKey : 4 occurrences @@ -125,31 +125,19 @@ return [ 'htdocs/compta/paiement/cheque/list.php' => ['PhanTypeMismatchProperty', 'PhanUndeclaredGlobalVariable'], 'htdocs/compta/paiement/list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredGlobalVariable'], 'htdocs/compta/sociales/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredProperty'], - 'htdocs/compta/tva/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal'], 'htdocs/compta/tva/class/paymentvat.class.php' => ['PhanUndeclaredProperty'], '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/perso.php' => ['PhanTypeMismatchProperty'], 'htdocs/contrat/agenda.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/contrat/card.php' => ['PhanTypeMismatchProperty', 'PhanUndeclaredGlobalVariable'], + 'htdocs/contrat/card.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/contrat/class/api_contracts.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'], - 'htdocs/contrat/messaging.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/contrat/services_list.php' => ['PhanEmptyForeach', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/core/actions_addupdatedelete.inc.php' => ['PhanPluginBothLiteralsBinaryOp', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], - 'htdocs/core/actions_comments.inc.php' => ['PhanUndeclaredGlobalVariable'], - 'htdocs/core/actions_lineupdown.inc.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable'], - 'htdocs/core/actions_linkedfiles.inc.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable'], - 'htdocs/core/actions_massactions.inc.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], + 'htdocs/core/actions_addupdatedelete.inc.php' => ['PhanTypeMismatchDimFetch', 'PhanUndeclaredProperty'], + 'htdocs/core/actions_massactions.inc.php' => ['PhanUndeclaredProperty'], 'htdocs/core/actions_printing.inc.php' => ['PhanUndeclaredProperty'], 'htdocs/core/actions_sendmails.inc.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], - 'htdocs/core/actions_setmoduleoptions.inc.php' => ['PhanPluginUnknownObjectMethodCall'], - 'htdocs/core/ajax/ajaxdirpreview.php' => ['PhanPossiblyUndeclaredGlobalVariable'], - 'htdocs/core/ajax/ajaxdirtree.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchProperty', 'PhanUndeclaredGlobalVariable'], - 'htdocs/core/ajax/selectobject.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/core/ajax/selectsearchbox.php' => ['PhanPluginUndeclaredVariableIsset'], + 'htdocs/core/ajax/ajaxdirtree.php' => ['PhanTypeMismatchProperty', 'PhanUndeclaredGlobalVariable'], 'htdocs/core/boxes/box_actions.php' => ['PhanPossiblyUndeclaredVariable'], 'htdocs/core/boxes/box_actions_future.php' => ['PhanPossiblyUndeclaredVariable'], 'htdocs/core/boxes/box_external_rss.php' => ['PhanPluginUnknownPropertyType'], @@ -263,7 +251,6 @@ return [ 'htdocs/core/modules/workstation/mod_workstation_advanced.php' => ['PhanUndeclaredProperty'], 'htdocs/core/search_page.php' => ['PhanEmptyForeach', 'PhanPluginBothLiteralsBinaryOp'], 'htdocs/core/tpl/ajaxrow.tpl.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanUndeclaredGlobalVariable'], - 'htdocs/core/tpl/bloc_comment.tpl.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/core/tpl/commonfields_view.tpl.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/core/tpl/document_actions_post_headers.tpl.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanUndeclaredGlobalVariable'], 'htdocs/core/tpl/extrafields_edit.tpl.php' => ['PhanPluginUndeclaredVariableIsset'], diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 4cc212f600678..dcf5d5b3248cf 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -106,10 +106,13 @@ $result = restrictedArea($user, 'tax', $object->id, 'tva', 'charges'); +$resteapayer = 0; + /* * Actions */ + $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { @@ -279,6 +282,7 @@ $ret = $object->delete($user); if ($ret > 0) { + $accountline = null; if ($object->fk_bank) { $accountline = new AccountLine($db); $result = $accountline->fetch($object->fk_bank); @@ -292,7 +296,7 @@ header("Location: ".DOL_URL_ROOT.'/compta/tva/list.php'); exit; } else { - $object->error = $accountline->error; + $object->error = $accountline !== null ? $accountline->error : 'No account line (no bank)'; $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php index 32cee3b385ceb..13ffb65097d2f 100644 --- a/htdocs/compta/tva/clients.php +++ b/htdocs/compta/tva/clients.php @@ -269,7 +269,7 @@ $company_static->name = $x_coll[$my_coll_thirdpartyid]['company_name'][$id]; $company_static->name_alias = $x_coll[$my_coll_thirdpartyid]['company_alias'][$id]; $company_static->email = $x_coll[$my_coll_thirdpartyid]['company_email'][$id]; - $company_static->tva_intra = isset($x_coll[$my_coll_thirdpartyid]['tva_intra'][$id]) ? $x_coll[$my_coll_thirdpartyid]['tva_intra'][$id] : '0'; // @phan-suppress-current-line PhanTypeInvalidDimOffset + $company_static->tva_intra = isset($x_coll[$my_coll_thirdpartyid]['tva_intra'][$id]) ? $x_coll[$my_coll_thirdpartyid]['tva_intra'][$id] : '0'; // @phan-suppress-current-line PhanTypeInvalidDimOffset,PhanTypeArraySuspiciousNull $company_static->client = $x_coll[$my_coll_thirdpartyid]['company_client'][$id]; $company_static->fournisseur = $x_coll[$my_coll_thirdpartyid]['company_fournisseur'][$id]; $company_static->status = $x_coll[$my_coll_thirdpartyid]['company_status'][$id]; @@ -285,8 +285,8 @@ 'pid' => $x_coll[$my_coll_thirdpartyid]['pid'][$id], 'pref' => isset($x_coll[$my_coll_thirdpartyid]['pref'][$id]) ? $x_coll[$my_coll_thirdpartyid]['pref'][$id] : '', 'ptype' => $x_coll[$my_coll_thirdpartyid]['ptype'][$id], - 'pstatus' => isset($x_paye[$my_coll_thirdpartyid]['pstatus'][$id]) ? $x_paye[$my_coll_thirdpartyid]['pstatus'][$id] : '', // @phan-suppress-current-line PhanTypeInvalidDimOffset - 'pstatusbuy' => isset($x_paye[$my_coll_thirdpartyid]['pstatusbuy'][$id]) ? $x_paye[$my_coll_thirdpartyid]['pstatusbuy'][$id] : '', // @phan-suppress-current-line PhanTypeInvalidDimOffset + 'pstatus' => isset($x_paye[$my_coll_thirdpartyid]['pstatus'][$id]) ? $x_paye[$my_coll_thirdpartyid]['pstatus'][$id] : '', // @phan-suppress-current-line PhanTypeInvalidDimOffset,PhanTypeArraySuspiciousNull + 'pstatusbuy' => isset($x_paye[$my_coll_thirdpartyid]['pstatusbuy'][$id]) ? $x_paye[$my_coll_thirdpartyid]['pstatusbuy'][$id] : '', // @phan-suppress-current-line PhanTypeInvalidDimOffset,PhanTypeArraySuspiciousNull 'payment_id' => $x_coll[$my_coll_thirdpartyid]['payment_id'][$id], 'payment_ref' => isset($x_coll[$my_coll_thirdpartyid]['payment_ref'][$id]) ? $x_coll[$my_coll_thirdpartyid]['payment_ref'][$id] : '', diff --git a/htdocs/compta/tva/payments.php b/htdocs/compta/tva/payments.php index 969b5e8ea71a5..9384a292aff3f 100644 --- a/htdocs/compta/tva/payments.php +++ b/htdocs/compta/tva/payments.php @@ -67,7 +67,7 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortfield) { +if (empty($sortfield)) { $sortfield = "ptva.datep"; } if (!$sortorder) { diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index 8010396141622..54fee8c2882b5 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -276,7 +276,7 @@ $company_static->name = $x_coll[$my_coll_rate]['company_name'][$id]; $company_static->name_alias = $x_coll[$my_coll_rate]['company_alias'][$id]; $company_static->email = $x_coll[$my_coll_rate]['company_email'][$id]; - $company_static->tva_intra = isset($x_coll[$my_coll_rate]['tva_intra'][$id]) ? $x_coll[$my_coll_rate]['tva_intra'][$id] : '0'; + $company_static->tva_intra = isset($x_coll[$my_coll_rate]['tva_intra'][$id]) ? $x_coll[$my_coll_rate]['tva_intra'][$id] : '0'; // @phan-suppress-current-line PhanTypeArraySuspiciousNull,PhanTypeInvalidDimOffset $company_static->client = $x_coll[$my_coll_rate]['company_client'][$id]; $company_static->fournisseur = $x_coll[$my_coll_rate]['company_fournisseur'][$id]; $company_static->status = $x_coll[$my_coll_rate]['company_status'][$id]; diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 866cb4590581c..e5cb083f5b0cc 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -716,7 +716,7 @@ print ''; } else { print ''; - print img_picto('', 'company', 'class="pictofixedwidth"').$form->select_company($socid, 'socid', '', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300 maxwidth500 widthcentpercentminusxx'); + print img_picto('', 'company', 'class="pictofixedwidth"').$form->select_company($socid, 'socid', '', 'SelectThirdParty', 0, 0, array(), 0, 'minwidth300 maxwidth500 widthcentpercentminusxx'); print ''; } } @@ -888,7 +888,7 @@ // Default language if (getDolGlobalInt('MAIN_MULTILANGS')) { print ''.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).''."\n"; - print img_picto('', 'language', 'class="pictofixedwidth"').$formadmin->select_language(GETPOST('default_lang', 'alpha') ? GETPOST('default_lang', 'alpha') : ($object->default_lang ? $object->default_lang : ''), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone'); + print img_picto('', 'language', 'class="pictofixedwidth"').$formadmin->select_language(GETPOST('default_lang', 'alpha') ? GETPOST('default_lang', 'alpha') : ($object->default_lang ? $object->default_lang : ''), 'default_lang', 0, array(), 1, 0, 0, 'maxwidth200onsmartphone'); print ''; print ''; } @@ -897,7 +897,7 @@ if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) { print ''.$form->editfieldkey('Categories', 'contcats', '', $object, 0).''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_CONTACT, '', 'parent', 64, 0, 3); - print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('contcats', $cate_arbo, GETPOST('contcats', 'array'), null, null, null, null, '90%'); + print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('contcats', $cate_arbo, GETPOST('contcats', 'array'), 0, 0, '', 0, '90%'); print ""; } @@ -1176,7 +1176,7 @@ function init_check_no_email(input) { // Default language if (getDolGlobalInt('MAIN_MULTILANGS')) { print ''.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).''."\n"; - print img_picto('', 'language', 'class="pictofixedwidth"').$formadmin->select_language(GETPOST('default_lang', 'alpha') ? GETPOST('default_lang', 'alpha') : ($object->default_lang ? $object->default_lang : ''), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone'); + print img_picto('', 'language', 'class="pictofixedwidth"').$formadmin->select_language(GETPOST('default_lang', 'alpha') ? GETPOST('default_lang', 'alpha') : ($object->default_lang ? $object->default_lang : ''), 'default_lang', 0, array(), 1, 0, 0, 'maxwidth200onsmartphone'); print ''; print ''; } @@ -1210,7 +1210,7 @@ function init_check_no_email(input) { foreach ($cats as $cat) { $arrayselected[] = $cat->id; } - print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('contcats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%'); + print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('contcats', $cate_arbo, $arrayselected, 0, 0, '', 0, '90%'); print ""; } diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index 0515698a68566..72eedc7bbe566 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -6,6 +6,7 @@ * Copyright (C) 2015-2017 Ferran Marcet * Copyright (C) 2024 Alexandre Spangaro * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * 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 @@ -212,7 +213,13 @@ print '
'; print ''; +$documentstatic = null; +$documentstaticline = null; $sql_select = ''; +$doc_number = ''; +$dateprint = ''; +$tables_from = ''; +$where = ''; if ($type_element == 'fichinter') { // Customer : show products from invoices require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; $documentstatic = new Fichinter($db); @@ -318,6 +325,8 @@ } $parameters = array(); +$totalnboflines = 0; +$sql = ''; $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook if (!empty($sql_select)) { @@ -343,7 +352,7 @@ // if ($type_element != 'fichinter') $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON d.fk_product = p.rowid '; $sql .= $where; $sql .= dolSqlDateFilter($dateprint, 0, $month, $year); - if ($sref) { + if ($sref && !empty($doc_number)) { $sql .= " AND ".$doc_number." LIKE '%".$db->escape($sref)."%'"; } if ($sprod_fulldescr) { @@ -386,7 +395,7 @@ $total_qty = 0; $num = 0; -if ($sql_select) { +if ($sql_select && $documentstatic !== null) { $resql = $db->query($sql); if (!$resql) { dol_print_error($db); @@ -584,7 +593,7 @@ } } else { if ($objp->fk_product > 0) { - echo $form->textwithtooltip($text, $description, 3, '', '', $i, 0, ''); + echo $form->textwithtooltip($text, $description, 3, 0, '', $i, 0, ''); // Show range echo get_date_range($objp->date_start, $objp->date_end); @@ -603,7 +612,7 @@ if (!empty($objp->label)) { $text .= ' '.$objp->label.''; - echo $form->textwithtooltip($text, dol_htmlentitiesbr($objp->description), 3, '', '', $i, 0, ''); + echo $form->textwithtooltip($text, dol_htmlentitiesbr($objp->description), 3, 0, '', $i, 0, ''); } else { echo $text.' '.dol_htmlentitiesbr($objp->description); } diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php index 4bc907f6c1553..9316a38927b74 100644 --- a/htdocs/contact/perso.php +++ b/htdocs/contact/perso.php @@ -75,7 +75,7 @@ $result = $object->update_perso($id, $user); if ($result > 0) { - $object->oldcopy = dol_clone($object, 2); + $object->oldcopy = dol_clone($object, 2); // @phan-suppres-current-line PhanTypeMismatchProperty // Logo/Photo save $dir = $conf->societe->dir_output.'/contact/'.get_exdir($object->id, 0, 0, 1, $object, 'contact').'/photos'; diff --git a/htdocs/contrat/agenda.php b/htdocs/contrat/agenda.php index a372c40d4ae33..031456f31ebab 100644 --- a/htdocs/contrat/agenda.php +++ b/htdocs/contrat/agenda.php @@ -3,6 +3,7 @@ * Copyright (C) 2017 Ferran Marcet * Copyright (C) 2024 Alexandre Spangaro * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * 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 @@ -181,7 +182,7 @@ $morehtmlref .= $object->ref; } else { $morehtmlref .= $form->editfieldkey("", 'ref', $object->ref, $object, $user->hasRight('contrat', 'creer'), 'string', '', 0, 3); - $morehtmlref .= $form->editfieldval("", 'ref', $object->ref, $object, $user->hasRight('contrat', 'creer'), 'string', '', 0, 2); + $morehtmlref .= $form->editfieldval("", 'ref', $object->ref, $object, $user->hasRight('contrat', 'creer'), 'string', null, 0, 2); } $permtoedit = 0; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 1083fa5d1555c..86a46a1919aec 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -795,7 +795,7 @@ if (GETPOST('buying_price')) { $pa_ht = price2num(GETPOST('buying_price'), '', 2); } else { - $pa_ht = null; + $pa_ht = 0; } $fk_unit = GETPOSTINT('unit'); @@ -811,9 +811,9 @@ $objectline->fk_product = GETPOSTINT('idprod'); $objectline->description = GETPOST('product_desc', 'restricthtml'); - $objectline->price_ht = $price_ht; - $objectline->subprice = price2num(GETPOST('elprice'), 'MU'); - $objectline->qty = price2num(GETPOST('elqty'), 'MS'); + $objectline->price_ht = (float) $price_ht; + $objectline->subprice = (float) price2num(GETPOST('elprice'), 'MU'); + $objectline->qty = (float) price2num(GETPOST('elqty'), 'MS'); $objectline->remise_percent = $remise_percent; $objectline->tva_tx = ($txtva ? $txtva : 0); // Field may be disabled, so we use vat rate 0 $objectline->vat_src_code = $vat_src_code; diff --git a/htdocs/contrat/messaging.php b/htdocs/contrat/messaging.php index aced39823b50d..879f1aaddf551 100644 --- a/htdocs/contrat/messaging.php +++ b/htdocs/contrat/messaging.php @@ -8,6 +8,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2024 Alexandre Spangaro * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * 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 @@ -177,7 +178,7 @@ $morehtmlref .= $object->ref; } else { $morehtmlref .= $form->editfieldkey("", 'ref', $object->ref, $object, $user->hasRight('contrat', 'creer'), 'string', '', 0, 3); - $morehtmlref .= $form->editfieldval("", 'ref', $object->ref, $object, $user->hasRight('contrat', 'creer'), 'string', '', 0, 2); + $morehtmlref .= $form->editfieldval("", 'ref', $object->ref, $object, $user->hasRight('contrat', 'creer'), 'string', '', null, 2); } $permtoedit = 0; diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index cb3ec8f7c4447..fb32ec1747e59 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -555,7 +555,7 @@ if (!empty($sall)) { $fieldstosearchall = array(); - foreach ($fieldstosearchall as $key => $val) { + foreach ($fieldstosearchall as $key => $val) { // @phan-suppress-current-line PhanEmptyForeach $fieldstosearchall[$key] = $langs->trans($val); } print '
'.$langs->trans("FilterOnInto", $sall).implode(', ', $fieldstosearchall).'
'; @@ -569,7 +569,7 @@ include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; $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, 'widthcentpercentminusx maxwidth300', 1); $moreforfilter .= '
'; } diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 3df9395845309..a9a51bf849a04 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -416,7 +416,7 @@ if ($action == "update_extras" && GETPOSTINT('id') > 0 && !empty($permissiontoadd)) { $object->fetch(GETPOSTINT('id')); - $object->oldcopy = dol_clone($object, 2); + $object->oldcopy = dol_clone($object, 2); // @phan-suppress-current-line PhanTypeMismatchProperty $attribute = GETPOST('attribute', 'alphanohtml'); @@ -644,6 +644,7 @@ // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes' && !empty($permissiontoadd)) { + // @phan-suppress-next-line PhanPluginBothLiteralsBinaryOp if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } else { diff --git a/htdocs/core/actions_comments.inc.php b/htdocs/core/actions_comments.inc.php index 19c79357081e5..fbbe2955d5d8d 100644 --- a/htdocs/core/actions_comments.inc.php +++ b/htdocs/core/actions_comments.inc.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * 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 @@ -32,6 +33,12 @@ * @var string $contextpage */ +// Next should be define in the including php source file +' +@phan-var-force int $withproject +@phan-var-force int $idcomment +'; + require_once DOL_DOCUMENT_ROOT.'/core/class/comment.class.php'; $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; diff --git a/htdocs/core/actions_lineupdown.inc.php b/htdocs/core/actions_lineupdown.inc.php index 4e99c6c3661b0..a787ea604dd8a 100644 --- a/htdocs/core/actions_lineupdown.inc.php +++ b/htdocs/core/actions_lineupdown.inc.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * 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 @@ -27,7 +28,11 @@ // $permissiontoedit must be defined to permission to edit object // $object must be defined // $langs must be defined -// $hidedetails, $hidedesc, $hideref must de defined +// $hidedetails, $hidedesc, $hideref must defined +' +@phan-var-force bool $permissiontoedit +@phan-var-force CommonObject $object +'; /** * @var CommonObject $object * @var Conf $conf diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index fd2757c3f1df1..9c77041439d92 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -3,6 +3,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Ferran Marcet * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * 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 @@ -37,6 +38,10 @@ * @var string $confirm * @var string $forceFullTextIndexation */ +' +@phan-var-force string $upload_dir +@phan-var-force string $forceFullTextIndexation +'; // Protection to understand what happen when submitting files larger than post_max_size if (GETPOSTINT('uploadform') && empty($_POST) && empty($_FILES)) { diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 77e8bcf52408b..812c21a739efd 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -923,6 +923,7 @@ $pdf->SetCompression(false); } + $pagecount = 0; // Add all others foreach ($files as $file) { // Charge un document PDF depuis un fichier. @@ -1924,7 +1925,7 @@ } if (empty($toselect)) { - $toselect=[]; + $toselect = []; } $parameters['toselect'] = &$toselect; $parameters['uploaddir'] = $uploaddir; diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index f6f812d86b020..ebad90e357993 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -138,10 +138,11 @@ $langs->load('mails'); + $sendtosocid = 0; // Id of related thirdparty + if (is_object($object)) { $result = $object->fetch($id); - $sendtosocid = 0; // Id of related thirdparty if (method_exists($object, "fetch_thirdparty") && !in_array($object->element, array('member', 'user', 'expensereport', 'societe', 'contact'))) { $resultthirdparty = $object->fetch_thirdparty(); $thirdparty = $object->thirdparty; @@ -436,7 +437,7 @@ // Call of triggers (you should have set $triggersendname to execute trigger. $trigger_name is deprecated) if (!empty($triggersendname) || !empty($trigger_name)) { // Call trigger - $result = $object->call_trigger(empty($triggersendname) ? $trigger_name : $triggersendname, $user); + $result = $object->call_trigger(empty($triggersendname) ? $trigger_name : $triggersendname, $user); // @phan-suppress-current-line PhanPossiblyUndeclaredGlobalVariable if ($result < 0) { $error++; } @@ -454,7 +455,8 @@ setEventMessages($mesg, null, 'mesgs'); $moreparam = ''; - if (isset($paramval2)) { + if (isset($paramval2)) { // @phan-var-suppress-current-line PhanPluginUndeclaredVariableIsset + // @phan-var-suppress-next-line PhanUndeclaredGlobalVariable $moreparam .= '&'.($paramname2 ? $paramname2 : 'mid').'='.$paramval2; } header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname ?? 'id').'='.(is_object($object) ? $object->id : '').$moreparam); diff --git a/htdocs/core/actions_setmoduleoptions.inc.php b/htdocs/core/actions_setmoduleoptions.inc.php index 3d1725e4a46d5..8439660f6c86d 100644 --- a/htdocs/core/actions_setmoduleoptions.inc.php +++ b/htdocs/core/actions_setmoduleoptions.inc.php @@ -41,15 +41,15 @@ * @var ?int $nomessageinsetmoduleoptions */ +' +@phan-var-force FormSetup $formSetup +'; + if ($action == 'update' && !empty($formSetup) && is_object($formSetup) && !empty($user->admin)) { $formSetup->saveConfFromPost(); return; } -' -@phan-var-force FormSetup $formSetup -'; - $upload_dir = null; if ($action == 'update' && !empty($arrayofparameters) && is_array($arrayofparameters) && !empty($user->admin)) { diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index ec7c39aecf6f9..51f053c9eda73 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -67,6 +67,8 @@ $sortfield = GETPOST("sortfield", 'aZ09comma'); $sortorder = GETPOST("sortorder", 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); + $showonrightsize = ''; + if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 diff --git a/htdocs/core/ajax/ajaxdirtree.php b/htdocs/core/ajax/ajaxdirtree.php index 330f398feed83..2c4bca52883d4 100644 --- a/htdocs/core/ajax/ajaxdirtree.php +++ b/htdocs/core/ajax/ajaxdirtree.php @@ -90,6 +90,7 @@ // Define fullpathselecteddir. $fullpathselecteddir = ''; +$fullpathpreopened = ''; if ($modulepart == 'ecm') { $fullpathselecteddir = $conf->ecm->dir_output.'/'.($selecteddir != '/' ? $selecteddir : ''); $fullpathpreopened = $conf->ecm->dir_output.'/'.($preopened != '/' ? $preopened : ''); @@ -367,7 +368,7 @@ /** * treeOutputForAbsoluteDir * - * @param array $sqltree Sqltree + * @param array $sqltree Sqltree * @param string $selecteddir Selected dir * @param string $fullpathselecteddir Full path of selected dir * @param string $modulepart Modulepart diff --git a/htdocs/core/ajax/selectobject.php b/htdocs/core/ajax/selectobject.php index 735c14c7a0304..f7d12c6477e23 100644 --- a/htdocs/core/ajax/selectobject.php +++ b/htdocs/core/ajax/selectobject.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * 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 @@ -91,6 +92,7 @@ } } +$objecttmp = null; if ($objectdesc) { // Example of value for $objectdesc: // Bom:bom/class/bom.class.php:0:t.status=1 @@ -145,10 +147,10 @@ $searchkey = (($id && GETPOST((string) $id, 'alpha')) ? GETPOST((string) $id, 'alpha') : (($htmlname && GETPOST($htmlname, 'alpha')) ? GETPOST($htmlname, 'alpha') : '')); // Add a security test to avoid to get content of all tables -if (!empty($objecttmp->module)) { +if ($objecttmp !== null && !empty($objecttmp->module)) { restrictedArea($user, $objecttmp->module, $id, $objecttmp->table_element, $objecttmp->element); } else { - restrictedArea($user, $objecttmp->element, $id); + restrictedArea($user, $objecttmp !== null ? $objecttmp->element : '', $id); } @@ -162,7 +164,7 @@ //print ''."\n"; -$arrayresult = $form->selectForFormsList($objecttmp, $htmlname, '', 0, $searchkey, '', '', '', 0, 1, 0, '', $filter); +$arrayresult = $form->selectForFormsList($objecttmp, $htmlname, 0, 0, $searchkey, '', '', '', 0, 1, 0, '', $filter); $db->close(); diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index 7b35d487bb383..366b2efdc199c 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * 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 @@ -30,6 +31,7 @@ * @var Translate $langs * @var User $user */ +'@phan-var-force ?int<0,1> $usedbyinclude'; if (!isset($usedbyinclude) || empty($usedbyinclude)) { if (!defined('NOTOKENRENEWAL')) { @@ -127,7 +129,7 @@ $arrayresult['searchintosupplierorder'] = array('position' => 110, 'img' => 'object_supplier_order', 'label' => $langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'text' => img_picto('', 'object_supplier_order', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'url' => DOL_URL_ROOT.'/fourn/commande/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); } if (isModEnabled('reception') && !getDolGlobalString('MAIN_SEARCHFORM_SUPPLIER_RECEPTION_DISABLED') && $user->hasRight('reception', 'lire')) { - $arrayresult['searchintoreception'] = array('position'=>115, 'img'=>'object_reception', 'label'=>$langs->trans("SearchIntoSupplierReceptions", $search_boxvalue), 'text'=>img_picto('', 'object_reception', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoSupplierReceptions", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/reception/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); + $arrayresult['searchintoreception'] = array('position' => 115, 'img' => 'object_reception', 'label' => $langs->trans("SearchIntoSupplierReceptions", $search_boxvalue), 'text' => img_picto('', 'object_reception', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoSupplierReceptions", $search_boxvalue), 'url' => DOL_URL_ROOT.'/reception/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); } if (((isModEnabled('fournisseur') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight('fournisseur', 'facture', 'lire')) || (isModEnabled('supplier_invoice') && $user->hasRight('supplier_invoice', 'lire'))) && !getDolGlobalString('MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED')) { $arrayresult['searchintosupplierinvoice'] = array('position' => 120, 'img' => 'object_supplier_invoice', 'label' => $langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'text' => img_picto('', 'object_supplier_invoice', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'url' => DOL_URL_ROOT.'/fourn/facture/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : ''));