From a42bc6755c7012657bfc597039da011fbb77d7ab Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 7 Jan 2025 15:31:41 +0100 Subject: [PATCH] Qual: Fix PhanPluginUnknownPropertyType, PhanPossiblyUndeclaredVariable --- htdocs/api/class/api_documents.class.php | 7 ++- htdocs/core/class/conf.class.php | 49 +++++++++++++++++-- ...e_20_modWorkflow_WorkflowManager.class.php | 4 +- ...terface_50_modTicket_TicketEmail.class.php | 2 + htdocs/holiday/card_group.php | 6 ++- .../stock/class/mouvementstock.class.php | 3 +- htdocs/stripe/class/stripe.class.php | 3 +- htdocs/ticket/class/api_tickets.class.php | 18 ++++--- htdocs/user/bank.php | 10 ++++ htdocs/website/class/website.class.php | 15 ++++-- 10 files changed, 96 insertions(+), 21 deletions(-) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 9cc2258a4df..71b42aea8a8 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -1,9 +1,11 @@ * Copyright (C) 2016 Laurent Destailleur * Copyright (C) 2016 Jean-François Ferry * Copyright (C) 2023 Romain Neil * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW * * 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; diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index e5dde138be6..63e782d3366 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -1,10 +1,12 @@ * Copyright (C) 2003 Xavier Dutoit * Copyright (C) 2004-2020 Laurent Destailleur * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2006 Jean Heimburger * Copyright (C) 2024-2025 Frédéric France + * Copyright (C) 2024-2025 MDW * * 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); diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index 28204bfb5ad..d581510dd99 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2014 Marcos García * Copyright (C) 2022-2024 Ferran Marcet * Copyright (C) 2023 Alexandre Janniaux - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * 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; diff --git a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php index 0d4734de318..1cd6aebb3c8 100644 --- a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php +++ b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php @@ -1,4 +1,5 @@ * Copyright (C) 2016 Christophe Battarel @@ -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 = ''; diff --git a/htdocs/holiday/card_group.php b/htdocs/holiday/card_group.php index 34b5f24109e..9eb3f2ab5d0 100644 --- a/htdocs/holiday/card_group.php +++ b/htdocs/holiday/card_group.php @@ -8,7 +8,7 @@ * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2020-2021 Udo Tamm * Copyright (C) 2022 Anthony Berton - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * 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; diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 45668188f93..5794ace75d3 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2005-2015 Laurent Destailleur * Copyright (C) 2011 Jean Heimburger * Copyright (C) 2014 Cedric GROSS - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * 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 diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index b63e8a10e9d..d9df53069b4 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * 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); diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php index c3206e04120..2d0fca7f77a 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * 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++; } diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index 61fadf541b6..026e4723736 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -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')); diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 65ef58f22dd..d1efc20b1ea 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2018-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * 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)) {