Skip to content

Commit

Permalink
Qual: Fix phan notices (modulebuilder)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeweerd committed Feb 6, 2025
1 parent 0772222 commit acd282a
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 98 deletions.
30 changes: 3 additions & 27 deletions dev/tools/phan/baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
*/
return [
// # Issue statistics:
// PhanTypeMismatchArgument : 2560+ occurrences
// PhanTypeMismatchArgument : 2490+ occurrences
// PhanUndeclaredProperty : 530+ occurrences
// PhanTypeMismatchArgumentNullable : 450+ occurrences
// PhanTypeMismatchArgumentNullable : 430+ occurrences
// PhanUndeclaredGlobalVariable : 190+ occurrences
// PhanPluginUnknownArrayMethodReturnType : 180+ occurrences
// PhanPossiblyUndeclaredGlobalVariable : 160+ occurrences
Expand Down Expand Up @@ -84,7 +84,7 @@ return [
'htdocs/adherents/admin/website.php' => ['PhanTypeMismatchArgument'],
'htdocs/adherents/canvas/actions_adherentcard_common.class.php' => ['PhanTypeMismatchArgument'],
'htdocs/adherents/card.php' => ['PhanTypeMismatchArgument'],
'htdocs/adherents/class/adherent.class.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'],
'htdocs/adherents/class/adherent.class.php' => ['PhanTypeMismatchArgumentNullable'],
'htdocs/adherents/class/adherent_type.class.php' => ['PhanTypeMismatchArgument'],
'htdocs/adherents/class/api_members.class.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'],
'htdocs/adherents/list.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanUndeclaredGlobalVariable'],
Expand Down Expand Up @@ -411,20 +411,16 @@ return [
'htdocs/core/login/functions_dolibarr.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/login/functions_ldap.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'],
'htdocs/core/menus/standard/auguria.lib.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php' => ['PhanTypeMismatchArgumentNullable'],
'htdocs/core/modules/asset/mod_asset_advanced.php' => ['PhanUndeclaredProperty'],
'htdocs/core/modules/barcode/mod_barcode_product_standard.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/modules/bom/mod_bom_advanced.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'],
'htdocs/core/modules/cheque/doc/pdf_blochet.class.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'],
'htdocs/core/modules/cheque/modules_chequereceipts.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/modules/commande/doc/pdf_einstein.modules.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'],
'htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'],
'htdocs/core/modules/commande/mod_commande_saphir.php' => ['PhanTypeMismatchArgumentNullable'],
'htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/modules/contract/doc/pdf_strato.modules.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'],
'htdocs/core/modules/delivery/doc/pdf_storm.modules.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'],
'htdocs/core/modules/delivery/doc/pdf_typhon.modules.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'],
Expand All @@ -435,7 +431,6 @@ return [
'htdocs/core/modules/expedition/doc/pdf_rouget.modules.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'],
'htdocs/core/modules/expensereport/doc/pdf_standard_expensereport.modules.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'],
'htdocs/core/modules/expensereport/mod_expensereport_jade.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/modules/facture/doc/pdf_crabe.modules.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanUndeclaredProperty'],
'htdocs/core/modules/facture/doc/pdf_octopus.modules.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanUndeclaredProperty'],
'htdocs/core/modules/facture/doc/pdf_sponge.modules.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanUndeclaredProperty'],
Expand Down Expand Up @@ -471,38 +466,29 @@ return [
'htdocs/core/modules/modSupplierProposal.class.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/modules/modTicket.class.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/modules/movement/doc/pdf_standard_movementstock.modules.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/modules/mrp/doc/pdf_vinci.modules.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'],
'htdocs/core/modules/mrp/mod_mo_advanced.php' => ['PhanUndeclaredProperty'],
'htdocs/core/modules/oauth/github_oauthcallback.php' => ['PhanUndeclaredGlobalVariable'],
'htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'],
'htdocs/core/modules/project/doc/pdf_beluga.modules.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/modules/project/doc/pdf_timespent.modules.php' => ['PhanUndeclaredProperty'],
'htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'],
'htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/modules/propale/doc/pdf_azur.modules.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanUndeclaredProperty'],
'htdocs/core/modules/propale/doc/pdf_cyan.modules.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanUndeclaredProperty'],
'htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/modules/reception/doc/pdf_squille.modules.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanUndeclaredProperty'],
'htdocs/core/modules/societe/doc/doc_generic_odt.modules.php' => ['PhanTypeMismatchArgumentNullable'],
'htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'],
'htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php' => ['PhanTypeMismatchArgumentNullable'],
'htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php' => ['PhanUndeclaredProperty'],
'htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php' => ['PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchProperty'],
'htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php' => ['PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'],
'htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php' => ['PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'],
'htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php' => ['PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'],
'htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php' => ['PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'],
'htdocs/core/modules/syslog/mod_syslog_file.php' => ['PhanPluginDuplicateArrayKey'],
'htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php' => ['PhanTypeMismatchArgumentNullable'],
'htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/modules/workstation/mod_workstation_advanced.php' => ['PhanUndeclaredProperty'],
'htdocs/core/multicompany_page.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/search_page.php' => ['PhanTypeMismatchArgument'],
Expand Down Expand Up @@ -622,15 +608,6 @@ return [
'htdocs/loan/document.php' => ['PhanUndeclaredProperty'],
'htdocs/loan/note.php' => ['PhanUndeclaredProperty'],
'htdocs/loan/payment/payment.php' => ['PhanUndeclaredProperty'],
'htdocs/modulebuilder/index.php' => ['PhanTypeMismatchArgumentNullable'],
'htdocs/modulebuilder/template/admin/setup.php' => ['PhanTypeMismatchArgument'],
'htdocs/modulebuilder/template/ajax/myobject.php' => ['PhanTypeMismatchArgument'],
'htdocs/modulebuilder/template/class/api_mymodule.class.php' => ['PhanTypeMismatchArgument'],
'htdocs/modulebuilder/template/class/myobject.class.php' => ['PhanTypeMismatchArgument'],
'htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php' => ['PhanTypeMismatchArgument'],
'htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'],
'htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php' => ['PhanTypeMismatchArgument'],
'htdocs/modulebuilder/template/myobject_list.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'],
'htdocs/mrp/ajax/ajax_bom.php' => ['PhanTypeMismatchArgument'],
'htdocs/mrp/class/api_mos.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgument'],
'htdocs/mrp/class/mo.class.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchProperty'],
Expand Down Expand Up @@ -802,7 +779,6 @@ return [
'htdocs/recruitment/class/api_recruitments.class.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'],
'htdocs/recruitment/class/recruitmentcandidature.class.php' => ['PhanUndeclaredProperty'],
'htdocs/recruitment/class/recruitmentjobposition.class.php' => ['PhanUndeclaredProperty'],
'htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php' => ['PhanTypeMismatchArgument'],
'htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php' => ['PhanTypeMismatchArgumentNullable', 'PhanUndeclaredProperty'],
'htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_advanced.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'],
'htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'],
Expand Down
7 changes: 5 additions & 2 deletions htdocs/core/lib/functions.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,7 @@ function checkVal($out = '', $check = 'alphanohtml', $filter = null, $options =
/**
* Return a sanitized or empty value after checking value against a rule.
*
* @param string|array<mixed> $out Value to check/clear.
* @param string|mixed[]|null $out Value to check/clear.
* @param string $check Type of check/sanitizing
* @param ?int $filter Filter to apply when $check is set to 'custom'. (See http://php.net/manual/en/filter.filters.php for détails)
* @param ?mixed $options Options to pass to filter_var when $check is set to 'custom'
Expand All @@ -1217,6 +1217,9 @@ function sanitizeVal($out = '', $check = 'alphanohtml', $filter = null, $options
{
// TODO : use class "Validate" to perform tests (and add missing tests) if needed for factorize
// Check is done after replacement
if ($out === null) {
$out = '';
}
switch ($check) {
case 'none':
case 'password':
Expand Down Expand Up @@ -9895,7 +9898,7 @@ function make_substitutions($text, $substitutionarray, $outputlangs = null, $con
* Complete the $substitutionarray with more entries coming from external module that had set the "substitutions=1" into module_part array.
* In this case, method completesubstitutionarray provided by module is called.
*
* @param array<string,string> $substitutionarray Array substitution old value => new value value
* @param array<string,string|float|null> $substitutionarray Array substitution old value => new value value
* @param Translate $outputlangs Output language
* @param ?CommonObject $object Source object
* @param ?mixed $parameters Add more parameters (useful to pass product lines)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* Copyright (C) 2010-2012 Laurent Destailleur <[email protected]>
* Copyright (C) 2012 Juanjo Menent <[email protected]>
* Copyright (C) 2018-2024 Frédéric France <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
* Copyright (C) 2024-2025 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 @@ -447,7 +447,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede
$reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
foreach ($tmparray as $key => $val) {
try {
if (!is_array($val)) {
if (!is_array($val)) { // @phpstan-ignore-line
$listlines->setVars($key, $val, true, 'UTF-8');
}
} catch (SegmentException $e) {
Expand Down
Loading

0 comments on commit acd282a

Please sign in to comment.