diff --git a/dev/build/phpstan/phpstan-baseline.neon b/dev/build/phpstan/phpstan-baseline.neon index 115e70be9ea..091061e9512 100644 --- a/dev/build/phpstan/phpstan-baseline.neon +++ b/dev/build/phpstan/phpstan-baseline.neon @@ -1476,12 +1476,6 @@ parameters: count: 3 path: ../../../htdocs/bom/bom_net_needs.php - - - message: '#^Property CommonDict\:\:\$label \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 1 - path: ../../../htdocs/bom/bom_net_needs.php - - message: '#^Left side of && is always false\.$#' identifier: booleanAnd.leftAlwaysFalse @@ -1518,12 +1512,6 @@ parameters: count: 1 path: ../../../htdocs/bom/tpl/objectline_title.tpl.php - - - message: '#^Property CommonDict\:\:\$label \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 1 - path: ../../../htdocs/bom/tpl/objectline_view.tpl.php - - message: '#^If condition is always false\.$#' identifier: if.alwaysFalse @@ -3390,24 +3378,12 @@ parameters: count: 1 path: ../../../htdocs/compta/paiement/class/cpaiement.class.php - - - message: '#^Property CommonDict\:\:\$code \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/compta/paiement/class/cpaiement.class.php - - message: '#^Property CommonDict\:\:\$id \(int\) in isset\(\) is not nullable\.$#' identifier: isset.property count: 1 path: ../../../htdocs/compta/paiement/class/cpaiement.class.php - - - message: '#^Property CommonDict\:\:\$label \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 2 - path: ../../../htdocs/compta/paiement/class/cpaiement.class.php - - message: '#^Property Cpaiement\:\:\$accountancy_code \(string\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -5100,42 +5076,12 @@ parameters: count: 4 path: ../../../htdocs/core/class/ccountry.class.php - - - message: '#^Property CommonDict\:\:\$code \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/core/class/ccountry.class.php - - - - message: '#^Property CommonDict\:\:\$label \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/core/class/ccountry.class.php - - - - message: '#^Method CGenericDic\:\:fetchAll\(\) has parameter \$filter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: ../../../htdocs/core/class/cgenericdic.class.php - - message: '#^Negated boolean expression is always true\.$#' identifier: booleanNot.alwaysTrue count: 1 path: ../../../htdocs/core/class/cgenericdic.class.php - - - message: '#^Property CGenericDic\:\:\$code \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/core/class/cgenericdic.class.php - - - - message: '#^Property CGenericDic\:\:\$label \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/core/class/cgenericdic.class.php - - message: '#^Method CLeadStatus\:\:fetchAll\(\) return type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -5154,24 +5100,12 @@ parameters: count: 2 path: ../../../htdocs/core/class/cleadstatus.class.php - - - message: '#^Property CommonDict\:\:\$code \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 2 - path: ../../../htdocs/core/class/cleadstatus.class.php - - message: '#^Property CommonDict\:\:\$id \(int\) in isset\(\) is not nullable\.$#' identifier: isset.property count: 1 path: ../../../htdocs/core/class/cleadstatus.class.php - - - message: '#^Property CommonDict\:\:\$label \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 3 - path: ../../../htdocs/core/class/cleadstatus.class.php - - message: '#^Property Comment\:\:\$description \(string\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -5604,24 +5538,12 @@ parameters: count: 1 path: ../../../htdocs/core/class/conf.class.php - - - message: '#^Property CommonDict\:\:\$code \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 2 - path: ../../../htdocs/core/class/cproductnature.class.php - - message: '#^Property CommonDict\:\:\$id \(int\) in isset\(\) is not nullable\.$#' identifier: isset.property count: 1 path: ../../../htdocs/core/class/cproductnature.class.php - - - message: '#^Property CommonDict\:\:\$label \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 2 - path: ../../../htdocs/core/class/cproductnature.class.php - - message: '#^Property Cstate\:\:\$code_departement \(string\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -5646,12 +5568,6 @@ parameters: count: 1 path: ../../../htdocs/core/class/cstate.class.php - - - message: '#^Property CommonDict\:\:\$code \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/core/class/ctypent.class.php - - message: '#^Property CommonDict\:\:\$id \(int\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -5676,18 +5592,6 @@ parameters: count: 1 path: ../../../htdocs/core/class/ctyperesource.class.php - - - message: '#^Property CommonDict\:\:\$code \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/core/class/ctyperesource.class.php - - - - message: '#^Property CommonDict\:\:\$label \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/core/class/ctyperesource.class.php - - message: '#^Property CUnits\:\:\$short_label \(string\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -5706,24 +5610,12 @@ parameters: count: 4 path: ../../../htdocs/core/class/cunits.class.php - - - message: '#^Property CommonDict\:\:\$code \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/core/class/cunits.class.php - - message: '#^Property CommonDict\:\:\$id \(int\) in isset\(\) is not nullable\.$#' identifier: isset.property count: 2 path: ../../../htdocs/core/class/cunits.class.php - - - message: '#^Property CommonDict\:\:\$label \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/core/class/cunits.class.php - - message: '#^Constructor of class DolEditor has an unused parameter \$toolbarlocation\.$#' identifier: constructor.unusedParameter diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 0940b2418fe..e0fe2c9c01f 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -506,7 +506,7 @@ class Setup extends DolibarrApi $obj = $this->db->fetch_object($result); $state = new Cstate($this->db); if ($state->fetch($obj->rowid) > 0) { - if (empty($filter) || stripos($state->label, $filter) !== false) { + if (empty($filter) || stripos((string) $state->label, $filter) !== false) { $list[] = $this->_cleanObjectDatas($state); } } @@ -619,7 +619,7 @@ class Setup extends DolibarrApi // and then apply the filter if there is one. $this->translateLabel($country, $lang, 'Country'); - if (empty($filter) || stripos($country->label, $filter) !== false) { + if (empty($filter) || stripos((string) $country->label, $filter) !== false) { $list[] = $this->_cleanObjectDatas($country); } } diff --git a/htdocs/bom/bom_net_needs.php b/htdocs/bom/bom_net_needs.php index 7d429702060..b5ff6475352 100644 --- a/htdocs/bom/bom_net_needs.php +++ b/htdocs/bom/bom_net_needs.php @@ -1,6 +1,6 @@ - * Copyright (C) 2019-2024 Frédéric France + * Copyright (C) 2019-2025 Frédéric France * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify @@ -332,7 +332,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php'; $unit = new CUnits($db); $unit->fetch((int) $elem['fk_unit']); - print(isset($unit->label) ? " ".$langs->trans(ucwords($unit->label))." " : ''); + print(isset($unit->label) ? " ".$langs->trans(ucwords((string) $unit->label))." " : ''); } print ''; print ''.price(price2num($prod->stock_reel, 'MS')).''; diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index d9162882023..297885e4bdd 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -168,7 +168,7 @@ if ($filtertype != 1) { // Product require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php'; $unit = new CUnits($this->db); $unit->fetch($line->fk_unit); - print(isset($unit->label) ? " ".$langs->trans(ucwords($unit->label))." " : ''); + print(isset($unit->label) ? " ".$langs->trans(ucwords((string) $unit->label))." " : ''); } print ''; diff --git a/htdocs/core/class/cgenericdic.class.php b/htdocs/core/class/cgenericdic.class.php index 137b828db78..840326011e4 100644 --- a/htdocs/core/class/cgenericdic.class.php +++ b/htdocs/core/class/cgenericdic.class.php @@ -49,12 +49,12 @@ class CGenericDic extends CommonDict public $lines = array(); /** - * @var string + * @var ?string */ public $code; /** - * @var string Label + * @var ?string Label */ public $label; @@ -225,7 +225,7 @@ class CGenericDic extends CommonDict * @param string $sortfield Sort field * @param int $limit Limit * @param int $offset offset limit - * @param string|array $filter filter USF + * @param string|string[] $filter filter USF * @param string $filtermode filter mode (AND or OR) * @return int Return integer <0 if KO, >0 if OK */ @@ -444,7 +444,7 @@ class CGenericDic extends CommonDict dol_syslog(__METHOD__, LOG_DEBUG); $error = 0; - $object = new Ctyperesource($this->db); + $object = new CGenericDic($this->db); $this->db->begin(); diff --git a/htdocs/core/class/commondict.class.php b/htdocs/core/class/commondict.class.php index 240fded7ea9..c1ee447dff2 100644 --- a/htdocs/core/class/commondict.class.php +++ b/htdocs/core/class/commondict.class.php @@ -55,12 +55,12 @@ abstract class CommonDict public $entity; /** - * @var string The code + * @var ?string The code */ public $code; /** - * @var string The label + * @var ?string The label */ public $label; diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php index 2a9fa4f0c8f..c7b7de24908 100644 --- a/htdocs/core/class/cunits.class.php +++ b/htdocs/core/class/cunits.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2024-2025 MDW - * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024-2025 Frédéric France * * 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 diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 70a7029982d..3db8392b363 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -957,9 +957,9 @@ function measuringUnitString($unitid, $measuring_style = '', $unitscale = null, if ($use_short_label == 1) { $labeltoreturn = $measuringUnits->records[key($measuringUnits->records)]->short_label; } elseif ($use_short_label == 2) { - $labeltoreturn = $outputlangs->transnoentitiesnoconv(ucfirst($measuringUnits->records[key($measuringUnits->records)]->label).'Short'); + $labeltoreturn = $outputlangs->transnoentitiesnoconv(ucfirst((string) $measuringUnits->records[key($measuringUnits->records)]->label).'Short'); } else { - $labeltoreturn = $outputlangs->transnoentitiesnoconv($measuringUnits->records[key($measuringUnits->records)]->label); + $labeltoreturn = $outputlangs->transnoentitiesnoconv((string) $measuringUnits->records[key($measuringUnits->records)]->label); } } else { $labeltoreturn = ''; diff --git a/htdocs/product/card.php b/htdocs/product/card.php index ae9cc460a94..e771e54d548 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -2873,7 +2873,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio $result = $measuringUnits->fetchAll('', 'scale', 0, 0, ['t.active' => 1, 't.unit_type' => 'time']); if ($result !== -1) { foreach ($measuringUnits->records as $record) { - $durations[$record->short_label] = dol_ucfirst($record->label) . $plural; + $durations[$record->short_label] = dol_ucfirst((string) $record->label) . $plural; } } print ''.$langs->trans("Duration").''; diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 63c23c4f77f..1bb4e0ca8e3 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -624,9 +624,9 @@ class FormProduct } $return .= '>'; if ($measuring_style == 'time') { - $return .= $langs->trans(ucfirst($lines->label)); + $return .= $langs->trans(ucfirst((string) $lines->label)); } else { - $return .= $langs->trans($lines->label); + $return .= $langs->trans((string) $lines->label); } $return .= ''; } @@ -695,7 +695,7 @@ class FormProduct } $return .= '>'; - $return .= $langs->trans($lines->label); + $return .= $langs->trans((string) $lines->label); $return .= ''; } } diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 8af2dd74993..ecea04a1ade 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -1060,7 +1060,7 @@ if (getDolGlobalString('MEMBER_SKIP_TABLE') || getDolGlobalString('MEMBER_NEWFOR $result = $measuringUnits->fetchAll('', '', 0, 0, array('t.active' => 1)); $units = array(); foreach ($measuringUnits->records as $lines) { - $units[$lines->short_label] = $langs->trans(ucfirst($lines->label)); + $units[$lines->short_label] = $langs->trans(ucfirst((string) $lines->label)); } $publiccounters = getDolGlobalString("MEMBER_COUNTERS_ARE_PUBLIC");