diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index b3595c3b43f..ac615c78751 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1489,7 +1489,7 @@ class BOM extends CommonObject $reg = array(); $qtyhourservice = 0; if (preg_match('/^(\d+)([a-z]+)$/', $defaultdurationofservice, $reg)) { - $qtyhourservice = convertDurationtoHour((int) $reg[1], $reg[2]); + $qtyhourservice = convertDurationtoHour((float) $reg[1], $reg[2]); } if ($qtyhourservice) { diff --git a/htdocs/core/ajax/box.php b/htdocs/core/ajax/box.php index 1324096d3d5..5771e4edbe9 100644 --- a/htdocs/core/ajax/box.php +++ b/htdocs/core/ajax/box.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2007-2012 Laurent Destailleur * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -44,7 +45,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; $boxid = GETPOSTINT('boxid'); $boxorder = GETPOST('boxorder'); -$zone = GETPOST('zone'); // Can be '0' or '1' or 'pagename'... +$zone = GETPOST('zone'); // Can be key for zone +if ($zone !== '') { + $zone = (int) $zone; +} $userid = GETPOSTINT('userid'); // Security check diff --git a/htdocs/core/class/commonstickergenerator.class.php b/htdocs/core/class/commonstickergenerator.class.php index ab048d5ab6a..bb7330e6ecc 100644 --- a/htdocs/core/class/commonstickergenerator.class.php +++ b/htdocs/core/class/commonstickergenerator.class.php @@ -253,7 +253,7 @@ abstract class CommonStickerGenerator extends CommonDocGenerator * Convert units (in to mm, mm to in) * $src and $dest must be 'in' or 'mm' * - * @param int $value value + * @param float $value value * @param string $src from ('in' or 'mm') * @param string $dest to ('in' or 'mm') * @return float value value after conversion diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php index f52675fa219..e7579678d18 100644 --- a/htdocs/core/class/infobox.class.php +++ b/htdocs/core/class/infobox.class.php @@ -218,7 +218,7 @@ class InfoBox * Save order of boxes for area and user * * @param DoliDB $dbs Database handler - * @param int $zone Name of area (0 for Homepage, ...) + * @param int $zone Key of area (0 for Homepage, ...) * @param string $boxorder List of boxes with correct order 'A:123,456,...-B:789,321...' * @param int $userid Id of user * @return int Return integer <0 if KO, 0=Nothing done, > 0 if OK diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 541cd56bd41..df027a28200 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -116,7 +116,7 @@ function getServerTimeZoneInt($refgmtdate = 'now') * Add a delay to a date * * @param int $time Date timestamp (or string with format YYYY-MM-DD) - * @param int $duration_value Value of delay to add + * @param float $duration_value Value of delay to add * @param string $duration_unit Unit of added delay (d, m, y, w, h, i) * @param int $ruleforendofmonth Change the behavior of PHP over data-interval, 0 or 1 * @return int New timestamp @@ -128,16 +128,16 @@ function dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforend return $time; } if ($duration_unit == 's') { - return $time + ($duration_value); + return $time + (int) ($duration_value); } if ($duration_unit == 'i') { - return $time + (60 * $duration_value); + return $time + (int) (60 * $duration_value); } if ($duration_unit == 'h') { - return $time + (3600 * $duration_value); + return $time + (int) (3600 * $duration_value); } if ($duration_unit == 'w') { - return $time + (3600 * 24 * 7 * $duration_value); + return $time + (int) (3600 * 24 * 7 * $duration_value); } $deltastring = 'P'; @@ -327,9 +327,9 @@ function convertSecondToTime($iSecond, $format = 'all', $lengthOfDay = 86400, $l /** Convert duration to hour * - * @param int $duration_value Duration value + * @param float $duration_value Duration value * @param string $duration_unit Duration unit - * @return int $result + * @return float $result */ function convertDurationtoHour($duration_value, $duration_unit) { diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 57b026a2e8c..38539b4c7ac 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1009,7 +1009,7 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, * @param ?Societe $fromcompany Object company * @param int $marge_basse Margin bottom we use for the autobreak * @param int $marge_gauche Margin left (no more used) - * @param int $page_hauteur Page height + * @param float $page_hauteur Page height * @param CommonObject $object Object shown in PDF * @param int<0,3> $showdetails Show company address details into footer (0=Nothing, 1=Show address, 2=Show managers, 3=Both) * @param int $hidefreetext 1=Hide free text, 0=Show free text @@ -1424,8 +1424,8 @@ function pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, * @param Translate $outputlangs Object lang for output * @param int $w Width * @param int $h Height - * @param int $posx Pos x - * @param int $posy Pos y + * @param float $posx Pos x + * @param float $posy Pos y * @param int<0,1> $hideref Hide reference * @param int<0,1> $hidedesc Hide description * @param int<0,1> $issupplierline Is it a line for a supplier object ? @@ -2542,9 +2542,9 @@ function pdf_getLinkedObjects(&$object, $outputlangs) $refListsTxt = ''; if (empty($object->linkedObjects['commande']) && $object->element != 'commande') { - $refListsTxt.= $outputlangs->transnoentities("RefOrder").' / '.$outputlangs->transnoentities("RefSending").' :'; + $refListsTxt .= $outputlangs->transnoentities("RefOrder").' / '.$outputlangs->transnoentities("RefSending").' :'; } else { - $refListsTxt.=$outputlangs->transnoentities("RefSending").' :'; + $refListsTxt .= $outputlangs->transnoentities("RefSending").' :'; } // We concat this record info into fields xxx_value. title is overwrote. foreach ($objects as $elementobject) { @@ -2559,12 +2559,12 @@ function pdf_getLinkedObjects(&$object, $outputlangs) } } } - $refListsTxt.= (!empty($refListsTxt)?' ':''); + $refListsTxt .= (!empty($refListsTxt) ? ' ' : ''); if (! is_object($order)) { - $refListsTxt.= $outputlangs->transnoentities($elementobject->ref); + $refListsTxt .= $outputlangs->transnoentities($elementobject->ref); } else { - $refListsTxt.= $outputlangs->convToOutputCharset($order->ref).($order->ref_client ? ' ('.$order->ref_client.')' : ''); - $refListsTxt.= ' / '.$outputlangs->transnoentities($elementobject->ref); + $refListsTxt .= $outputlangs->convToOutputCharset($order->ref).($order->ref_client ? ' ('.$order->ref_client.')' : ''); + $refListsTxt .= ' / '.$outputlangs->transnoentities($elementobject->ref); } } diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 95b670ec030..e6aaf448e6e 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -1003,7 +1003,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $reg = []; $qtyhourservice = 0; if (preg_match('/^(\d+)([a-z]+)$/', $tmpproduct->duration, $reg)) { - $qtyhourservice = convertDurationtoHour((int) $reg[1], (string) $reg[2]); + $qtyhourservice = convertDurationtoHour((float) $reg[1], (string) $reg[2]); } $qtyhourforline = 0; if ($line->fk_unit) { diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 50b78c18ae6..6a98d84eedc 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -7,6 +7,7 @@ * Copyright (C) 2019 Pierre Ardoin * Copyright (C) 2019-2024 Frédéric France * Copyright (C) 2019 Nicolas ZABOURI + * Copyright (C) 2024 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 @@ -332,7 +333,7 @@ if ((isModEnabled("product") || isModEnabled("service")) && ($user->hasRight("pr $sql .= $db->plimit($max, 0); //print $sql; - $lastmodified=""; + $lastmodified = ""; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index dd89d8023d5..6613ada99f3 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -83,12 +83,12 @@ class Task extends CommonObjectLine public $description; /** - * @var float|'' total of time spent on this task + * @var int|'' total of time spent on this task (in seconds) */ public $duration_effective; /** - * @var float|'' planned workload + * @var int|'' planned workload (in seconds) */ public $planned_workload; diff --git a/phpstan.neon.dist b/phpstan.neon.dist index ed685c31da3..96c88e5e9cc 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -82,11 +82,9 @@ parameters: - '#EvalMath::trigger\(\) expects string, int given#' - '# Diff::generatePartialDiff\(\) expects array#' - '# EmailCollector::getpart\(\) expects string#' - - '#(?:convertSecondToTime) expects int, float\|string given#' - - '#(?:Comm(?:(?:ande::updateline|on(?:Invoice::getLibStatut|StickerGenerator::(?:Set_Char_Size|_Croix|convertMetric)))\(\))|Facture(?:(?:::update|FournisseurRec::add)line\(\))|(?:Holiday::addLogCP|Loan::getLibStatut|SupplierProposal::updateline)\(\)|c(?:alcul_price_total|onvert(?:DurationtoHour|SecondToTime))|dol_time_plus_duree|pdf_(?:azur::_tableau_(?:(?:info|tot)\(\))|ban(?:::_tableau\(\)|k)|c(?:anelle::_tableau_(?:(?:tot|versements)\(\))|ornas::_tableau_(?:(?:info|tot)\(\))|rabe::_tableau_(?:(?:info|tot|versements)\(\))|yan::draw(?:(?:Info|Total)Table\(\)))|e(?:agle(?:(?:::_tableau_tot|_proforma::drawTotalTable)\(\))|instein::_tableau_(?:(?:info|tot)\(\))|ratosthene::draw(?:(?:Info|Total)Table\(\))|spadon::_tableau_tot\(\))|muscadet::_tableau_(?:(?:info|tot)\(\))|octopus::(?:_table(?:(?:FirstPage|au)\(\))|draw(?:(?:Info|Total)Table\(\)))|page(?:foot|head)|(?:rouget::_tableau_tot|s(?:epamandate::_tableau(?:_info)?|ponge::draw(?:(?:Info|Total)Table)|quille::_tableau_tot|t(?:andard_(?:e(?:(?:valuation|xpensereport)::_tableau|xpensereport::tablePayments)|(?:myobjec|supplierpaymen)t::_tableau|supplierpayment::_tableau_cheque)|orm::_tableau_info|rato::tabSignature))|t(?:cpdflabel::writeBarcode|yphon::_tableau_info)|vinci::_tableau_info)\(\)|w(?:atermark|rite(?:LinkedObjects|linedesc))|zenith::_tableau_tot\(\))|usleep) expects int, float given\.#' - + - '#(?:(?:CommonStickerGenerator::_Croix|pdf_(?:azur::_tableau_(?:info|tot)|ban::_tableau))\(\)|pdf_(?:bank|c(?:anelle::_tableau_(?:(?:tot|versements)\(\))|ornas::_tableau_(?:(?:info|tot)\(\))|rabe::_tableau_(?:(?:info|tot|versements)\(\))|yan::draw(?:(?:Info|Total)Table\(\)))|e(?:agle(?:(?:::_tableau_tot|_proforma::drawTotalTable)\(\))|instein::_tableau_(?:(?:info|tot)\(\))|ratosthene::draw(?:(?:Info|Total)Table\(\))|spadon::_tableau_tot\(\))|muscadet::_tableau_(?:(?:info|tot)\(\))|octopus::(?:_table(?:(?:FirstPage|au)\(\))|draw(?:(?:Info|Total)Table\(\)))|page(?:foot|head)|(?:rouget::_tableau_tot|s(?:epamandate::_tableau(?:_info)?|ponge::draw(?:(?:Info|Total)Table)|quille::_tableau_tot|t(?:andard_(?:e(?:(?:valuation|xpensereport)::_tableau|xpensereport::tablePayments)|(?:myobjec|supplierpaymen)t::_tableau|supplierpayment::_tableau_cheque)|orm::_tableau_info|rato::tabSignature))|t(?:cpdflabel::writeBarcode|yphon::_tableau_info)|vinci::_tableau_info)\(\)|w(?:atermark|rite(?:LinkedObjects|linedesc))|zenith::_tableau_tot\(\))) expects int, float given\.#' + - '#(?:Comm(?:(?:ande::updateline|on(?:Invoice::getLibStatut|StickerGenerator::Set_Char_Size))\(\))|Facture(?:(?:::update|FournisseurRec::add)line\(\))|(?:Holiday::addLogCP|Loan::getLibStatut|SupplierProposal::updateline)\(\)|calcul_price_total) expects int, float given\.#' - '#(?:dol_(?:mktime|remove_file_process)|fetchObjectByElement|print_actions_filter) expects int, array\|string given\.#' - - '# (CSMSFile) constructor expects int, array\|string given.#' - '#(?:ProductFournisseur::logPrice\(\)) expects float\|null#' - '#(?:(?:Asset::addDepreciationL|Facture(?:(?:(?:Fournisseur)?::add|Fournisseur::update)l))ine\(\)|calcul_price_total|dol_convertToWord|(?:loanCalcMonthlyPaymen|print_paypal_redirec)t) expects float, string given.#' diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index 6e32dd68085..85b097ed3d9 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -6,6 +6,7 @@ * Copyright (C) 2005-2016 Regis Houssin * Copyright (C) 2019 Nicolas ZABOURI * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 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 @@ -396,7 +397,7 @@ if ($resql) { } if (getDolGlobalInt('MAILING_DELAY')) { - usleep((float) getDolGlobalInt('MAILING_DELAY') * 1000000); + usleep((int) ((float) getDolGlobalInt('MAILING_DELAY') * 1000000)); } } } else {