Skip to content

Commit

Permalink
Qual: Fix phpdoc for *ArrayMethod* args/return values (non api_)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeweerd committed Nov 7, 2024
1 parent 7c5c08f commit 596efab
Show file tree
Hide file tree
Showing 27 changed files with 132 additions and 127 deletions.
34 changes: 13 additions & 21 deletions dev/tools/phan/baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ return [
// PhanPossiblyUndeclaredGlobalVariable : 520+ occurrences
// PhanUndeclaredGlobalVariable : 350+ occurrences
// PhanTypeMismatchArgumentProbablyReal : 320+ occurrences
// PhanPluginUnknownArrayMethodReturnType : 210+ occurrences
// PhanPluginUnknownArrayMethodReturnType : 180+ occurrences
// PhanTypeMismatchProperty : 160+ occurrences
// PhanPluginUnknownArrayMethodParamType : 130+ occurrences
// PhanPluginUnknownPropertyType : 130+ occurrences
// PhanPluginUnknownArrayMethodParamType : 120+ occurrences
// PhanPossiblyUndeclaredVariable : 110+ occurrences
// PhanPluginUndeclaredVariableIsset : 65+ occurrences
// PhanTypeMismatchArgumentNullableInternal : 50+ occurrences
// PhanRedefineFunction : 45+ occurrences
// PhanTypeExpectedObjectPropAccess : 40+ occurrences
// PhanTypeMismatchDimFetch : 40+ occurrences
// PhanPluginEmptyStatementIf : 35+ occurrences
// PhanPluginUnknownArrayFunctionParamType : 35+ occurrences
// PhanPluginUnknownArrayFunctionReturnType : 30+ occurrences
// PhanTypeInvalidDimOffset : 30+ occurrences
// PhanTypeMismatchDimFetch : 30+ occurrences
// PhanUndeclaredConstant : 15+ occurrences
// PhanEmptyForeach : 10+ occurrences
// PhanPluginUnknownObjectMethodCall : 10+ occurrences
Expand All @@ -39,6 +39,7 @@ return [
// PhanPluginDuplicateExpressionBinaryOp : 7 occurrences
// PhanParamTooMany : 5 occurrences
// PhanPossiblyNullTypeMismatchProperty : 5 occurrences
// PhanTypeMismatchReturn : 5 occurrences
// PhanPluginDuplicateArrayKey : 4 occurrences
// PhanEmptyFQSENInClasslike : 3 occurrences
// PhanInvalidFQSENInClasslike : 3 occurrences
Expand All @@ -47,10 +48,7 @@ return [
// PhanTypeMismatchDimAssignment : 2 occurrences
// PhanAccessMethodProtected : 1 occurrence
// PhanParamTooFew : 1 occurrence
// PhanPluginRedundantReturnComment : 1 occurrence
// PhanTypeConversionFromArray : 1 occurrence
// PhanTypeMismatchArgumentReal : 1 occurrence
// PhanTypeMismatchReturn : 1 occurrence
// PhanTypeSuspiciousStringExpression : 1 occurrence

// Currently, file_suppressions and directory_suppressions are the only supported suppressions
Expand Down Expand Up @@ -258,7 +256,7 @@ return [
'htdocs/core/class/notify.class.php' => ['PhanUndeclaredProperty'],
'htdocs/core/class/smtps.class.php' => ['PhanTypeConversionFromArray'],
'htdocs/core/class/timespent.class.php' => ['PhanUndeclaredMethod', 'PhanUndeclaredProperty'],
'htdocs/core/customreports.php' => ['PhanPluginEmptyStatementIf', 'PhanPluginRedundantReturnComment', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetchNullable'],
'htdocs/core/customreports.php' => ['PhanPluginEmptyStatementIf', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetchNullable'],
'htdocs/core/datepicker.php' => ['PhanTypeInvalidDimOffset'],
'htdocs/core/db/sqlite3.class.php' => ['PhanTypeMismatchReturn'],
'htdocs/core/extrafieldsinimport.inc.php' => ['PhanTypeMismatchArgumentNullableInternal'],
Expand Down Expand Up @@ -287,16 +285,15 @@ return [
'htdocs/core/modules/expedition/doc/pdf_merou.modules.php' => ['PhanPluginUnknownPropertyType', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/core/modules/expensereport/doc/pdf_standard_expensereport.modules.php' => ['PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'],
'htdocs/core/modules/facture/doc/pdf_crabe.modules.php' => ['PhanPluginEmptyStatementIf', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/core/modules/facture/doc/pdf_octopus.modules.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'],
'htdocs/core/modules/facture/doc/pdf_sponge.modules.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'],
'htdocs/core/modules/facture/doc/pdf_octopus.modules.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanTypeMismatchReturn', 'PhanUndeclaredProperty'],
'htdocs/core/modules/facture/doc/pdf_sponge.modules.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'],
'htdocs/core/modules/facture/modules_facture.php' => ['PhanPluginUnknownPropertyType'],
'htdocs/core/modules/fichinter/mod_pacific.php' => ['PhanPossiblyUndeclaredVariable'],
'htdocs/core/modules/hrm/doc/pdf_standard_evaluation.modules.php' => ['PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'],
'htdocs/core/modules/hrm/mod_evaluation_advanced.php' => ['PhanUndeclaredProperty'],
'htdocs/core/modules/import/import_csv.modules.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchProperty'],
'htdocs/core/modules/import/import_xlsx.modules.php' => ['PhanTypeMismatchProperty'],
'htdocs/core/modules/mailings/contacts1.modules.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/core/modules/mailings/modules_mailings.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'],
'htdocs/core/modules/mailings/thirdparties.modules.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/core/modules/member/modules_cards.php' => ['PhanPluginUnknownArrayFunctionParamType'],
'htdocs/core/modules/movement/doc/pdf_standard_movementstock.modules.php' => ['PhanPluginDuplicateExpressionBinaryOp', 'PhanPluginEmptyStatementIf', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable'],
Expand All @@ -308,7 +305,7 @@ return [
'htdocs/core/modules/product/doc/pdf_standard.modules.php' => ['PhanPluginEmptyStatementIf', 'PhanPossiblyUndeclaredVariable'],
'htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php' => ['PhanUndeclaredProperty'],
'htdocs/core/modules/project/doc/pdf_timespent.modules.php' => ['PhanUndeclaredProperty'],
'htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable', 'PhanUndeclaredProperty'],
'htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php' => ['PhanPossiblyUndeclaredVariable', 'PhanUndeclaredProperty'],
'htdocs/core/modules/propale/doc/pdf_azur.modules.php' => ['PhanPluginEmptyStatementIf', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/core/modules/propale/doc/pdf_cyan.modules.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'],
'htdocs/core/modules/propale/modules_propale.php' => ['PhanPluginUnknownPropertyType'],
Expand All @@ -330,8 +327,8 @@ return [
'htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php' => ['PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'],
'htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php' => ['PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'],
'htdocs/core/modules/syslog/mod_syslog_file.php' => ['PhanPluginDuplicateArrayKey'],
'htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable'],
'htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable'],
'htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php' => ['PhanPossiblyUndeclaredVariable'],
'htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php' => ['PhanPossiblyUndeclaredVariable'],
'htdocs/core/modules/workstation/mod_workstation_advanced.php' => ['PhanUndeclaredProperty'],
'htdocs/core/search_page.php' => ['PhanEmptyForeach', 'PhanPluginBothLiteralsBinaryOp'],
'htdocs/core/tpl/ajaxrow.tpl.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanUndeclaredGlobalVariable'],
Expand Down Expand Up @@ -362,13 +359,8 @@ return [
'htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php' => ['PhanUndeclaredProperty'],
'htdocs/cron/card.php' => ['PhanPluginBothLiteralsBinaryOp'],
'htdocs/cron/list.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/debugbar/class/DataCollector/DolConfigCollector.php' => ['PhanPluginUnknownArrayMethodReturnType'],
'htdocs/debugbar/class/DataCollector/DolExceptionsCollector.php' => ['PhanPluginUnknownArrayMethodReturnType'],
'htdocs/debugbar/class/DataCollector/DolMemoryCollector.php' => ['PhanPluginUnknownArrayMethodReturnType'],
'htdocs/debugbar/class/DataCollector/DolQueryCollector.php' => ['PhanPluginUnknownArrayMethodReturnType'],
'htdocs/debugbar/class/DataCollector/DolRequestDataCollector.php' => ['PhanPluginUnknownArrayMethodReturnType'],
'htdocs/debugbar/class/DataCollector/DolTimeDataCollector.php' => ['PhanPluginUnknownArrayMethodReturnType'],
'htdocs/debugbar/class/DataCollector/DolibarrCollector.php' => ['PhanPluginUnknownArrayMethodReturnType'],
'htdocs/debugbar/class/DataCollector/DolMemoryCollector.php' => ['PhanTypeMismatchReturn'],
'htdocs/debugbar/class/DataCollector/DolQueryCollector.php' => ['PhanTypeMismatchReturn'],
'htdocs/delivery/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'],
'htdocs/delivery/class/delivery.class.php' => ['PhanUndeclaredProperty'],
'htdocs/delivery/tpl/linkedobjectblock.tpl.php' => ['PhanUndeclaredProperty'],
Expand Down Expand Up @@ -709,7 +701,7 @@ return [
'htdocs/webservices/server_supplier_invoice.php' => ['PhanPluginUnknownArrayFunctionReturnType', 'PhanUndeclaredProperty'],
'htdocs/webservices/server_thirdparty.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'],
'htdocs/webservices/server_user.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanUndeclaredProperty'],
'htdocs/website/class/website.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyNullTypeMismatchProperty', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal'],
'htdocs/website/class/website.class.php' => ['PhanPossiblyNullTypeMismatchProperty', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal'],
'htdocs/website/index.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/website/samples/wrapper.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/website/websiteaccount_card.php' => ['PhanUndeclaredProperty'],
Expand Down
53 changes: 28 additions & 25 deletions htdocs/core/modules/facture/doc/pdf_octopus.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class pdf_octopus extends ModelePDFFactures
public $heightforfooter;

/**
* @var int tab_top
* @var float tab_top
*/
public $tab_top;

Expand Down Expand Up @@ -130,7 +130,7 @@ class pdf_octopus extends ModelePDFFactures
/**
* Situation invoices
*
* @var array{derniere_situation:Facture,date_derniere_situation:int,current:array} Data of situation
* @var array{derniere_situation?:Facture,date_derniere_situation?:int,cumul_anterieur:array{HT:float,TVA:float,TTC:float,retenu_garantie:float,travaux_sup:float,HTnet:float,total_a_payer:float},current:array{HT:float,HTnet:float,TVA:float,TTC:float,retenue_garantie:float,travaux_sup:float,total_a_payer:float,derniere_situation?:Facture,date_derniere_situation:int},nouveau_cumul:array<int|string, array|float|int>} Data of situation
*/
public $TDataSituation;

Expand Down Expand Up @@ -1958,10 +1958,10 @@ public static function liste_modeles($db, $maxfilenamelength = 0)
* @param int $tab_height Height of table (rectangle)
* @param int $nexY Y (not used)
* @param Translate $outputlangs Langs object
* @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
* @param int $hidebottom Hide bottom bar of array
* @param int<-1,1> $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
* @param int<0,1> $hidebottom Hide bottom bar of array
* @param string $currency Currency code
* @param Translate $outputlangsbis Langs object bis
* @param ?Translate $outputlangsbis Langs object bis
* @return void
*/
protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '', $outputlangsbis = null)
Expand Down Expand Up @@ -2052,10 +2052,10 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $
*
* @param TCPDI|TCPDF $pdf Object PDF
* @param Facture $object Object to show
* @param int $showaddress 0=no, 1=yes (usually set to 1 for first page, and 0 for next pages)
* @param int<0,1> $showaddress 0=no, 1=yes (usually set to 1 for first page, and 0 for next pages)
* @param Translate $outputlangs Object lang for output
* @param Translate $outputlangsbis Object lang for output bis
* @return array top shift of linked object lines
* @param ?Translate $outputlangsbis Object lang for output bis
* @return array{top_shift:float,shipp_shift:float} Top shift of linked object lines
*/
protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null)
{
Expand Down Expand Up @@ -2755,8 +2755,8 @@ public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hide
* @param int $tab_height Height of table (rectangle)
* @param int $nexY Y (not used)
* @param Translate $outputlangs Langs object
* @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
* @param int $hidebottom Hide bottom bar of array
* @param int<-1,1> $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
* @param int<0,1> $hidebottom Hide bottom bar of array
* @param string $currency Currency code
* @return void
*/
Expand Down Expand Up @@ -2980,7 +2980,7 @@ public function _tableFirstPage(&$pdf, $tab_top, $tab_height, $nexY, $outputlang
*
* @param Facture $object Facture
*
* @return array
* @return array{derniere_situation?:Facture,date_derniere_situation?:int,cumul_anterieur:array{HT:float,TVA:float,TTC:float,retenu_garantie:float,travaux_sup:float,HTnet:float,total_a_payer:float},current:array{HT:float,HTnet:float,TVA:float,TTC:float,retenue_garantie:float,travaux_sup:float,total_a_payer:float,derniere_situation?:Facture,date_derniere_situation:int},nouveau_cumul:array<int|string, array|float|int>}
*
* Details of returned table
*
Expand Down Expand Up @@ -3101,7 +3101,8 @@ public function getDataSituation(&$object)

foreach ($TDiffKey as $i) {
if (empty($object->lines[$i]->fk_prev_id)) {
$TDataSituation['nouveau_cumul']['travaux_sup'] += $object->lines[$i]->total_ht;
// Next line is useless because 'nouveau_cumul' is overwritten below
// $TDataSituation['nouveau_cumul']['travaux_sup'] += $object->lines[$i]->total_ht;
$TDataSituation['current']['travaux_sup'] += $object->lines[$i]->total_ht;
}
}
Expand All @@ -3116,10 +3117,10 @@ public function getDataSituation(&$object)
/**
* Calculates the sum of two arrays, key by key, taking into account nested arrays
*
* @param array $a [$a description]
* @param array $b [$b description]
* @param array<int|string,int|float|mixed[]> $a [$a description]
* @param array<int|string,int|float|mixed[]> $b [$b description]
*
* @return array [return description]
* @return array<int|string,int|float|mixed[]> [return description]
*/
public function sumSituation($a, $b)
{
Expand Down Expand Up @@ -3231,8 +3232,8 @@ public function getInfosLineLastSituation(&$object, &$current_line)
* @param float $y Ordinate of first point
* @param float $l ??
* @param float $h ??
* @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
* @param int $hidebottom Hide bottom
* @param int<-1,1> $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
* @param int<0,1> $hidebottom Hide bottom
* @return void
*/
/*
Expand All @@ -3257,8 +3258,8 @@ public function printRectBtp(&$pdf, $x, $y, $l, $h, $hidetop = 0, $hidebottom =
* @param float $w Width of the rectangle
* @param float $h Height of the rectangle
* @param float $r Corner radius (can be an array for different radii per corner)
* @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
* @param int $hidebottom Hide bottom
* @param int<-1,1> $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
* @param int<0,1> $hidebottom Hide bottom
* @param string $style Draw style (e.g. 'D' for draw, 'F' for fill, 'DF' for both)
* @return void
*/
Expand All @@ -3279,10 +3280,10 @@ public function printRoundedRectBtp($pdf, $x, $y, $w, $h, $r, $hidetop = 0, $hid
/**
* Get data about invoice
*
* @param int $id invoice id
* @param boolean $forceReadFromDB set to true if you want to force refresh data from SQL
* @param int $id invoice id
* @param bool $forceReadFromDB set to true if you want to force refresh data from SQL
*
* @return array [return description]
* @return array{HT:float,HTnet:float,TVA:float,TTC:float,retenue_garantie:float,travaux_sup:float,total_a_payer:float,derniere_situation?:Facture,date_derniere_situation:int}
*/
public function btpGetInvoiceAmounts($id, $forceReadFromDB = false)
{
Expand Down Expand Up @@ -3346,9 +3347,11 @@ public function btpGetInvoiceAmounts($id, $forceReadFromDB = false)
$ret['retenue_garantie'] = $retenue_garantie;

//Clean up before keep in "cache"
unset($ret['derniere_situation']->db);
unset($ret['derniere_situation']->fields);
unset($ret['derniere_situation']->lines);
if (array_key_exists('derniere_situation', $ret)) {
unset($ret['derniere_situation']->db);
unset($ret['derniere_situation']->fields);
unset($ret['derniere_situation']->lines);
}

// print "<p>Store to cache $id : " . json_encode($_cache_btpProrataGetInvoiceAmounts[$id]) . "</p>";
return $ret;
Expand Down
Loading

0 comments on commit 596efab

Please sign in to comment.