Qual: Fix PhanPluginUnknownPropertyType, PhanPossiblyUndeclaredVariable

This commit is contained in:
MDW 2025-01-07 15:31:41 +01:00
parent b61d286e7d
commit a42bc6755c
No known key found for this signature in database
10 changed files with 96 additions and 21 deletions

View File

@ -1,9 +1,11 @@
<?php
/* Copyright (C) 2016 Xebax Christy <xebax@wanadoo.fr>
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2016 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2023 Romain Neil <contact@romain-neil.fr>
* Copyright (C) 2024 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
@ -105,7 +107,7 @@ class Documents extends DolibarrApi
}
$file_content = file_get_contents($original_file_osencoded);
return array('filename'=>$filename, 'content-type' => dol_mimetype($filename), 'filesize'=>filesize($original_file), 'content'=>base64_encode($file_content), 'encoding'=>'base64');
return array('filename' => $filename, 'content-type' => dol_mimetype($filename), 'filesize' => filesize($original_file), 'content' => base64_encode($file_content), 'encoding' => 'base64');
}
@ -290,7 +292,7 @@ class Documents extends DolibarrApi
}
$file_content = file_get_contents($original_file_osencoded);
return array('filename'=>$filename, 'content-type' => dol_mimetype($filename), 'filesize'=>filesize($original_file), 'content'=>base64_encode($file_content), 'langcode'=>$outputlangs->defaultlang, 'template'=>$templateused, 'encoding'=>'base64');
return array('filename' => $filename, 'content-type' => dol_mimetype($filename), 'filesize' => filesize($original_file), 'content' => base64_encode($file_content), 'langcode' => $outputlangs->defaultlang, 'template' => $templateused, 'encoding' => 'base64');
}
/**
@ -693,6 +695,7 @@ class Documents extends DolibarrApi
}
$original_file = dol_sanitizeFileName($filename);
$relativefile = 'UNSET';
// Define $uploadir
$object = null;

View File

@ -1,10 +1,12 @@
<?php
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Xavier Dutoit <doli@sydesy.com>
* Copyright (C) 2004-2020 Laurent Destailleur <eldy@users.sourceforge.net>
* 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
@ -53,6 +55,9 @@ class Conf extends stdClass
public $browser;
//! To store some setup of generic modules
/**
* @var stdClass
*/
public $mycompany;
/**
@ -71,7 +76,13 @@ class Conf extends stdClass
public $multicompany;
//! To store module status of special module names
/**
* @var ?mixed
*/
public $expedition_bon;
/**
* @var ?mixed
*/
public $delivery_note;
/**
@ -85,7 +96,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;
@ -172,15 +183,45 @@ class Conf extends stdClass
*/
public $dol_use_jmobile; // Set if we force param dol_use_jmobile into login url. 0=default, 1=to say we use app from a webview app, 2=to say we use app from a webview app and keep ajax
/**
* @var string
*/
public $format_date_short; // Format of day with PHP/C tags (strftime functions)
/**
* @var string
*/
public $format_date_short_java; // Format of day with Java tags
/**
* @var string
*/
public $format_hour_short;
/**
* @var string
*/
public $format_hour_short_duration;
/**
* @var string
*/
public $format_date_text_short;
/**
* @var string
*/
public $format_date_text;
/**
* @var string
*/
public $format_date_hour_short;
/**
* @var string
*/
public $format_date_hour_sec_short;
/**
* @var string
*/
public $format_date_hour_text_short;
/**
* @var string
*/
public $format_date_hour_text;
/**
@ -306,12 +347,13 @@ class Conf extends stdClass
*/
public $productbatch;
/**
* @var ?stdClass
* @deprecated Use project
*/
public $projet;
/**
* @var stdClass
* @var ?stdClass
*/
public $project;
@ -631,8 +673,9 @@ class Conf extends stdClass
}
// Object $mc
global $mc;
$mc = null;
if (!defined('NOREQUIREMC') && isModEnabled('multicompany')) {
global $mc;
$ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php');
if ($ret && class_exists('ActionsMulticompany')) {
$mc = new ActionsMulticompany($db);

View File

@ -4,7 +4,7 @@
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2022-2024 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2023 Alexandre Janniaux <alexandre.janniaux@gmail.com>
* 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
@ -453,7 +453,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers
if (!getDolGlobalString('STOCK_SUPPORTS_SERVICES') && $orderline->product_type > 0) {
continue;
}
if (isset($qtyordred[$shippingline->fk_product])) {
if (isset($qtyordred[$orderline->fk_product])) {
$qtyordred[$orderline->fk_product] += $orderline->qty;
} else {
$qtyordred[$orderline->fk_product] = $orderline->qty;

View File

@ -1,4 +1,5 @@
<?php
/*
* Copyright (C) 2014-2016 Jean-François Ferry <hello@librethic.io>
* Copyright (C) 2016 Christophe Battarel <christophe@altairis.fr>
@ -87,6 +88,7 @@ class InterfaceTicketEmail extends DolibarrTriggers
$body_assignee = 'TicketAssignedEmailBody';
$see_ticket_assignee = 'SeeThisTicketIntomanagementInterface';
$old_MAIN_MAIL_AUTO_COPY_TO = null; // For static analysis
if (getDolGlobalString('TICKET_DISABLE_MAIL_AUTOCOPY_TO')) {
$old_MAIN_MAIL_AUTOCOPY_TO = getDolGlobalString('MAIN_MAIL_AUTOCOPY_TO');
$conf->global->MAIN_MAIL_AUTOCOPY_TO = '';

View File

@ -8,7 +8,7 @@
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2020-2021 Udo Tamm <dev@dolibit.de>
* Copyright (C) 2022 Anthony Berton <anthony.berton@bb2a.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
@ -780,6 +780,10 @@ function sendMail($id, $cancreate, $now, $autoValidation)
} elseif ($object->halfday == 0 || $object->halfday == 2) {
$starthalfdaykey = "Morning";
$endhalfdaykey = "Afternoon";
} else {
// For static analysis, ensure variables are defined
$starthalfdaykey = "InvalidHalfday";
$endhalfdaykey = "InvalidHalfday";
}
$link = dol_buildpath("/holiday/card.php", 3) . '?id='.$object->id;

View File

@ -3,7 +3,7 @@
* Copyright (C) 2005-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2011 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -542,6 +542,7 @@ class MouvementStock extends CommonObject
// Test if there is already a record for couple (warehouse / product), so later we will make an update or create.
$alreadyarecord = 0;
$fk_product_stock = 0;
if (!$error) {
$sql = "SELECT rowid, reel FROM ".$this->db->prefix()."product_stock";
$sql .= " WHERE fk_entrepot = ".((int) $entrepot_id)." AND fk_product = ".((int) $fk_product); // This is a unique key

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2018-2021 Thibault FOUCART <support@ptibogxiv.net>
* Copyright (C) 2024 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
@ -1220,6 +1220,7 @@ class Stripe extends CommonObject
$description = "";
$ref = "";
$invoice = null;
if ($origin == 'order') {
$order = new Commande($this->db);
$order->fetch($item);

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2016 Jean-François Ferry <hello@librethic.io>
* Copyright (C) 2024 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
@ -162,17 +162,19 @@ class Tickets extends DolibarrApi
if ($this->ticket->cache_msgs_ticket[$i]['fk_user_author'] > 0) {
$user_action = new User($this->db);
$user_action->fetch($this->ticket->cache_msgs_ticket[$i]['fk_user_author']);
} else {
$user_action = null;
}
// Now define messages
$messages[] = array(
'id' => $this->ticket->cache_msgs_ticket[$i]['id'],
'fk_user_action' => $this->ticket->cache_msgs_ticket[$i]['fk_user_author'],
'fk_user_action_socid' => $user_action->socid,
'fk_user_action_string' => dolGetFirstLastname($user_action->firstname, $user_action->lastname),
'message' => $this->ticket->cache_msgs_ticket[$i]['message'],
'datec' => $this->ticket->cache_msgs_ticket[$i]['datec'],
'private' => $this->ticket->cache_msgs_ticket[$i]['private']
'id' => $this->ticket->cache_msgs_ticket[$i]['id'],
'fk_user_action' => $this->ticket->cache_msgs_ticket[$i]['fk_user_author'],
'fk_user_action_socid' => $user_action === null ? '' : $user_action->socid,
'fk_user_action_string' => $user_action === null ? '' : dolGetFirstLastname($user_action->firstname, $user_action->lastname),
'message' => $this->ticket->cache_msgs_ticket[$i]['message'],
'datec' => $this->ticket->cache_msgs_ticket[$i]['datec'],
'private' => $this->ticket->cache_msgs_ticket[$i]['private']
);
$i++;
}

View File

@ -62,6 +62,16 @@ if (isModEnabled('accounting')) {
* @var User $user
*/
// $moreparam is used, but it is unclear how it is set, keeping the variable and ensuring it exists.
// $countrynotdefined is used, but it is unclear how it is set.
'
@phan-var-force ?string $moreparam
@phan-var-force ?string $countrynotdefined
';
if (!isset($moreparam)) {
$moreparam = null;
}
// Load translation files required by page
$langs->loadLangs(array('companies', 'commercial', 'banks', 'bills', 'trips', 'holiday', 'salaries'));

View File

@ -4,7 +4,7 @@
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2018-2024 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
@ -790,6 +790,8 @@ class Website extends CommonObject
dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
}
$newidforhome = 0;
if (!$error) {
// @phan-suppress-next-line PhanPluginSuspiciousParamOrder
dolCopyDir($pathofwebsiteold, $pathofwebsitenew, getDolGlobalString('MAIN_UMASK'), 0, [], 2);
@ -812,8 +814,6 @@ class Website extends CommonObject
$pathofmediasimagenew = DOL_DATA_ROOT.'/medias/image/'.$newref;
dolCopyDir($pathofmediasimageold, $pathofmediasimagenew, getDolGlobalString('MAIN_UMASK'), 0);
$newidforhome = 0;
// Duplicate pages
$objectpages = new WebsitePage($this->db);
$listofpages = $objectpages->fetchAll($fromid);
@ -1350,6 +1350,7 @@ class Website extends CommonObject
// Search the $maxrowid because we need it later
$sqlgetrowid = 'SELECT MAX(rowid) as max from '.MAIN_DB_PREFIX.'website_page';
$maxrowid = 0;
$resql = $this->db->query($sqlgetrowid);
if ($resql) {
$obj = $this->db->fetch_object($resql);
@ -1364,6 +1365,7 @@ class Website extends CommonObject
}
$objectpagestatic = new WebsitePage($this->db);
$aliasesarray = null;
// Regenerate the php files for pages
$fp = fopen($sqlfile, "r");
@ -1765,6 +1767,8 @@ class Website extends CommonObject
return -1;
}
$destdir = null; // Otherwise only set when 'WEBSITE_ALLOW_OVERWRITE_GIT_SOURCE' is not falsy.
$destdirrel = ''; // Otherwise only set when 'WEBSITE_ALLOW_OVERWRITE_GIT_SOURCE' is not falsy.
// Replace modified files into the doctemplates directory.
if (getDolGlobalString('WEBSITE_ALLOW_OVERWRITE_GIT_SOURCE')) {
// If the user has not specified a path
@ -1798,6 +1802,11 @@ class Website extends CommonObject
}
}
if ($destdir === null) {
setEventMessages("The destination path is not determined.", null, 'errors');
return -1;
}
dol_mkdir($destdir);
if (!is_writable($destdir)) {