Skip to content

Commit

Permalink
Qual: Fix phan/phpstan notices in class files (part 1) (#31501)
Browse files Browse the repository at this point in the history
* Ignore phpstan configuration for spelling

* Qual: Fix phan notices in class files
  • Loading branch information
mdeweerd authored Oct 25, 2024
1 parent 213b0e4 commit 0ac5953
Show file tree
Hide file tree
Showing 45 changed files with 481 additions and 226 deletions.
63 changes: 22 additions & 41 deletions dev/tools/phan/baseline.txt

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dev/tools/phan/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@
'simplify_ast' => true,
'analyzed_file_extensions' => ['php','inc'],
'globals_type_map' => [
'_Avery_Labels' => 'array<string,array{name:string,paper-size:string,orientation:string,metric:string,marginLeft:float,marginTop:float,NX:int,NY:int,SpaceX:float,SpaceY:float,width:float,height:float,font-size:float,custom_x:float,custom_y:float}>',
'action' => 'string',
'actioncode' => 'string',
'badgeStatus0' => 'string',
Expand Down
18 changes: 9 additions & 9 deletions htdocs/accountancy/journal/bankjournal.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,12 +400,12 @@

if ($links[$key]['type'] == 'payment') {
$paymentstatic->id = $links[$key]['url_id'];
$paymentstatic->ref = $links[$key]['url_id'];
$paymentstatic->ref = (string) $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' '.$paymentstatic->getNomUrl(2, '', ''); // TODO Do not include list of invoice in tooltip, the dol_string_nohtmltag is ko with this
$tabpay[$obj->rowid]["paymentid"] = $paymentstatic->id;
} elseif ($links[$key]['type'] == 'payment_supplier') {
$paymentsupplierstatic->id = $links[$key]['url_id'];
$paymentsupplierstatic->ref = $links[$key]['url_id'];
$paymentsupplierstatic->ref = (string) $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' '.$paymentsupplierstatic->getNomUrl(2);
$tabpay[$obj->rowid]["paymentsupplierid"] = $paymentsupplierstatic->id;
} elseif ($links[$key]['type'] == 'company') {
Expand Down Expand Up @@ -451,7 +451,7 @@
}
} elseif ($links[$key]['type'] == 'sc') {
$chargestatic->id = $links[$key]['url_id'];
$chargestatic->ref = $links[$key]['url_id'];
$chargestatic->ref = (string) $links[$key]['url_id'];

$tabpay[$obj->rowid]["lib"] .= ' '.$chargestatic->getNomUrl(2);
$reg = array();
Expand Down Expand Up @@ -486,29 +486,29 @@
}
} elseif ($links[$key]['type'] == 'payment_donation') {
$paymentdonstatic->id = $links[$key]['url_id'];
$paymentdonstatic->ref = $links[$key]['url_id'];
$paymentdonstatic->ref = (string) $links[$key]['url_id'];
$paymentdonstatic->fk_donation = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' '.$paymentdonstatic->getNomUrl(2);
$tabpay[$obj->rowid]["paymentdonationid"] = $paymentdonstatic->id;
$tabtp[$obj->rowid][$account_pay_donation] = isset($tabtp[$obj->rowid][$account_pay_donation]) ? $tabtp[$obj->rowid][$account_pay_donation] + $amounttouse : $amounttouse;
} elseif ($links[$key]['type'] == 'member') {
$paymentsubscriptionstatic->id = $links[$key]['url_id'];
$paymentsubscriptionstatic->ref = $links[$key]['url_id'];
$paymentsubscriptionstatic->ref = (string) $links[$key]['url_id'];
$paymentsubscriptionstatic->label = $links[$key]['label'];
$tabpay[$obj->rowid]["lib"] .= ' '.$paymentsubscriptionstatic->getNomUrl(2);
$tabpay[$obj->rowid]["paymentsubscriptionid"] = $paymentsubscriptionstatic->id;
$paymentsubscriptionstatic->fetch($paymentsubscriptionstatic->id);
$tabtp[$obj->rowid][$account_pay_subscription] = isset($tabtp[$obj->rowid][$account_pay_subscription]) ? $tabtp[$obj->rowid][$account_pay_subscription] + $amounttouse : $amounttouse;
} elseif ($links[$key]['type'] == 'payment_vat') { // Payment VAT
$paymentvatstatic->id = $links[$key]['url_id'];
$paymentvatstatic->ref = $links[$key]['url_id'];
$paymentvatstatic->ref = (string) $links[$key]['url_id'];
$paymentvatstatic->label = $links[$key]['label'];
$tabpay[$obj->rowid]["lib"] .= ' '.$paymentvatstatic->getNomUrl(2);
$tabpay[$obj->rowid]["paymentvatid"] = $paymentvatstatic->id;
$tabtp[$obj->rowid][$account_pay_vat] = isset($tabtp[$obj->rowid][$account_pay_vat]) ? $tabtp[$obj->rowid][$account_pay_vat] + $amounttouse : $amounttouse;
} elseif ($links[$key]['type'] == 'payment_salary') {
$paymentsalstatic->id = $links[$key]['url_id'];
$paymentsalstatic->ref = $links[$key]['url_id'];
$paymentsalstatic->ref = (string) $links[$key]['url_id'];
$paymentsalstatic->label = $links[$key]['label'];
$tabpay[$obj->rowid]["lib"] .= ' '.$paymentsalstatic->getNomUrl(2);
$tabpay[$obj->rowid]["paymentsalid"] = $paymentsalstatic->id;
Expand Down Expand Up @@ -556,7 +556,7 @@
$tabpay[$obj->rowid]["paymentexpensereport"] = $paymentexpensereportstatic->id;
} elseif ($links[$key]['type'] == 'payment_various') {
$paymentvariousstatic->id = $links[$key]['url_id'];
$paymentvariousstatic->ref = $links[$key]['url_id'];
$paymentvariousstatic->ref = (string) $links[$key]['url_id'];
$paymentvariousstatic->label = $links[$key]['label'];
$tabpay[$obj->rowid]["lib"] .= ' '.$paymentvariousstatic->getNomUrl(2);
$tabpay[$obj->rowid]["paymentvariousid"] = $paymentvariousstatic->id;
Expand All @@ -567,7 +567,7 @@
$tabtp[$obj->rowid][$account_subledger] = isset($tabtp[$obj->rowid][$account_subledger]) ? $tabtp[$obj->rowid][$account_subledger] + $amounttouse : $amounttouse;
} elseif ($links[$key]['type'] == 'payment_loan') {
$paymentloanstatic->id = $links[$key]['url_id'];
$paymentloanstatic->ref = $links[$key]['url_id'];
$paymentloanstatic->ref = (string) $links[$key]['url_id'];
$paymentloanstatic->fk_loan = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' '.$paymentloanstatic->getNomUrl(2);
$tabpay[$obj->rowid]["paymentloanid"] = $paymentloanstatic->id;
Expand Down
7 changes: 4 additions & 3 deletions htdocs/asset/class/assetaccountancycodes.class.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2021 Open-Dsi <[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 @@ -29,7 +30,7 @@
class AssetAccountancyCodes extends CommonObject
{
/**
* @var array Array with all accountancy codes info by mode.
* @var array<string,array<string,string|array<string,array{label:string,columnbreak?:bool}>>> Array with all accountancy codes info by mode.
* Note : 'economic' mode is mandatory and is the primary accountancy codes
* 'depreciation_asset' and 'depreciation_expense' is mandatory and is used for write depreciation in bookkeeping
*/
Expand Down Expand Up @@ -64,7 +65,7 @@ class AssetAccountancyCodes extends CommonObject
);

/**
* @var array Array with all accountancy codes by mode.
* @var array<string,array<string,string>> Array with all accountancy codes by mode.
*/
public $accountancy_codes = array();

Expand All @@ -81,7 +82,7 @@ public function __construct(DoliDB $db)
/**
* Fill accountancy_codes property of object (using for data sent by forms)
*
* @return array Array of values
* @return array<string,array<string,string>> Array of values
*/
public function setAccountancyCodesFromPost()
{
Expand Down
8 changes: 4 additions & 4 deletions htdocs/asset/class/assetdepreciationoptions.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ class AssetDepreciationOptions extends CommonObject
public $fields = array();

/**
* @var array Array with all deprecation options info by mode.
* Note : economic mode is mandatory and is the primary options
* @var array<string,array{label:string,table:string,fields:array<string,array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int<-2,5>|string,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,2>,disabled?:int<0,1>,arrayofkeyval?:array<int|string,string>,comment?:string,validate?:int<0,1>}>}>
* Note : economic mode is mandatory and is the primary option
*/
public $deprecation_options_fields = array(
'economic' => array(
Expand Down Expand Up @@ -119,7 +119,7 @@ class AssetDepreciationOptions extends CommonObject
public $fk_user_modif;

/**
* @var array Array with all deprecation options by mode.
* @var array<string,array<string,null|int|float|string>> Array with all deprecation options by mode.
*/
public $deprecation_options = array();

Expand Down Expand Up @@ -174,7 +174,7 @@ public function __construct(DoliDB $db)
* Set object infos for a mode
*
* @param string $mode Depreciation mode (economic, accelerated_depreciation, ...)
* @param int $class_type Type (0:asset, 1:asset model)
* @param int<0,1> $class_type Type (0:asset, 1:asset model)
* @param bool $all_field Get all fields
* @return int Return integer <0 if KO, >0 if OK
*/
Expand Down
2 changes: 1 addition & 1 deletion htdocs/asset/class/assetmodel.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ public function fetchLines()
* @param string $filter Filter as an Universal Search string.
* Example: '((client:=:1) OR ((client:>=:2) AND (client:<=:3))) AND (client:!=:8) AND (nom:like:'a%')'
* @param string $filtermode No more used
* @return array|int int <0 if KO, array of pages if OK
* @return AssetModel[]|int int <0 if KO, array of pages if OK
*/
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND')
{
Expand Down
3 changes: 2 additions & 1 deletion htdocs/asset/tpl/depreciation_options_view.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
}
}
// Discard if extrafield is a hidden field on form
if (abs($field_info['visible']) != 1 && abs($field_info['visible']) != 3 && abs($field_info['visible']) != 4 && abs($field_info['visible']) != 5) {
$isVisibleAbs = array_key_exists('visible', $field_info) ? abs((int) $field_info['visible']) : 0;
if (!in_array($isVisibleAbs, array(1, 3, 4, 5))) {
continue;
}
if (array_key_exists('enabled', $field_info) && isset($field_info['enabled']) && !verifCond($field_info['enabled'])) {
Expand Down
4 changes: 3 additions & 1 deletion htdocs/asset/tpl/depreciation_view.tpl.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2021 Open-Dsi <[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 @@ -77,7 +78,8 @@
}
}
// Discard if extrafield is a hidden field on form
if (abs($field_info['visible']) != 1 && abs($field_info['visible']) != 3 && abs($field_info['visible']) != 4 && abs($field_info['visible']) != 5) {
$isVisibleAbs = array_key_exists('visible', $field_info) ? abs((int) $field_info['visible']) : 0;
if (!in_array($isVisibleAbs, array(1, 3, 4, 5))) {
continue;
}
if (array_key_exists('enabled', $field_info) && isset($field_info['enabled']) && !verifCond($field_info['enabled'])) {
Expand Down
6 changes: 3 additions & 3 deletions htdocs/bom/class/bom.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ public function delete(User $user, $notrigger = 1)
* @param ?int $fk_bom_child Id of BOM Child
* @param ?string $import_key Import Key
* @param int $fk_unit Unit
* @param array $array_options extrafields array
* @param array<string,mixed> $array_options extrafields array
* @param ?int $fk_default_workstation Default workstation
* @return int<-3,max> Return integer <0 if KO, Id of created object if OK
*/
Expand Down Expand Up @@ -698,7 +698,7 @@ public function addLine($fk_product, $qty, $qty_frozen = 0, $disable_stock_chang
* @param int<-1,max> $position Position of BOM-Line in BOM-Lines
* @param ?string $import_key Import Key
* @param int $fk_unit Unit of line
* @param array $array_options extrafields array
* @param array<string,mixed> $array_options extrafields array
* @param ?int $fk_default_workstation Default workstation
* @return int<-3,max> Return integer <0 if KO, Id of updated BOM-Line if OK
*/
Expand Down Expand Up @@ -1299,7 +1299,7 @@ public function getLinesArray()
* @param int<0,1> $hidedetails Hide details of lines
* @param int<0,1> $hidedesc Hide description
* @param int<0,1> $hideref Hide ref
* @param null|array $moreparams Array to provide more information
* @param ?array<string,mixed> $moreparams Array to provide more information
* @return int<0,1> 0 if KO, 1 if OK
*/
public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
Expand Down
17 changes: 9 additions & 8 deletions htdocs/comm/action/class/cactioncomm.class.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <[email protected]>
* Copyright (C) 2004-2014 Laurent Destailleur <[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 @@ -55,7 +56,7 @@ class CActionComm

/**
* @var string label
* @deprecated
* @deprecated Use $label
* @see $label
*/
public $libelle;
Expand Down Expand Up @@ -87,7 +88,7 @@ class CActionComm


/**
* @var array Used to return value by some methods
* @var array{id:array<int,string>,code:array<string,string>,all:array<string,array{id:string,label:string,type:string,color:mixed,picto:string}>} Used to return value by some methods
*/
public $liste_array;

Expand Down Expand Up @@ -148,13 +149,13 @@ public function fetch($id)
/**
* Return list of event types: array(id=>label) or array(code=>label)
*
* @param string|int $active 1 or 0 to filter on event state active or not ('' by default = no filter)
* @param string $idorcode 'id' or 'code' or 'all'
* @param string $excludetype Type to exclude ('system' or 'systemauto')
* @param int $onlyautoornot 1=Group all type AC_XXX into 1 line AC_MANUAL. 0=Keep details of type, -1 or -2=Keep details and add a combined line per calendar (Default, Auto, BoothConf, ...)
* @param ''|int<0,1> $active 1 or 0 to filter on event state active or not ('' by default = no filter)
* @param 'id'|'code'|'all' $idorcode 'id' or 'code' or 'all'
* @param string $excludetype Type to exclude ('system' or 'systemauto')
* @param int<-2,1> $onlyautoornot 1=Group all type AC_XXX into 1 line AC_MANUAL. 0=Keep details of type, -1 or -2=Keep details and add a combined line per calendar (Default, Auto, BoothConf, ...)
* @param string $morefilter Add more SQL filter
* @param int $shortlabel 1=Get short label instead of long label
* @return array|int Array of all event types if OK, <0 if KO. Key of array is id or code depending on parameter $idorcode.
* @param int<0,1> $shortlabel 1=Get short label instead of long label
* @return int<-1,-1>|array{id:array<int,string>,code:array<string,string>,all:array<string,array{id:string,label:string,type:string,color:mixed,picto:string}>,AC_OTH_AUTO?:mixed} Array of all event types if OK, <0 if KO. Key of array is id or code depending on parameter $idorcode.
*/
public function liste_array($active = '', $idorcode = 'id', $excludetype = '', $onlyautoornot = 0, $morefilter = '', $shortlabel = 0)
{
Expand Down
Loading

0 comments on commit 0ac5953

Please sign in to comment.