Qual: Fix Phan notices (#38069)

* Qual: Fix Phan notices

# Qual: Fix Phan notices

Fix notices related to PhanUndeclaredProperty

* Qual: Update Phan baseline

* Qual: Fix Phan notice that occurred after merge
This commit is contained in:
MDW 2026-05-10 00:26:46 +02:00 committed by GitHub
parent ef7189dede
commit bfd620b73e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 49 additions and 31 deletions

View file

@ -9,8 +9,8 @@
*/
return [
// # Issue statistics:
// PhanUndeclaredProperty : 390+ occurrences
// PhanUndeclaredGlobalVariable : 50+ occurrences
// PhanUndeclaredProperty : 380+ occurrences
// PhanUndeclaredGlobalVariable : 45+ occurrences
// PhanTypeMismatchArgument : 35+ occurrences
// PhanTypeMismatchProperty : 20+ occurrences
// PhanTypeInvalidDimOffset : 10+ occurrences
@ -38,7 +38,6 @@ return [
'htdocs/commande/list.php' => ['PhanUndeclaredProperty'],
'htdocs/commande/list_det.php' => ['PhanTypeInvalidDimOffset'],
'htdocs/compta/bank/class/account.class.php' => ['PhanUndeclaredProperty'],
'htdocs/compta/bank/line.php' => ['PhanUndeclaredGlobalVariable'],
'htdocs/compta/bank/various_payment/card.php' => ['PhanUndeclaredProperty'],
'htdocs/compta/bank/various_payment/document.php' => ['PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'],
'htdocs/compta/facture/class/facture-rec.class.php' => ['PhanUndeclaredProperty'],
@ -220,7 +219,6 @@ return [
'htdocs/variants/tpl/productattributevalueline_view.tpl.php' => ['PhanUndeclaredProperty'],
'htdocs/webhook/class/target.class.php' => ['PhanUndeclaredMethod'],
'htdocs/webhook/target_card.php' => ['PhanUndeclaredGlobalVariable'],
'htdocs/webportal/class/html.formlistwebportal.class.php' => ['PhanUndeclaredProperty'],
'htdocs/webservices/server_project.php' => ['PhanUndeclaredProperty'],
],
// 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed.

View file

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
*
@ -155,11 +155,13 @@ if (($action == 'send' || $action == 'relance') && !GETPOST('addfile') && !GETPO
$sendtosocid = $thirdparty->id;
}
} elseif ($object->element == 'member' || $object->element == 'user') {
'@phan-var-force Adherent|User $object';
$thirdparty = $object;
if ($object->socid > 0) {
$sendtosocid = $object->socid;
}
} elseif ($object->element == 'expensereport') {
'@phan-var-force ExpenseReport $object';
$tmpuser = new User($db);
$tmpuser->fetch($object->fk_user_author);
$thirdparty = $tmpuser;
@ -167,11 +169,13 @@ if (($action == 'send' || $action == 'relance') && !GETPOST('addfile') && !GETPO
$sendtosocid = $object->socid;
}
} elseif ($object->element == 'societe') {
'@phan-var-force Societe $object';
$thirdparty = $object;
if (is_object($thirdparty) && $thirdparty->id > 0) {
$sendtosocid = $thirdparty->id;
}
} elseif ($object->element == 'contact') {
'@phan-var-force Contact $object';
$contact = $object;
if ($contact->id > 0) {
$contact->fetch_thirdparty();

View file

@ -7,7 +7,7 @@
* Copyright (C) 2018-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2019-2021 Christophe Battarel <christophe@altairis.fr>
* Copyright (C) 2023 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Vincent de Grandpré <vincent@de-grandpre.quebec>
* Copyright (C) 2024 Solution Libre SAS <contact@solution-libre.fr>
* Copyright (C) 2026 Joachim Kueter <git-jk@bloxera.com>
@ -504,6 +504,11 @@ if ($action == 'confirm_generateinvoice' && $user->hasRight('facture', 'creer'))
foreach ($toselect as $key => $value) {
// Get userid, timepent
$object->fetchTimeSpent($value); // $value is ID of 1 line in timespent table
if (!array_key_exists($object->timespent_fk_user, $arrayoftasks)) {
$arrayoftasks[$object->timespent_fk_user] = [
(int) $object->timespent_fk_product => ['timespent' => 0, 'totalvaluetodivideby3600' => 0]
];
}
$arrayoftasks[$object->timespent_fk_user][(int) $object->timespent_fk_product]['timespent'] += $object->timespent_duration;
$arrayoftasks[$object->timespent_fk_user][(int) $object->timespent_fk_product]['totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm);
}
@ -2463,7 +2468,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print '<td class="nowraponall">';
if ($action == 'editline' && GETPOSTINT('lineid') == $task_time->rowid) {
print img_picto('', 'service');
print $form->select_produits($task_time->fk_product, 'fk_product', 1, 0, $projectstatic->thirdparty->price_level, 1, 2, '', 1, array(), $projectstatic->thirdparty->id, 'None', 0, 'maxwidth500', ($user->hasRight('produit', 'lire') ? 0 : 1), '', null, 1);
print $form->select_produits($task_time->fk_product, 'fk_product', 1, 0, $projectstatic->thirdparty->price_level, 1, 2, '', 1, array(), $projectstatic->thirdparty->id, 'None', 0, 'maxwidth500', ($user->hasRight('produit', 'lire') ? 0 : 1), '', null, 1);
} elseif (!empty($task_time->fk_product)) {
$product = new Product($db);
$resultFetch = $product->fetch($task_time->fk_product);

View file

@ -3,7 +3,7 @@
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2019 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Charlene Benke <charlene@patas-monkey.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2025 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -41,6 +41,7 @@ $langs = $GLOBALS['langs'];
* @var CommonObject $object
*/
$linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
// Note - at this time there does not seem to be a list of linked objects
'@phan-var-force CommonObject[] $linkedObjectBlock';
/** @var Task[] $linkedObjectBlock */
@ -48,7 +49,6 @@ $linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
$langs->load("tasks");
$linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date,ref', 'desc', 0, 0, 1);
'@phan-var-force CommonObject[] $linkedObjectBlock'; // Repeat because type lost after dol_sort_array)
/** @var Task[] $linkedObjectBlock */
$total = 0;

View file

@ -3,7 +3,7 @@
* Copyright (C) 2023-2024 Lionel Vessiller <lvessiller@easya.solutions>
* Copyright (C) 2023-2024 Patrice Andreani <pandreani@easya.solutions>
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2026 Charlene Benke <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -580,16 +580,22 @@ class FormListWebPortal
if (!empty($field_spec['arrayofkeyval']) && is_array($field_spec['arrayofkeyval'])) {
$out = $this->form->selectarray('search_' . $field_key, $field_spec['arrayofkeyval'], (isset($this->search[$field_key]) ? $this->search[$field_key] : ''), $field_spec['notnull'], 0, 0, '', 1, 0, 0, '', '');
} elseif (preg_match('/^(date|timestamp|datetime)/', $field_spec['type'])) {
$postDateStart = dol_mktime(0, 0, 0,
(int) isset($this->search[$field_key . '_dtstartmonth']) ? $this->search[$field_key . '_dtstartmonth'] : 0,
(int) isset($this->search[$field_key . '_dtstartday']) ? $this->search[$field_key . '_dtstartday'] : 0,
(int) isset($this->search[$field_key . '_dtstartyear']) ? $this->search[$field_key . '_dtstartyear'] : 0
);
$postDateEnd = dol_mktime(0, 0, 0,
(int) isset($this->search[$field_key . '_dtendmonth']) ? $this->search[$field_key . '_dtendmonth'] : 0,
(int) isset($this->search[$field_key . '_dtendday']) ? $this->search[$field_key . '_dtendday'] : 0,
(int) isset($this->search[$field_key . '_dtendyear']) ? $this->search[$field_key . '_dtendyear'] : 0
);
$postDateStart = dol_mktime(
0,
0,
0,
(int) isset($this->search[$field_key . '_dtstartmonth']) ? $this->search[$field_key . '_dtstartmonth'] : 0,
(int) isset($this->search[$field_key . '_dtstartday']) ? $this->search[$field_key . '_dtstartday'] : 0,
(int) isset($this->search[$field_key . '_dtstartyear']) ? $this->search[$field_key . '_dtstartyear'] : 0
);
$postDateEnd = dol_mktime(
0,
0,
0,
(int) isset($this->search[$field_key . '_dtendmonth']) ? $this->search[$field_key . '_dtendmonth'] : 0,
(int) isset($this->search[$field_key . '_dtendday']) ? $this->search[$field_key . '_dtendday'] : 0,
(int) isset($this->search[$field_key . '_dtendyear']) ? $this->search[$field_key . '_dtendyear'] : 0
);
$out = '<div class="grid width150">';
$out .= $this->form->inputDate('search_' . $field_key . '_dtstart', $postDateStart ? $postDateStart : '', $langs->trans('From'));
@ -617,10 +623,13 @@ class FormListWebPortal
// specific to get invoice status (depends on payment)
if ($this->element == 'invoice') {
$invoice = $this->object; // Copy to help static analysis
/** @var Facture $invoice */
'@phan-var-force Facture $invoice';
$discount = new DiscountAbsolute($this->db);
// Store company
$idCompany = (int) $this->object->socid;
$idCompany = (int) $invoice->socid;
if (!isset($this->companyStaticList[$idCompany])) {
$companyStatic = new Societe($this->db);
$companyStatic->fetch($idCompany);
@ -629,19 +638,18 @@ class FormListWebPortal
$companyStatic = $this->companyStaticList[$idCompany];
// paid sum
$payment = $this->object->getSommePaiement();
$totalcreditnotes = $this->object->getSumCreditNotesUsed();
$totaldeposits = $this->object->getSumDepositsUsed();
$payment = $invoice->getSommePaiement();
$totalcreditnotes = $invoice->getSumCreditNotesUsed();
$totaldeposits = $invoice->getSumDepositsUsed();
// remain to pay
$totalpay = $payment + $totalcreditnotes + $totaldeposits;
$remaintopay = price2num($this->object->total_ttc - $totalpay);
if ($this->object->status == Facture::STATUS_CLOSED && $this->object->close_code == 'discount_vat') { // If invoice closed with discount for anticipated payment
$remaintopay = price2num($invoice->total_ttc - $totalpay);
if ($invoice->status == Facture::STATUS_CLOSED && $invoice->close_code == 'discount_vat') { // If invoice closed with discount for anticipated payment
$remaintopay = 0;
}
if ($this->object->type == Facture::TYPE_CREDIT_NOTE && $this->object->paye == 1) {
// @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal
$remaincreditnote = $discount->getAvailableDiscounts($companyStatic, '', 'rc.fk_facture_source=' . $this->object->id);
if ($invoice->type == Facture::TYPE_CREDIT_NOTE && $invoice->paye == 1) {
$remaincreditnote = $discount->getAvailableDiscounts($companyStatic, null, 'rc.fk_facture_source=' . $invoice->id);
$remaintopay = -$remaincreditnote;
}
@ -688,8 +696,11 @@ class FormListWebPortal
$filedir = $conf->{$element}->multidir_output[$this->object->entity] . '/' . dol_sanitizeFileName($this->object->ref);
$out = $this->form->getDocumentsLink($element, $filename, $filedir);
} elseif ($field_key == 'signature_link') {
if ($this->object->fk_statut == Propal::STATUS_VALIDATED) {
$out = $this->form->getSignatureLink('proposal', $this->object);
$webobject = $this->object; // Intermediate var to help with typing.
/** @var WebPortalPropal|WebPortalOrder|WebPortalInvoice $webobject */
'@phan-var-force WebPortalPropal|WebPortalOrder|WebPortalInvoice $webobject';
if ($webobject->fk_statut == Propal::STATUS_VALIDATED) {
$out = $this->form->getSignatureLink('proposal', $webobject);
}
} else {
$out = $this->form->showOutputFieldForObject($this->object, $field_spec, $field_key, $this->object->$field_key, '');