Skip to content

Commit

Permalink
Qual: Fix phan notices
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeweerd committed Oct 1, 2024
1 parent 6a1ad2c commit 99f5ea7
Show file tree
Hide file tree
Showing 23 changed files with 376 additions and 116 deletions.
1 change: 1 addition & 0 deletions dev/tools/codespell/codespell-dict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ thoose->those
# fiche->card
nempty->an empty, empty, not empty,
mot de passe->password
multicurreny->multicurrency
not de passe->password
nothtml->nohtml
shippin->shipping
Expand Down
39 changes: 18 additions & 21 deletions dev/tools/phan/baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
*/
return [
// # Issue statistics:
// PhanPluginUnknownPropertyType : 1290+ occurrences
// PhanPluginUnknownPropertyType : 1210+ occurrences
// PhanUndeclaredProperty : 840+ occurrences
// PhanPossiblyUndeclaredGlobalVariable : 690+ occurrences
// PhanPossiblyUndeclaredGlobalVariable : 680+ occurrences
// PhanTypeMismatchArgumentProbablyReal : 560+ occurrences
// PhanPluginUnknownArrayMethodReturnType : 420+ occurrences
// PhanUndeclaredGlobalVariable : 420+ occurrences
// PhanPluginUnknownArrayMethodParamType : 330+ occurrences
// PhanPluginUnknownArrayMethodParamType : 320+ occurrences
// PhanPossiblyUndeclaredVariable : 280+ occurrences
// PhanTypeMismatchProperty : 190+ occurrences
// PhanPluginUnknownArrayFunctionParamType : 140+ occurrences
// PhanPluginUnknownArrayFunctionReturnType : 140+ occurrences
// PhanPluginUnknownObjectMethodCall : 95+ occurrences
// PhanPluginUnknownObjectMethodCall : 80+ occurrences
// PhanTypeMismatchArgumentNullableInternal : 80+ occurrences
// PhanPluginUnknownArrayPropertyType : 70+ occurrences
// PhanPluginUndeclaredVariableIsset : 65+ occurrences
Expand Down Expand Up @@ -426,7 +426,6 @@ return [
'htdocs/core/modules/hrm/mod_evaluation_advanced.php' => ['PhanUndeclaredProperty'],
'htdocs/core/modules/import/import_csv.modules.php' => ['PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty'],
'htdocs/core/modules/import/import_xlsx.modules.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty'],
'htdocs/core/modules/import/modules_import.php' => ['PhanTypeMismatchDimFetch'],
'htdocs/core/modules/mailings/contacts1.modules.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/core/modules/mailings/modules_mailings.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownArrayPropertyType'],
'htdocs/core/modules/mailings/thirdparties.modules.php' => ['PhanTypeMismatchArgumentProbablyReal'],
Expand Down Expand Up @@ -559,11 +558,11 @@ return [
'htdocs/eventorganization/conferenceorbooth_list.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/eventorganization/conferenceorboothattendee_card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable'],
'htdocs/eventorganization/conferenceorboothattendee_list.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/eventorganization/core/actions_massactions_mail.inc.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredProperty'],
'htdocs/eventorganization/core/actions_massactions_mail.inc.php' => ['PhanUndeclaredProperty'],
'htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'],
'htdocs/expedition/card.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchProperty', 'PhanUndeclaredGlobalVariable'],
'htdocs/expedition/card.php' => ['PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'],
'htdocs/expedition/class/api_shipments.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'],
'htdocs/expedition/class/expedition.class.php' => ['PhanPossiblyUndeclaredVariable', 'PhanUndeclaredProperty'],
'htdocs/expedition/class/expedition.class.php' => ['PhanUndeclaredProperty'],
'htdocs/expedition/class/expeditionlinebatch.class.php' => ['PhanPluginUnknownPropertyType'],
'htdocs/expedition/class/expeditionstats.class.php' => ['PhanPluginUnknownArrayMethodReturnType'],
'htdocs/expedition/contact.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
Expand Down Expand Up @@ -598,7 +597,6 @@ return [
'htdocs/fourn/class/fournisseur.class.php' => ['PhanPluginUnknownArrayMethodReturnType'],
'htdocs/fourn/class/fournisseur.commande.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredProperty'],
'htdocs/fourn/class/fournisseur.facture-rec.class.php' => ['PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'],
'htdocs/fourn/class/fournisseur.product.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchProperty'],
'htdocs/fourn/class/paiementfourn.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType', 'PhanPossiblyNullTypeMismatchProperty', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/fourn/commande/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'],
'htdocs/fourn/commande/contact.php' => ['PhanUndeclaredGlobalVariable'],
Expand All @@ -614,7 +612,7 @@ return [
'htdocs/fourn/facture/list-rec.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/fourn/facture/list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/fourn/facture/paiement.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable'],
'htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanUndeclaredProperty'],
'htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php' => ['PhanUndeclaredProperty'],
'htdocs/fourn/paiement/card.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/fourn/paiement/document.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/fourn/product/list.php' => ['PhanUndeclaredGlobalVariable'],
Expand All @@ -625,28 +623,27 @@ return [
'htdocs/holiday/list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable'],
'htdocs/holiday/view_log.php' => ['PhanTypeMismatchDimFetch'],
'htdocs/hrm/admin/admin_hrm.php' => ['PhanEmptyForeach', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/hrm/class/evaluation.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'],
'htdocs/hrm/class/evaluationdet.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'],
'htdocs/hrm/class/job.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyNullTypeMismatchProperty', 'PhanUndeclaredProperty'],
'htdocs/hrm/class/position.class.php' => ['PhanPluginEmptyStatementIf', 'PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyNullTypeMismatchProperty', 'PhanUndeclaredProperty'],
'htdocs/hrm/class/skill.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'],
'htdocs/hrm/class/skilldet.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'],
'htdocs/hrm/class/skillrank.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'],
'htdocs/hrm/class/evaluation.class.php' => ['PhanUndeclaredProperty'],
'htdocs/hrm/class/evaluationdet.class.php' => ['PhanUndeclaredProperty'],
'htdocs/hrm/class/job.class.php' => ['PhanUndeclaredProperty'],
'htdocs/hrm/class/position.class.php' => ['PhanUndeclaredProperty'],
'htdocs/hrm/class/skill.class.php' => ['PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'],
'htdocs/hrm/class/skilldet.class.php' => ['PhanUndeclaredProperty'],
'htdocs/hrm/class/skillrank.class.php' => ['PhanUndeclaredProperty'],
'htdocs/hrm/compare.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType'],
'htdocs/hrm/core/tpl/objectline_view.tpl.php' => ['PhanPluginEmptyStatementIf', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredProperty'],
'htdocs/hrm/evaluation_card.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/hrm/evaluation_card.php' => ['PhanPluginUnknownObjectMethodCall'],
'htdocs/hrm/evaluation_list.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/hrm/index.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/hrm/job_agenda.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/hrm/job_card.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'],
'htdocs/hrm/job_card.php' => ['PhanUndeclaredGlobalVariable'],
'htdocs/hrm/job_list.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/hrm/lib/hrm.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'],
'htdocs/hrm/lib/hrm_job.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'],
'htdocs/hrm/lib/hrm_position.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'],
'htdocs/hrm/lib/hrm_skill.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'],
'htdocs/hrm/lib/hrm_skilldet.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'],
'htdocs/hrm/lib/hrm_skillrank.lib.php' => ['PhanPluginUnknownArrayFunctionReturnType'],
'htdocs/hrm/position_card.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/hrm/position_list.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty'],
'htdocs/hrm/skill_card.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'],
'htdocs/hrm/skill_list.php' => ['PhanTypeMismatchArgumentProbablyReal'],
Expand Down Expand Up @@ -974,7 +971,7 @@ return [
'htdocs/webportal/class/controller.class.php' => ['PhanPluginUnknownArrayMethodParamType'],
'htdocs/webportal/class/html.formcardwebportal.class.php' => ['PhanUndeclaredProperty'],
'htdocs/webportal/class/html.formlistwebportal.class.php' => ['PhanPluginUnknownArrayPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/webportal/class/html.formwebportal.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanTypeInvalidDimOffset', 'PhanTypeMismatchDimFetch'],
'htdocs/webportal/class/html.formwebportal.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownObjectMethodCall', 'PhanTypeInvalidDimOffset', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchReturnNullable'],
'htdocs/webportal/class/webportalinvoice.class.php' => ['PhanPluginUnknownPropertyType'],
'htdocs/webportal/class/webportalmember.class.php' => ['PhanPluginUnknownPropertyType'],
'htdocs/webportal/class/webportalpropal.class.php' => ['PhanUndeclaredProperty'],
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
2 changes: 1 addition & 1 deletion 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
2 changes: 1 addition & 1 deletion htdocs/core/modules/import/modules_import.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ public function listOfAvailableImportFormat($db, $maxfilenamelength = 0)
/**
* Return picto of import driver
*
* @param int $key Key
* @param string $key Key
* @return string
*/
public function getPictoForKey($key)
Expand Down
12 changes: 8 additions & 4 deletions htdocs/eventorganization/core/actions_massactions_mail.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
if (!$error && $massaction == 'confirm_presend_attendees' && !GETPOST('sendmail')) { // If we do not choose button send (for example when we change template or limit), we must not send email, but keep on send email form
$massaction = 'presend_attendees';
}

if (!$error && $massaction == 'confirm_presend_attendees') {
$resaction = '';
$nbsent = 0;
Expand All @@ -78,12 +79,13 @@
$listofobjectref = array();
$oneemailperrecipient = (GETPOSTINT('oneemailperrecipient') ? 1 : 0);

$listofselectedid = array();
$listofselectedref = array();
if (!$error) {
require_once DOL_DOCUMENT_ROOT . '/eventorganization/class/conferenceorboothattendee.class.php';
$attendee = new ConferenceOrBoothAttendee($db);
$listofselectedid = array();
$listofselectedref = array();
$objecttmp = new $objectclass($db);
'@phan-var-force CommonObject $objecttmp';

foreach ($toselect as $toselectid) {
$result = $objecttmp->fetch($toselectid);
Expand Down Expand Up @@ -131,7 +133,7 @@
$massaction = 'presend_attendees';
}

if (!$error) {
if (!$error && !empty($listofselectedid)) {
$objecttmp->fetch_thirdparty();
foreach ($listofselectedid as $email => $attendees) {
$sendto = '';
Expand Down Expand Up @@ -192,6 +194,8 @@
// $objecttmp is a real object or an empty object if we choose to send one email per thirdparty instead of one per object
// Make substitution in email content
$substitutionarray = getCommonSubstitutionArray($langs, 0, null, $attendees);
$url_link = null;
$html_link = null;

if (getDolGlobalString('MAIN_AGENDA_XCAL_EXPORTKEY')) {
$urlwithouturlroot = preg_replace('/' . preg_quote(DOL_URL_ROOT, '/') . '$/i', '', trim($dolibarr_main_url_root));
Expand Down Expand Up @@ -279,7 +283,7 @@
}
}
}
}
} // foreach ($listofselectedid as $email => $attendees)
}
$resaction .= ($resaction ? '<br>' : $resaction);
$resaction .= '<strong>' . $langs->trans("ResultOfMailSending") . ':</strong><br>' . "\n";
Expand Down
6 changes: 5 additions & 1 deletion htdocs/expedition/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@
$permissiondellink = $user->hasRight('expedition', 'delivery', 'creer'); // Used by the include of actions_dellink.inc.php
$permissiontoadd = $user->hasRight('expedition', 'creer');

$editColspan = 0;
$objectsrc = null;
$typeobject = null;


/*
* Actions
Expand Down Expand Up @@ -249,7 +253,7 @@
// We will loop on each line of the original document to complete the shipping object with various info and quantity to deliver
$classname = ucfirst($object->origin);
$objectsrc = new $classname($db);
'@phan-var-force Facture|Commande $object';
'@phan-var-force Facture|Commande $objectsrc';
$objectsrc->fetch($object->origin_id);

$object->socid = $objectsrc->socid;
Expand Down
28 changes: 18 additions & 10 deletions htdocs/expedition/class/expedition.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,7 @@ public function addline_batch($dbatch, $array_options = [])
global $conf, $langs;

$num = count($this->lines);
$linebatch = null;
if ($dbatch['qty'] > 0 || ($dbatch['qty'] == 0 && getDolGlobalString('SHIPMENT_GETS_ALL_ORDER_PRODUCTS'))) {
$line = new ExpeditionLigne($this->db);
$tab = array();
Expand Down Expand Up @@ -1113,7 +1114,9 @@ public function addline_batch($dbatch, $array_options = [])
//var_dump($linebatch);
}
}
$line->entrepot_id = $linebatch->entrepot_id;
if (is_object($linebatch)) {
$line->entrepot_id = $linebatch->entrepot_id;
}
$line->origin_line_id = $dbatch['ix_l']; // deprecated
$line->fk_elementdet = $dbatch['ix_l'];
$line->qty = $dbatch['qty'];
Expand Down Expand Up @@ -1160,7 +1163,8 @@ public function update($user = null, $notrigger = 0)
if (isset($this->fk_user_author)) {
$this->fk_user_author = (int) $this->fk_user_author;
}
if (isset($this->fk_user_valid)) {
if (isset($this->fk_user_valid)) { // @phan-ignore-current-line PhanUndeclaredProperty
// If set, then accept @phan-ignore-next-line PhanUndeclaredProperty
$this->fk_user_valid = (int) $this->fk_user_valid;
}
if (isset($this->fk_delivery_address)) {
Expand Down Expand Up @@ -1402,12 +1406,14 @@ public function cancel($notrigger = 0, $also_update_stock = false)
if ($this->db->query($sql)) {
if (!empty($this->origin) && $this->origin_id > 0) {
$this->fetch_origin();
if ($this->origin_object->statut == Commande::STATUS_SHIPMENTONPROCESS) { // If order source of shipment is "shipment in progress"
$origin_object = $this->origin_object;
'@phan-var-force Facture|Commande $origin_object';
if ($origin_object->statut == Commande::STATUS_SHIPMENTONPROCESS) { // If order source of shipment is "shipment in progress"
// Check if there is no more shipment. If not, we can move back status of order to "validated" instead of "shipment in progress"
$this->origin_object->loadExpeditions();
$origin_object->loadExpeditions();
//var_dump($this->$origin->expeditions);exit;
if (count($this->origin_object->expeditions) <= 0) {
$this->origin_object->setStatut(Commande::STATUS_VALIDATED);
if (count($origin_object->expeditions) <= 0) {
$origin_object->setStatut(Commande::STATUS_VALIDATED);
}
}
}
Expand Down Expand Up @@ -1603,12 +1609,14 @@ public function delete($user = null, $notrigger = 0, $also_update_stock = false)
if ($this->db->query($sql)) {
if (!empty($this->origin) && $this->origin_id > 0) {
$this->fetch_origin();
if ($this->origin_object->statut == Commande::STATUS_SHIPMENTONPROCESS) { // If order source of shipment is "shipment in progress"
$origin_object = $this->origin_object;
'@phan-var-force Facture|Commande $origin_object';
if ($origin_object->statut == Commande::STATUS_SHIPMENTONPROCESS) { // If order source of shipment is "shipment in progress"
// Check if there is no more shipment. If not, we can move back status of order to "validated" instead of "shipment in progress"
$this->origin_object->loadExpeditions();
$origin_object->loadExpeditions();
//var_dump($this->$origin->expeditions);exit;
if (count($this->origin_object->expeditions) <= 0) {
$this->origin_object->setStatut(Commande::STATUS_VALIDATED);
if (count($origin_object->expeditions) <= 0) {
$origin_object->setStatut(Commande::STATUS_VALIDATED);
}
}
}
Expand Down
Loading

0 comments on commit 99f5ea7

Please sign in to comment.