Fix ci phan/phpstan notices

# Fix ci phan/phpstan notices

Fix most notices, except undefined fk_website in SocieteAccount
as it is not clear if that is supposed to be a property there
(more specifically, that it is set).
This commit is contained in:
MDW 2025-01-25 00:46:59 +01:00
parent 77c8457d88
commit 2696c9a107
No known key found for this signature in database
5 changed files with 28 additions and 25 deletions

View File

@ -8,7 +8,7 @@
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2017 Open-DSI <support@open-dsi.fr>
* Copyright (C) 2021-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@ -1145,7 +1145,7 @@ if ($user->hasRight("holiday", "read")) {
$sql .= " AND x.date_fin >= '".$db->idate(dol_get_first_day($year, $month))."'";
}
if (!$user->hasRight('holiday', 'readall')) {
$sql.= " AND x.fk_user IN(".$db->sanitize(implode(", ", $user->getAllChildIds(1))).") ";
$sql .= " AND x.fk_user IN(".$db->sanitize(implode(", ", $user->getAllChildIds(1))).") ";
}
$resql = $db->query($sql);
@ -2119,7 +2119,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
//var_dump($event->userassigned);
//var_dump($event->transparency);
print '<table class="centpercent cal_event';
print (empty($event->transparency) ? ' cal_event_notbusy' : ' cal_event_busy');
print(empty($event->transparency) ? ' cal_event_notbusy' : ' cal_event_busy');
//if (empty($event->transparency) && empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) print ' opacitymedium'; // Not busy
print '" style="'.$h;
$colortouse = $color;

View File

@ -7,7 +7,7 @@
* Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr>
* Copyright (C) 2018-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2023 Florian HENRY <florian.henry@scopen.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@ -363,7 +363,7 @@ if ($usergroup > 0) {
if ($socid > 0) {
$param .= "&search_socid=".urlencode((string) ($socid));
}
if ($showbirthday) {
if ($showbirthday) { // Always false @phpstan-suppress-current-line
$param .= "&search_showbirthday=1";
}
if ($pid) {
@ -649,13 +649,13 @@ if (!empty($conf->use_javascript_ajax)) { // If javascript on
$s .= "\n".'<!-- End div to calendars selectors -->'."\n";
} else { // If javascript off
$newparam = $param; // newparam is for birthday links
$newparam = preg_replace('/showbirthday=[0-1]/i', 'showbirthday='.(empty($showbirthday) ? 1 : 0), $newparam);
$newparam = preg_replace('/showbirthday=[0-1]/i', 'showbirthday='.($showbirthday ? '1' : '0'), $newparam); // Always false @phpstan-ignore-line
if (!preg_match('/showbirthday=/i', $newparam)) {
$newparam .= '&showbirthday=1';
}
$link = '<a href="'.$_SERVER['PHP_SELF'].'?'.dol_escape_htmltag($newparam);
$link .= '">';
if (empty($showbirthday)) {
if ($showbirthday) { // Always false @phpstan-ignore-line
$link .= $langs->trans("AgendaShowBirthdayEvents");
} else {
$link .= $langs->trans("AgendaHideBirthdayEvents");
@ -983,7 +983,7 @@ if ($resql) {
// BIRTHDATES CALENDAR
// Complete $eventarray with birthdates
if ($showbirthday) {
if ($showbirthday) { // always false @phpstan-ignore-line
// Add events in array
$sql = 'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday';
$sql .= ' FROM '.MAIN_DB_PREFIX.'socpeople as sp';
@ -1067,7 +1067,7 @@ if ($user->hasRight("holiday", "read")) {
$sql .= " AND x.date_debut < '".$db->idate(dol_get_last_day($year, $month))."'";
$sql .= " AND x.date_fin >= '".$db->idate(dol_get_first_day($year, $month))."'";
if (!$user->hasRight('holiday', 'readall')) {
$sql.= " AND x.fk_user IN(".$db->sanitize(implode(", ", $user->getAllChildIds(1))).") ";
$sql .= " AND x.fk_user IN(".$db->sanitize(implode(", ", $user->getAllChildIds(1))).") ";
}
$resql = $db->query($sql);
@ -1342,7 +1342,7 @@ if (count($listofextcals)) {
$addevent = true;
}
if ($addevent) {
if ($addevent && $datestart !== null && $dateend !== null) {
$event->id = $icalevent['UID'];
$event->ref = (string) $event->id;
$userstatic = new User($db);
@ -2438,7 +2438,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
print 'style="background: #'.$color3.'; "';
}
print 'class="';
print($style3 ? $style3.' ' : '');
print $style3.' ';
print 'center'.($title2 ? ' classfortooltip' : '').($title3 ? ' cursorpointer' : '').'" ref="ref_'.$username->id.'_'.sprintf("%04d", $year).'_'.sprintf("%02d", $month).'_'.sprintf("%02d", $day).'_'.sprintf("%02d", $h).'_30_'.($ids3 ? $ids3 : 'none').'"'.($title3 ? ' title="'.$title3.'"' : '').'>';
print $string3;
print '</td>';
@ -2450,7 +2450,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, &
print 'style="background: #'.$color4.'; "';
}
print 'class="';
print($style4 ? $style4.' ' : '');
print $style4.' ';
print 'center'.($title3 ? ' classfortooltip' : '').($title4 ? ' cursorpointer' : '').'" ref="ref_'.$username->id.'_'.sprintf("%04d", $year).'_'.sprintf("%02d", $month).'_'.sprintf("%02d", $day).'_'.sprintf("%02d", $h).'_45_'.($ids4 ? $ids4 : 'none').'"'.($title4 ? ' title="'.$title4.'"' : '').'>';
print $string4;
print '</td>';

View File

@ -5,6 +5,7 @@
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2006 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@ -85,7 +86,7 @@ class Conf extends stdClass
public $disable_compute;
/**
* @var string Used to store current currency (ISO code like 'USD', 'EUR', ...). To get the currency symbol: $langs->getCurrencySymbol($this->currency)
* @var string Used to store current currency (ISO code like 'USD', 'EUR', ...). To get the currency symbol:->getCurrencySymbol($this->currency)
*/
public $currency;
@ -149,12 +150,12 @@ class Conf extends stdClass
public $entities = array();
/**
* @var int Set if we force param dol_hide_topmenu into login url
* @var int<0,1> Set if we force param dol_hide_topmenu into login url
*/
public $dol_hide_topmenu;
/**
* @var int Set if we force param dol_hide_leftmenu into login url
* @var int<0,1> Set if we force param dol_hide_leftmenu into login url
*/
public $dol_hide_leftmenu;
@ -1204,10 +1205,10 @@ class Conf extends stdClass
// For modules that want to disable top or left menu
if (!empty($this->global->MAIN_HIDE_TOP_MENU)) {
$this->dol_hide_topmenu = getDolGlobalInt('MAIN_HIDE_TOP_MENU');
$this->dol_hide_topmenu = (int) (bool) getDolGlobalInt('MAIN_HIDE_TOP_MENU');
}
if (!empty($this->global->MAIN_HIDE_LEFT_MENU)) {
$this->dol_hide_leftmenu = getDolGlobalInt('MAIN_HIDE_LEFT_MENU');
$this->dol_hide_leftmenu = (int) (bool) getDolGlobalInt('MAIN_HIDE_LEFT_MENU');
}
if (empty($this->global->MAIN_SIZE_SHORTLIST_LIMIT)) {

View File

@ -6,7 +6,7 @@
* Copyright (C) 2015-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2016-2025 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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

View File

@ -6,6 +6,7 @@
* Copyright (C) 2021 Maxime Demarest <maxime@indelog.fr>
* Copyright (C) 2021 Dorian Vabre <dorian.vabre@gmail.com>
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@ -44,7 +45,7 @@ if (!defined('NOBROWSERNOTIF')) {
}
if (!defined('XFRAMEOPTIONS_ALLOWALL')) {
define('XFRAMEOPTIONS_ALLOWALL', '1');
define('XFRAMEOPTIONS_ALLOWALL', '1');
}
// For MultiCompany module.
@ -394,7 +395,7 @@ if (empty($ipaddress)) {
$ipaddress = $_SESSION['ipaddress'];
}
if (empty($TRANSACTIONID)) {
$TRANSACTIONID = empty($_SESSION['TRANSACTIONID']) ? '' :$_SESSION['TRANSACTIONID']; // pi_... or ch_...
$TRANSACTIONID = empty($_SESSION['TRANSACTIONID']) ? '' : $_SESSION['TRANSACTIONID']; // pi_... or ch_...
if (empty($TRANSACTIONID) && GETPOST('payment_intent', 'alphanohtml')) {
// For the case we use STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION = 2
$TRANSACTIONID = GETPOST('payment_intent', 'alphanohtml');
@ -1653,18 +1654,18 @@ if ($ispaymentok) {
} else {
$booth->status = ConferenceOrBooth::STATUS_SUGGESTED;
$resultboothupdate = $booth->update($user);
if ($resultboothupdate<0) {
if ($resultboothupdate < 0) {
// Finding the thirdparty by getting the invoice
$invoice = new Facture($db);
$resultinvoice = $invoice->fetch($ref);
if ($resultinvoice<0) {
if ($resultinvoice < 0) {
$postactionmessages[] = 'Could not find the associated invoice.';
$ispostactionok = -1;
$error++;
} else {
$thirdparty = new Societe($db);
$resultthirdparty = $thirdparty->fetch($invoice->socid);
if ($resultthirdparty<0) {
if ($resultthirdparty < 0) {
$error++;
setEventMessages(null, $thirdparty->errors, "errors");
} else {
@ -1893,10 +1894,11 @@ if ($ispaymentok) {
$payerID = empty($PAYPALPAYERID) ? $_SESSION['payerID'] : $PAYPALPAYERID;
// Set by newpayment.php
$currencyCodeType = empty($_SESSION['currencyCodeType']) ? '' : $_SESSION['currencyCodeType'];
$FinalPaymentAmt = empty($_SESSION["FinalPaymentAmt"]) ? '': $_SESSION["FinalPaymentAmt"];
$FinalPaymentAmt = empty($_SESSION["FinalPaymentAmt"]) ? '' : $_SESSION["FinalPaymentAmt"];
$paymentType = empty($_SESSION['PaymentType']) ? '' : $_SESSION['PaymentType']; // Seems used by paypal only
if (is_object($object) && method_exists($object, 'call_trigger')) {
'@phan-var-force CommonObject $object';
// Call trigger
$result = $object->call_trigger('PAYMENTONLINE_PAYMENT_OK', $user);
if ($result < 0) {
@ -1904,7 +1906,7 @@ if ($ispaymentok) {
}
// End call triggers
} elseif (get_class($object) == 'stdClass') {
//In some case $object is not instantiate (for paiement on custom object) We need to deal with payment
//In some cases $object is not instantiated (for payment on custom object) We need to deal with payment
include_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
$paiement = new Paiement($db);
$result = $paiement->call_trigger('PAYMENTONLINE_PAYMENT_OK', $user);