diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 3f0f9365f25..cfc989ba39a 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -9,7 +9,7 @@ */ return [ // # Issue statistics: - // PhanTypeMismatchArgument : 2300+ occurrences + // PhanTypeMismatchArgument : 2230+ occurrences // PhanUndeclaredProperty : 530+ occurrences // PhanTypeMismatchArgumentNullable : 430+ occurrences // PhanUndeclaredGlobalVariable : 190+ occurrences @@ -593,16 +593,8 @@ return [ 'htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php' => ['PhanUndeclaredProperty'], 'htdocs/partnership/partnership_card.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/partnership/partnership_list.php' => ['PhanUndeclaredProperty'], - 'htdocs/product/admin/price_rules.php' => ['PhanTypeMismatchArgument'], - 'htdocs/product/admin/product.php' => ['PhanPluginEmptyStatementIf', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/product/admin/product_tools.php' => ['PhanTypeMismatchArgument'], - 'htdocs/product/ajax/products.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/product/canvas/product/actions_card_product.class.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'], - 'htdocs/product/canvas/service/actions_card_service.class.php' => ['PhanTypeMismatchArgument'], - 'htdocs/product/card.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanUndeclaredGlobalVariable'], 'htdocs/product/class/api_products.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgument', 'PhanUndeclaredProperty'], 'htdocs/product/class/html.formproduct.class.php' => ['PhanUndeclaredProperty'], - 'htdocs/product/class/product.class.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'], 'htdocs/product/class/productcustomerprice.class.php' => ['PhanTypeMismatchArgument'], 'htdocs/product/class/productfournisseurprice.class.php' => ['PhanUndeclaredMethod', 'PhanUndeclaredProperty'], 'htdocs/product/composition/card.php' => ['PhanTypeMismatchArgument'], diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index def20558866..1ce3201aa9c 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -6,7 +6,7 @@ * Copyright (C) 2012-2014 Raphaël Doursenaud * Copyright (C) 2013 Florian Henry * Copyright (C) 2017 Juanjo Menent - * 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 @@ -153,7 +153,7 @@ print ''; if ($filtertype != 1) { // Product if (getDolGlobalInt('PRODUCT_USE_UNITS')) { // For product, unit is shown only if option PRODUCT_USE_UNITS is on print ''; - $label = measuringUnitString($line->fk_unit, '', '', 1); + $label = measuringUnitString((int) $line->fk_unit, '', null, 1); if ($label !== '') { print $langs->trans($label); } @@ -359,7 +359,7 @@ if ($resql) { $total_cost += $sub_bom->total_cost * $sub_bom_line->qty * (float) $line->qty; } elseif ($sub_bom_product->type == Product::TYPE_SERVICE && isModEnabled('workstation') && !empty($sub_bom_product->fk_default_workstation)) { //Convert qty to hour - $unit = measuringUnitString($sub_bom_line->fk_unit, '', '', 1); + $unit = measuringUnitString($sub_bom_line->fk_unit, '', null, 1); $qty = convertDurationtoHour($sub_bom_line->qty, $unit); $workstation = new Workstation($this->db); $res = $workstation->fetch($sub_bom_product->fk_default_workstation); diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 65f87ed9870..4bb9a8fbb08 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -7,7 +7,7 @@ * Copyright (C) 2016-2023 Charlene Benke * Copyright (C) 2018-2025 Frédéric France * Copyright (C) 2020 Josep Lluís Amador - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Mélina Joum * Copyright (C) 2024 Nick Fragoulis * @@ -1055,7 +1055,7 @@ abstract class CommonDocGenerator $array_key.'_tracking_number' => $object->tracking_number, $array_key.'_tracking_url' => $object->tracking_url, $array_key.'_shipping_method' => $object->listmeths[0]['libelle'], - $array_key.'_weight' => $object->trueWeight.' '.measuringUnitString(0, 'weight', (string) $object->weight_units), + $array_key.'_weight' => $object->trueWeight.' '.measuringUnitString(0, 'weight', $object->weight_units), $array_key.'_width' => $object->trueWidth.' '.measuringUnitString(0, 'size', $object->width_units), $array_key.'_height' => $object->trueHeight.' '.measuringUnitString(0, 'size', $object->height_units), $array_key.'_depth' => $object->trueDepth.' '.measuringUnitString(0, 'size', $object->depth_units), @@ -1092,31 +1092,31 @@ abstract class CommonDocGenerator // Set trueVolume and volume_units not currently stored into database if ($object->trueWidth && $object->trueHeight && $object->trueDepth) { - $object->trueVolume = $object->trueWidth * $object->trueHeight * $object->trueDepth; - $object->volume_units = $object->size_units * 3; + $object->trueVolume = $object->trueWidth * $object->trueHeight * $object->trueDepth; + $object->volume_units = $object->size_units * 3; } $array_shipment[$array_key.'_total_ordered'] = (string) $totalOrdered; $array_shipment[$array_key.'_total_toship'] = (string) $totalToShip; if ($object->trueWeight) { - $array_shipment[$array_key.'_total_weight'] = (empty($totalWeight)) ? '' : showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); + $array_shipment[$array_key.'_total_weight'] = (empty($totalWeight)) ? '' : showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); } elseif (!empty($totalWeight)) { - $array_shipment[$array_key.'_total_weight'] = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs, -1, 'no', 1); + $array_shipment[$array_key.'_total_weight'] = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs, -1, 'no', 1); } else { - $array_shipment[$array_key.'_total_weight'] = ""; + $array_shipment[$array_key.'_total_weight'] = ""; } if (!empty($object->trueVolume)) { if ($object->volume_units < 50) { - $array_shipment[$array_key.'_total_volume'] = (empty($totalVolume)) ? '' : showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); + $array_shipment[$array_key.'_total_volume'] = (empty($totalVolume)) ? '' : showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); } else { - $array_shipment[$array_key.'_total_volume'] = (empty($totalVolume)) ? '' : price($object->trueVolume, 0, $outputlangs, 0, 0).' '.measuringUnitString(0, "volume", $object->volume_units); + $array_shipment[$array_key.'_total_volume'] = (empty($totalVolume)) ? '' : price($object->trueVolume, 0, $outputlangs, 0, 0).' '.measuringUnitString(0, "volume", $object->volume_units); } } elseif (!empty($totalVolume)) { - $array_shipment[$array_key.'_total_volume'] = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs, -1, 'no', 1); + $array_shipment[$array_key.'_total_volume'] = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs, -1, 'no', 1); } else { - $array_shipment[$array_key.'_total_volume'] = ""; + $array_shipment[$array_key.'_total_volume'] = ""; } return $array_shipment; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 149e23b3f9f..dd832818958 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -204,7 +204,7 @@ class Form * @param string $text Text of label (not used in this function) * @param string $htmlname Name of select field * @param string|int $value Value to show/edit - * @param CommonObject $object Object (that we want to show) + * @param CommonObject|ActionsCardProduct|ActionsCardService $object Object (that we want to show) * @param bool|int<0,1> $perm Permission to allow button to edit parameter * @param string $typeofdata Type of data ('string' by default, 'checkbox', 'email', 'phone', 'amount:99', 'numeric:99', * 'text' or 'textarea:rows:cols%', 'safehtmlstring', 'restricthtml', diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 948907ff469..800913719ee 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -5,7 +5,7 @@ * Copyright (C) 2017 Rui Strecht * Copyright (C) 2020 Open-Dsi * 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 @@ -249,9 +249,9 @@ class FormCompany extends Form * The key of the list is the code (there can be several entries for a given code but in this case, the country field differs). * Thus the links with the departments are done on a department independently of its name. * - * @param string $selected Code state preselected - * @param int $country_codeid 0=list for all countries, otherwise country code or country rowid to show - * @param string $htmlname Id of department + * @param string $selected Code state preselected + * @param int|string $country_codeid 0=list for all countries, otherwise country code or country rowid to show + * @param string $htmlname Id of department * @return void */ public function select_departement($selected = '', $country_codeid = 0, $htmlname = 'state_id') @@ -267,11 +267,11 @@ class FormCompany extends Form * The key of the list is the code (there can be several entries for a given code but in this case, the country field differs). * Thus the links with the departments are done on a department independently of its name. * - * @param int $selected Code state preselected (must be state id) - * @param int $country_codeid Country code or id: 0=list for all countries, otherwise country code or country rowid to show - * @param string $htmlname Id of department. If '', we want only the string with