Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qual: Fix phan notices #31212

Merged
merged 4 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dev/tools/codespell/codespell-dict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ maxwidthonspartphone->maxwidthonsmartphone
minwith100->minwidth100
minwith200->minwidth200
mot de passe->password
multicurreny->multicurrency
nempty->an empty, empty, not empty,
nocellnopadding->nocellnopadd
nodrap->nodrag, nodrop,
Expand Down
143 changes: 53 additions & 90 deletions dev/tools/phan/baseline.txt

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions htdocs/comm/propal/class/propaleligne.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ class PropaleLigne extends CommonObjectLine

/**
* Product use lot
* @var string
* @var int
*/
public $product_tobatch;

Expand Down Expand Up @@ -445,7 +445,7 @@ public function fetch($rowid)
/**
* Insert object line propal in database
*
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @param int<0,1> $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int Return integer <0 if KO, >0 if OK
*/
public function insert($notrigger = 0)
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/class/commondocgenerator.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ public function get_substitutionarray_shipment($object, $outputlangs, $array_key
$array_key.'_tracking_number' => $object->tracking_number,
$array_key.'_tracking_url' => $object->tracking_url,
$array_key.'_shipping_method' => $object->listmeths[0]['libelle'],
$array_key.'_weight' => $object->trueWeight.' '.measuringUnitString(0, 'weight', $object->weight_units),
$array_key.'_weight' => $object->trueWeight.' '.measuringUnitString(0, 'weight', (string) $object->weight_units),
$array_key.'_width' => $object->trueWidth.' '.measuringUnitString(0, 'size', $object->width_units),
$array_key.'_height' => $object->trueHeight.' '.measuringUnitString(0, 'size', $object->height_units),
$array_key.'_depth' => $object->trueDepth.' '.measuringUnitString(0, 'size', $object->depth_units),
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/class/commonorder.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ abstract class CommonOrderLine extends CommonObjectLine

/**
* Product use lot
* @var string
* @var int
*/
public $product_tobatch;

Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/class/html.form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -9537,8 +9537,8 @@ public function showLinkedObjectBlock($object, $morehtmlright = '', $compatibleI
* Show block with links "to link to" other objects.
*
* @param CommonObject $object Object we want to show links to
* @param string[] $restrictlinksto Restrict links to some elements, for example array('order') or array('supplier_order'). null or array() if no restriction.
* @param string[] $excludelinksto Do not show links of this type, for example array('order') or array('supplier_order'). null or array() if no exclusion.
* @param string[]|null $restrictlinksto Restrict links to some elements, for example array('order') or array('supplier_order'). null or array() if no restriction.
* @param string[]|null $excludelinksto Do not show links of this type, for example array('order') or array('supplier_order'). null or array() if no exclusion.
* @param int<0,1> $nooutput 1=Return array with content instead of printing it.
* @return array{linktoelem:string,htmltoenteralink:string}|string HTML block
*/
Expand Down
5 changes: 3 additions & 2 deletions htdocs/core/get_info.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2018 Laurent Destailleur <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
*
* This file is a modified version of datepicker.php from phpBSM to fix some
* bugs, to add new features and to dramatically increase speed.
Expand Down Expand Up @@ -111,9 +112,9 @@
$toprightmenu .= '<div class="login_block_user">';

// Login name with photo and tooltip
$mode = -1;
$picto = -1;
$toprightmenu .= '<div class="inline-block nowrap"><div class="inline-block login_block_elem login_block_elem_name" style="padding: 0px;">';
$toprightmenu .= $user->getNomUrl($mode, '', -1, 0, 11, 0, ($user->firstname ? 'firstname' : -1), 'atoplogin');
$toprightmenu .= $user->getNomUrl($picto, '', -1, 0, 11, 0, ($user->firstname ? 'firstname' : -1), 'atoplogin');
$toprightmenu .= '</div></div>';

$toprightmenu .= '</div>'."\n";
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/lib/fichinter.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
/**
* Prepare array with list of tabs
*
* @param Object $object Object related to tabs
* @param CommonObject $object Object related to tabs
* @return array<array{0:string,1:string,2:string}> Array of tabs to show
*/
function fichinter_prepare_head($object)
Expand Down Expand Up @@ -165,7 +165,7 @@ function fichinter_prepare_head($object)
/**
* Return array head with list of tabs to view object information.
*
* @return array head array with tabs
* @return array<array{0:string,1:string,2:string}> head array with tabs
*/
function fichinter_admin_prepare_head()
{
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/lib/functions.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -7614,7 +7614,7 @@ function get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer,
* @param Societe $thirdparty_buyer Thirdparty buyer
* @param int $idprod Id product
* @param int $idprodfournprice Id supplier price for product
* @return float 0 or 1
* @return int<0,1> 0 or 1
* @see get_default_tva(), get_default_localtax()
*/
function get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod = 0, $idprodfournprice = 0)
Expand Down Expand Up @@ -13142,7 +13142,7 @@ function getElementProperties($elementType)
* @param string $element_ref Element ref (Use this or element_id but not both. If id and ref are empty, object with no fetch is returned)
* @param int<0,2> $useCache If you want to store object in cache or get it from cache 0 => no use cache , 1 use cache, 2 force reload cache
* @param int $maxCacheByType Number of object in cache for this element type
* @return int<-1,0>|object object || 0 || <0 if error
* @return int<-1,0>|CommonObject object || 0 || <0 if error
* @see getElementProperties()
*/
function fetchObjectByElement($element_id, $element_type, $element_ref = '', $useCache = 0, $maxCacheByType = 10)
Expand Down
8 changes: 4 additions & 4 deletions htdocs/core/lib/functions2.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -903,20 +903,20 @@ function array2table($data, $tableMarkup = 1, $tableoptions = '', $troptions = '
* @param string $table Table containing field with counter
* @param string $field Field containing already used values of counter
* @param string $where To add a filter on selection (for example to filter on invoice types)
* @param Societe|'' $objsoc The company that own the object we need a counter for
* @param null|Societe|'' $objsoc The company that own the object we need a counter for
* @param int|'' $date Date to use for the {y},{m},{d} tags. is timestamp or '' to use dol_now()
* @param string $mode 'next' for next value or 'last' for last value
* @param bool $bentityon Activate the entity filter. Default is true (for modules not compatible with multicompany)
* @param User $objuser Object user we need data from.
* @param string $forceentity Entity id to force, can be '0' or '1' or '1,2' etc
* @param ?User $objuser Object user we need data from.
* @param ?string $forceentity Entity id to force, can be '0' or '1' or '1,2' etc
* @return string New value (numeric) or error message
*/
function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $date = '', $mode = 'next', $bentityon = true, $objuser = null, $forceentity = null)
{
global $user;

if (!is_object($objsoc)) {
$valueforccc = $objsoc;
$valueforccc = (string) $objsoc;
} elseif ($table == "commande_fournisseur" || $table == "facture_fourn" || $table == "paiementfourn") {
$valueforccc = dol_string_unaccent($objsoc->code_fournisseur);
} else {
Expand Down
10 changes: 6 additions & 4 deletions htdocs/core/lib/pdf.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0,
* @param TCPDF $pdf The PDF factory
* @param Translate $outputlangs Object lang for output
* @param string $paramfreetext Constant name of free text
* @param Societe $fromcompany Object company
* @param ?Societe $fromcompany Object company
* @param int $marge_basse Margin bottom we use for the autobreak
* @param int $marge_gauche Margin left (no more used)
* @param int $page_hauteur Page height
Expand All @@ -1034,8 +1034,10 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_
if (empty($hidefreetext) && getDolGlobalString($paramfreetext)) {
$substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
// More substitution keys
$substitutionarray['__FROM_NAME__'] = $fromcompany->name;
$substitutionarray['__FROM_EMAIL__'] = $fromcompany->email;
if (is_object($fromcompany)) {
$substitutionarray['__FROM_NAME__'] = $fromcompany->name;
$substitutionarray['__FROM_EMAIL__'] = $fromcompany->email;
}
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$newfreetext = make_substitutions(getDolGlobalString($paramfreetext), $substitutionarray, $outputlangs);

Expand All @@ -1054,7 +1056,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_
$line3 = "";
$line4 = "";

if ($showdetails == 1 || $showdetails == 3) {
if (is_object($fromcompany) && in_array($showdetails, array(1, 3))) {
// Company name
if ($fromcompany->name) {
$line1 .= ($line1 ? " - " : "").$outputlangs->transnoentities("RegisteredOffice").": ".$fromcompany->name;
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/lib/propal.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/**
* Prepare array with list of tabs
*
* @param object $object Object related to tabs
* @param Propal $object Object related to tabs
* @return array<array{0:string,1:string,2:string}> Array of tabs to show
*/
function propal_prepare_head($object)
Expand Down Expand Up @@ -154,7 +154,7 @@ function propal_prepare_head($object)
/**
* Return array head with list of tabs to view object information.
*
* @return array head array with tabs
* @return array<array{0:string,1:string,2:string}> head array with tabs
*/
function propal_admin_prepare_head()
{
Expand Down
19 changes: 11 additions & 8 deletions htdocs/core/lib/security2.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ function dol_getwebuser($mode)
/**
* Return a login if login/pass was successful
*
* @param string $usertotest Login value to test
* @param string $passwordtotest Password value to test
* @param string $entitytotest Instance of data we must check
* @param array $authmode Array list of selected authentication mode array('http', 'dolibarr', 'xxx'...)
* @param string $context Context checkLoginPassEntity was created for ('api', 'dav', 'ws', '')
* @return string Login or '' or '--bad-login-validity--'
* @param string $usertotest Login value to test
* @param string $passwordtotest Password value to test
* @param string $entitytotest Instance of data we must check
* @param string[] $authmode Array list of selected authentication mode array('http', 'dolibarr', 'xxx'...)
* @param 'api'|'dav'|'ws'|'' $context Context checkLoginPassEntity was created for ('api', 'dav', 'ws', '')
* @return string Login or '' or '--bad-login-validity--'
*/
function checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $authmode, $context = '')
{
Expand Down Expand Up @@ -175,6 +175,7 @@ function dol_loginfunction($langs, $conf, $mysoc)
*/

// Select templates dir
$template_dir = '';
if (!empty($conf->modules_parts['tpl'])) { // Using this feature slow down application
$dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl/'));
foreach ($dirtpls as $reldir) {
Expand Down Expand Up @@ -394,6 +395,7 @@ function encodedecode_dbpassconf($level = 0)
$lineofpass = 0;

$reg = array();
$mode = '';
if (preg_match('/^[^#]*dolibarr_main_db_encrypted_pass[\s]*=[\s]*(.*)/i', $buffer, $reg)) { // Old way to save encrypted value
$val = trim($reg[1]); // This also remove CR/LF
$val = preg_replace('/^["\']/', '', $val);
Expand Down Expand Up @@ -479,8 +481,8 @@ function encodedecode_dbpassconf($level = 0)
/**
* Return a generated password using default module
*
* @param boolean $generic true=Create generic password (32 chars/numbers), false=Use the configured password generation module
* @param array $replaceambiguouschars Discard ambiguous characters. For example array('I').
* @param bool $generic true=Create generic password (32 chars/numbers), false=Use the configured password generation module
* @param ?array<string> $replaceambiguouschars Discard ambiguous characters. For example array('I').
* @param int $length Length of random string (Used only if $generic is true)
* @return string New value for password
* @see dol_hash(), dolJSToSetRandomPassword()
Expand Down Expand Up @@ -542,6 +544,7 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len
//print DOL_DOCUMENT_ROOT."/core/modules/security/generate/".$nomclass;
require_once DOL_DOCUMENT_ROOT."/core/modules/security/generate/".$nomfichier;
$genhandler = new $nomclass($db, $conf, $langs, $user);
'@phan-var-force ModeleGenPassword $genhandler';
$generated_password = $genhandler->getNewGeneratedPassword();
unset($genhandler);
}
Expand Down
8 changes: 5 additions & 3 deletions htdocs/core/lib/sendings.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/**
* Prepare array with list of tabs
*
* @param Object $object Object related to tabs
* @param Expedition $object Object related to tabs
* @return array<array{0:string,1:string,2:string}> Array of tabs to show
*/
function shipping_prepare_head($object)
Expand Down Expand Up @@ -320,6 +320,7 @@ function show_list_sending_receive($origin, $origin_id, $filter = '')
// Define output language
if (getDolGlobalInt('MAIN_MULTILANGS') && getDolGlobalString('PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE')) {
$object = new $origin($db);
'@phan-var-force CommonObject $object';
$object->fetch($origin_id);
$object->fetch_thirdparty();

Expand Down Expand Up @@ -356,7 +357,7 @@ function show_list_sending_receive($origin, $origin_id, $filter = '')
$text = $product_static->getNomUrl(1);
$text .= ' - '.$label;
$description = (getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE') ? '' : dol_htmlentitiesbr($objp->description));
print $form->textwithtooltip($text, $description, 3, '', '', $i);
print $form->textwithtooltip($text, $description, 3, 0, '', $i);

// Show range
print_date_range($objp->date_start, $objp->date_end);
Expand All @@ -377,7 +378,7 @@ function show_list_sending_receive($origin, $origin_id, $filter = '')

if (!empty($objp->label)) {
$text .= ' <strong>'.$objp->label.'</strong>';
print $form->textwithtooltip($text, $objp->description, 3, '', '', $i);
print $form->textwithtooltip($text, $objp->description, 3, 0, '', $i);
} else {
print $text.' '.nl2br($objp->description);
}
Expand Down Expand Up @@ -452,6 +453,7 @@ function show_list_sending_receive($origin, $origin_id, $filter = '')
}

if (!empty($receiving)) {
'@phan-var-force Delivery $receiving';
// $expedition->fk_elementdet = id of det line of order
// $receiving->fk_origin_line = id of det line of order
// $receiving->origin may be 'shipping'
Expand Down
10 changes: 5 additions & 5 deletions htdocs/core/lib/supplier_proposal.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
*/

/**
* \file htdocs/core/lib/propal.lib.php
* \brief Ensemble de functions de base pour le module propal
* \ingroup propal
* \file htdocs/core/lib/supplier_proposal.lib.php
* \brief Ensemble de functions de base pour le module supplier_proposal
* \ingroup supplier_proposal
*/

/**
* Prepare array with list of tabs
*
* @param object $object Object related to tabs
* @param SupplierProposal $object Object related to tabs
* @return array<array{0:string,1:string,2:string}> Array of tabs to show
*/
function supplier_proposal_prepare_head($object)
Expand Down Expand Up @@ -108,7 +108,7 @@ function supplier_proposal_prepare_head($object)
/**
* Return array head with list of tabs to view object information.
*
* @return array head array with tabs
* @return array<array{0:string,1:string,2:string}> head array with tabs
*/
function supplier_proposal_admin_prepare_head()
{
Expand Down
14 changes: 12 additions & 2 deletions htdocs/core/modules/expedition/doc/pdf_espadon.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,17 @@ class pdf_espadon extends ModelePdfExpedition
*/
public $version = 'dolibarr';

/**
* @var int|float
*/
public $posxweightvol;
/**
* @var int|float
*/
public $posxqtytoship;
/**
* @var int|float
*/
public $posxqtyordered;


Expand Down Expand Up @@ -865,7 +874,7 @@ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs
$totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs, -1, 'no', 1);
}
if (!empty($object->trueWeight)) {
$totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
$totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, (int) $object->weight_units, "weight", $outputlangs);
}
if (!empty($object->trueVolume)) {
if ($object->volume_units < 50) {
Expand Down Expand Up @@ -967,7 +976,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $
*
* @param TCPDF $pdf Object PDF
* @param Expedition $object Object to show
* @param int $showaddress 0=no, 1=yes
* @param int<0,1> $showaddress 0=no, 1=yes
* @param Translate $outputlangs Object lang for output
* @return float|int Return topshift value
*/
Expand Down Expand Up @@ -1066,6 +1075,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)

$classname = ucfirst($origin);
$linkedobject = new $classname($this->db);
'@phan-var-force Commande|Facture $linkedobject';
$result = $linkedobject->fetch($origin_id);
if ($result >= 0) {
//$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
Expand Down
12 changes: 11 additions & 1 deletion htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,17 @@ class pdf_rouget extends ModelePdfExpedition
*/
public $version = 'dolibarr';

/**
* @var float|int
*/
public $posxweightvol;
/**
* @var float|int
*/
public $posxqtytoship;
/**
* @var float|int
*/
public $posxqtyordered;


Expand Down Expand Up @@ -757,7 +766,7 @@ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs
$totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs, -1, 'no', 1);
}
if (!empty($object->trueWeight)) {
$totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
$totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, (int) $object->weight_units, "weight", $outputlangs);
}
if (!empty($object->trueVolume)) {
$totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
Expand Down Expand Up @@ -999,6 +1008,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)

$classname = ucfirst($origin);
$linkedobject = new $classname($this->db);
'@phan-var-force Commande|Facture $linkedobject';
$result = $linkedobject->fetch($origin_id);
if ($result >= 0) {
//$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede
}

// Fetch info for linked propal
$object->fetchObjectLinked('', '', '', '');
$object->fetchObjectLinked(0, '', null, '');
//print_r($object->linkedObjects['propal']); exit;

$propal_object = null;
Expand Down
Loading
Loading