diff --git a/dev/tools/phan/config.php b/dev/tools/phan/config.php index f11b816d841..2290d297499 100644 --- a/dev/tools/phan/config.php +++ b/dev/tools/phan/config.php @@ -446,7 +446,7 @@ return [ 'PhanRedefinedClassReference', // 'PhanPluginNoCommentOnClass', // 'PhanPluginNotFullyQualifiedGlobalConstant', - 'PhanTypeMismatchDefault', + // 'PhanTypeMismatchDefault', // 'PhanPluginPHPDocHashComment', 'PhanPluginShortArrayList', 'PhanPluginUnknownArrayPropertyType', diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7fafe17c152..4a6e3a42f01 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -13880,9 +13880,9 @@ function GETPOSTDATE($prefix, $hourTime = '', $gm = 'auto') * request. * * @param string $prefix Prefix used to build the date selector (for instance using Form::selectDate) - * @param int $timestamp If null, the timestamp will be created from request data - * @param bool $hourTime If timestamp is null, will be passed to GETPOSTDATE to construct the timestamp - * @param bool $gm If timestamp is null, will be passed to GETPOSTDATE to construct the timestamp + * @param ?int $timestamp If null, the timestamp will be created from request data + * @param string $hourTime If timestamp is null, will be passed to GETPOSTDATE to construct the timestamp + * @param string $gm If timestamp is null, will be passed to GETPOSTDATE to construct the timestamp * @return string Portion of URL with query parameters for the specified date */ function buildParamDate($prefix, $timestamp = null, $hourTime = '', $gm = 'auto') diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 7fcb1c8f0d1..9c5d138dfc6 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -639,7 +639,7 @@ function print_start_menu_entry($idsel, $classname, $showmode) * @param string $idsel Id sel * @param string $classname Class name * @param string $atarget Target - * @param array{rowid:string,fk_menu:string,langs:string,enabled:int<0,2>,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,level?:int,prefix:string} $menuval All the $menuval array + * @param array{}|array{rowid:string,fk_menu:string,langs:string,enabled:int<0,2>,type:string,fk_mainmenu:string,fk_leftmenu:string,url:string,titre:string,perms:string,target:string,mainmenu:string,leftmenu:string,position:int,level?:int,prefix:string} $menuval All the $menuval array * @return void */ function print_text_menu_entry($text, $showmode, $url, $id, $idsel, $classname, $atarget, $menuval = array()) diff --git a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php index cd6d9f78d0e..ff0ac8142aa 100644 --- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php +++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005-2008 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * 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 @@ -135,7 +136,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders * @param CommandeFournisseur $object Object * @return string Value if OK, 0 if KO */ - public function getNextValue($objsoc = '', $object = '') + public function getNextValue($objsoc, $object) { global $db, $conf; diff --git a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php index 03f948de1c1..025ee320d36 100644 --- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php +++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * 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 @@ -126,7 +127,7 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders * @param CommandeFournisseur $object Object * @return string|0 Value if OK, 0 if KO */ - public function getNextValue($objsoc = '', $object = '') + public function getNextValue($objsoc, $object) { global $db, $conf; diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 54c4a8b469a..a602edc810d 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -656,8 +656,6 @@ class ExpenseReport extends CommonObject */ public function fetch($id, $ref = '') { - global $conf; - $sql = "SELECT d.rowid, d.entity, d.ref, d.note_public, d.note_private,"; // DEFAULT $sql .= " d.detail_refuse, d.detail_cancel, d.fk_user_refuse, d.fk_user_cancel,"; // ACTIONS $sql .= " d.date_refuse, d.date_cancel,"; // ACTIONS @@ -885,6 +883,8 @@ class ExpenseReport extends CommonObject $sql .= " WHERE f.rowid = ".((int) $id); $sql .= " AND f.entity = ".$conf->entity; + + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { @@ -920,7 +920,7 @@ class ExpenseReport extends CommonObject */ public function initAsSpecimen() { - global $user, $langs, $conf; + global $user, $langs; $now = dol_now(); @@ -983,10 +983,10 @@ class ExpenseReport extends CommonObject * @param User $user User * @return int Return integer <0 if KO, >0 if OK */ - public function fetch_line_by_project($projectid, $user = '') + public function fetch_line_by_project($projectid, $user) { // phpcs:enable - global $conf, $db, $langs; + global $langs; $langs->load('trips'); @@ -1086,8 +1086,6 @@ class ExpenseReport extends CommonObject public function fetch_lines() { // phpcs:enable - global $conf; - $this->lines = array(); $sql = ' SELECT de.rowid, de.comments, de.qty, de.value_unit, de.date, de.rang,'; @@ -1792,7 +1790,7 @@ class ExpenseReport extends CommonObject */ public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1) { - global $langs, $conf, $hookmanager; + global $langs, $hookmanager; $result = ''; @@ -1906,7 +1904,7 @@ class ExpenseReport extends CommonObject * @param float $qty Qty * @param double $up Unit price (price with tax) * @param int $fk_c_type_fees Type payment - * @param string $vatrate Vat rate (Can be '10' or '10 (ABC)') + * @param int<-1,0>|string $vatrate Vat rate (Can be '10' or '10 (ABC)') * @param string $date Date * @param string $comments Description * @param int $fk_project Project id @@ -1917,7 +1915,7 @@ class ExpenseReport extends CommonObject */ public function addline($qty = 0, $up = 0, $fk_c_type_fees = 0, $vatrate = 0, $date = '', $comments = '', $fk_project = 0, $fk_c_exp_tax_cat = 0, $type = 0, $fk_ecm_files = 0) { - global $conf, $langs, $mysoc; + global $langs, $mysoc; dol_syslog(get_class($this)."::addline qty=$qty, up=$up, fk_c_type_fees=$fk_c_type_fees, vatrate=$vatrate, date=$date, fk_project=$fk_project, type=$type, comments=$comments", LOG_DEBUG); @@ -2029,7 +2027,7 @@ class ExpenseReport extends CommonObject */ public function checkRules($type = 0, $seller = '') { - global $user, $conf, $db, $langs, $mysoc; + global $conf, $db, $langs, $mysoc; $langs->load('trips'); @@ -2105,7 +2103,7 @@ class ExpenseReport extends CommonObject */ public function applyOffset($type = 0, $seller = '') { - global $conf, $mysoc; + global $mysoc; if (!getDolGlobalString('MAIN_USE_EXPENSE_IK')) { return false; @@ -2327,10 +2325,10 @@ class ExpenseReport extends CommonObject /** * deleteline * - * @param int $rowid Row id - * @param User $fuser User - * @param int $notrigger 1=No trigger - * @return int Return integer <0 if KO, >0 if OK + * @param int $rowid Row id + * @param User|string $fuser User + * @param int<0,1> $notrigger 1=No trigger + * @return int<0,1> Return integer <0 if KO, >0 if OK */ public function deleteLine($rowid, $fuser = '', $notrigger = 0) { @@ -2473,8 +2471,6 @@ class ExpenseReport extends CommonObject */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { - global $conf; - $outputlangs->load("trips"); if (!dol_strlen($modele)) { @@ -2530,7 +2526,7 @@ class ExpenseReport extends CommonObject */ public function loadStateBoard() { - global $conf, $user; + global $user; $this->nb = array(); @@ -3040,7 +3036,7 @@ class ExpenseReportLine extends CommonObjectLine */ public function insert($notrigger = 0, $fromaddline = false) { - global $user, $conf; + global $user; $error = 0; @@ -3182,7 +3178,7 @@ class ExpenseReportLine extends CommonObjectLine */ public function update(User $user) { - global $langs, $conf; + global $langs; $error = 0; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 7f7511db38f..5c7fba47e8e 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1929,7 +1929,7 @@ class CommandeFournisseur extends CommonOrder * @param int $date_end Date end of service * @param array $array_options extrafields array * @param int|null $fk_unit Code of the unit to use. Null to use the default one - * @param string $pu_ht_devise Amount in currency + * @param int|string $pu_ht_devise Amount in currency * @param string $origin 'order', ... * @param int $origin_id Id of origin object * @param int $rang Rank @@ -2880,13 +2880,13 @@ class CommandeFournisseur extends CommonOrder * * @param int $rowid ID de la ligne de facture * @param string $desc Line description - * @param float $pu Unit price - * @param float $qty Quantity - * @param float $remise_percent Percent discount on line - * @param float $txtva VAT rate - * @param float $txlocaltax1 Localtax1 tax - * @param float $txlocaltax2 Localtax2 tax - * @param float $price_base_type Type of price base + * @param int|float $pu Unit price + * @param int|float $qty Quantity + * @param int|float $remise_percent Percent discount on line + * @param int|float $txtva VAT rate + * @param int|float $txlocaltax1 Localtax1 tax + * @param int|float $txlocaltax2 Localtax2 tax + * @param string $price_base_type Type of price base * @param int $info_bits Miscellaneous information * @param int $type Type of line (0=product, 1=service) * @param int $notrigger Disable triggers @@ -2894,11 +2894,11 @@ class CommandeFournisseur extends CommonOrder * @param integer $date_end Date end of service * @param array $array_options Extrafields array * @param int|null $fk_unit Code of the unit to use. Null to use the default one - * @param float $pu_ht_devise Unit price in currency + * @param int|float $pu_ht_devise Unit price in currency * @param string $ref_supplier Supplier ref * @return int Return integer < 0 if error, > 0 if ok */ - public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = 0, $notrigger = 0, $date_start = '', $date_end = '', $array_options = [], $fk_unit = null, $pu_ht_devise = 0, $ref_supplier = '') + public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = 0, $notrigger = 0, $date_start = 0, $date_end = 0, $array_options = [], $fk_unit = null, $pu_ht_devise = 0, $ref_supplier = '') { global $mysoc, $conf, $langs; dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $type, $fk_unit"); @@ -3243,8 +3243,8 @@ class CommandeFournisseur extends CommonOrder /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * - * @param User $user Object user - * @param int $mode "opened", "awaiting" for orders awaiting reception + * @param User $user Object user + * @param string $mode "opened", "awaiting" for orders awaiting reception * @return WorkboardResponse|int Return integer <0 if KO, WorkboardResponse if OK */ public function load_board($user, $mode = 'opened') diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 8084c99c40b..c9b37398cae 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2065,7 +2065,7 @@ class FactureFournisseur extends CommonInvoice * @param int $fk_remise_except Id discount used * @return int >0 if OK, <0 if KO */ - public function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product = 0, $remise_percent = 0, $date_start = '', $date_end = '', $fk_code_ventilation = 0, $info_bits = '', $price_base_type = 'HT', $type = 0, $rang = -1, $notrigger = 0, $array_options = [], $fk_unit = null, $origin_id = 0, $pu_devise = 0, $ref_supplier = '', $special_code = '', $fk_parent_line = 0, $fk_remise_except = 0) + public function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product = 0, $remise_percent = 0, $date_start = 0, $date_end = 0, $fk_code_ventilation = 0, $info_bits = 0, $price_base_type = 'HT', $type = 0, $rang = -1, $notrigger = 0, $array_options = [], $fk_unit = null, $origin_id = 0, $pu_devise = 0, $ref_supplier = '', $special_code = '', $fk_parent_line = 0, $fk_remise_except = 0) { global $langs, $mysoc, $conf; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 5812a120489..942a332d7a0 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1971,7 +1971,7 @@ class Product extends CommonObject // Add new price $sql = "INSERT INTO ".$this->db->prefix()."product_price(price_level,date_price, fk_product, fk_user_author, price_label, price, price_ttc, price_base_type,tosell, tva_tx, default_vat_code, recuperableonly,"; $sql .= " localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, price_min,price_min_ttc,price_by_qty,entity,fk_price_expression) "; - $sql .= " VALUES(".($level ? ((int) $level) : 1).", '".$this->db->idate($now)."', ".((int) $this->id).", ".((int) $user->id).", ".(empty($this->price_label)?"null":"'".$this->db->escape($this->price_label)."'").", ".((float) price2num($this->price)).", ".((float) price2num($this->price_ttc)).",'".$this->db->escape($this->price_base_type)."',".((int) $this->status).", ".((float) price2num($this->tva_tx)).", ".($this->default_vat_code ? ("'".$this->db->escape($this->default_vat_code)."'") : "null").", ".((int) $this->tva_npr).","; + $sql .= " VALUES(".($level ? ((int) $level) : 1).", '".$this->db->idate($now)."', ".((int) $this->id).", ".((int) $user->id).", ".(empty($this->price_label) ? "null" : "'".$this->db->escape($this->price_label)."'").", ".((float) price2num($this->price)).", ".((float) price2num($this->price_ttc)).",'".$this->db->escape($this->price_base_type)."',".((int) $this->status).", ".((float) price2num($this->tva_tx)).", ".($this->default_vat_code ? ("'".$this->db->escape($this->default_vat_code)."'") : "null").", ".((int) $this->tva_npr).","; $sql .= " ".price2num($this->localtax1_tx).", ".price2num($this->localtax2_tx).", '".$this->db->escape($this->localtax1_type)."', '".$this->db->escape($this->localtax2_type)."', ".price2num($this->price_min).", ".price2num($this->price_min_ttc).", ".price2num($this->price_by_qty).", ".((int) $conf->entity).",".($this->fk_price_expression > 0 ? ((int) $this->fk_price_expression) : 'null'); $sql .= ")"; @@ -2308,7 +2308,7 @@ class Product extends CommonObject * @param double $newprice New price * @param string $newpricebase HT or TTC * @param User $user Object user that make change - * @param double $newvat New VAT Rate (For example 8.5. Should not be a string) + * @param ?double $newvat New VAT Rate (For example 8.5. Should not be a string) * @param double $newminprice New price min * @param int $level 0=standard, >0 = level if multilevel prices * @param int $newnpr 0=Standard vat rate, 1=Special vat rate for French NPR VAT @@ -2320,7 +2320,7 @@ class Product extends CommonObject * @param int $notrigger Disable triggers * @return int Return integer <0 if KO, >0 if OK */ - public function updatePrice($newprice, $newpricebase, $user, $newvat = '', $newminprice = 0, $level = 0, $newnpr = 0, $newpbq = 0, $ignore_autogen = 0, $localtaxes_array = array(), $newdefaultvatcode = '', $price_label = '', $notrigger = 0) + public function updatePrice($newprice, $newpricebase, $user, $newvat = null, $newminprice = 0, $level = 0, $newnpr = 0, $newpbq = 0, $ignore_autogen = 0, $localtaxes_array = array(), $newdefaultvatcode = '', $price_label = '', $notrigger = 0) { global $conf, $langs; @@ -2342,7 +2342,7 @@ class Product extends CommonObject } // Check parameters - if ($newvat == '') { + if ($newvat === null || $newvat == '') { // Maintain '' for backwards compatibility $newvat = $this->tva_tx; } diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 754f465e574..260b922d5de 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -934,9 +934,9 @@ class Task extends CommonObjectLine * @param string $filteronproj Filter on project ref or label * @param string $filteronprojstatus Filter on project status ('-1'=no filter, '0,1'=Draft+Validated only) * @param string $morewherefilter Add more filter into where SQL request (must start with ' AND ...') - * @param string $filteronprojuser Filter on user that is a contact of project - * @param string $filterontaskuser Filter on user assigned to task - * @param Extrafields $extrafields Show additional column from project or task + * @param int $filteronprojuser Filter on user that is a contact of project + * @param int $filterontaskuser Filter on user assigned to task + * @param ?Extrafields $extrafields Show additional column from project or task * @param int $includebilltime Calculate also the time to bill and billed * @param array $search_array_options Array of search filters. Not Used yet. * @param int $loadextras Fetch all Extrafields on each project and task @@ -945,9 +945,9 @@ class Task extends CommonObjectLine * @param string $sortorder Sort order * @return array|string Array of tasks */ - public function getTasksArray($usert = null, $userp = null, $projectid = 0, $socid = 0, $mode = 0, $filteronproj = '', $filteronprojstatus = '-1', $morewherefilter = '', $filteronprojuser = 0, $filterontaskuser = 0, $extrafields = array(), $includebilltime = 0, $search_array_options = array(), $loadextras = 0, $loadRoleMode = 1, $sortfield = '', $sortorder = '') + public function getTasksArray($usert = null, $userp = null, $projectid = 0, $socid = 0, $mode = 0, $filteronproj = '', $filteronprojstatus = '-1', $morewherefilter = '', $filteronprojuser = 0, $filterontaskuser = 0, $extrafields = null, $includebilltime = 0, $search_array_options = array(), $loadextras = 0, $loadRoleMode = 1, $sortfield = '', $sortorder = '') { - global $conf, $hookmanager; + global $hookmanager; $tasks = array(); @@ -1054,7 +1054,7 @@ class Task extends CommonObjectLine if ($filteronproj) { $sql .= natural_search(array("p.ref", "p.title"), $filteronproj); } - if ($filteronprojstatus && $filteronprojstatus != '-1') { + if ($filteronprojstatus && (int) $filteronprojstatus != '-1') { $sql .= " AND p.fk_statut IN (".$this->db->sanitize($filteronprojstatus).")"; } if ($morewherefilter) {