diff --git a/dev/build/phpstan/phpstan-baseline.neon b/dev/build/phpstan/phpstan-baseline.neon index be280491075..feeee73df53 100644 --- a/dev/build/phpstan/phpstan-baseline.neon +++ b/dev/build/phpstan/phpstan-baseline.neon @@ -3642,12 +3642,6 @@ parameters: count: 4 path: ../../../htdocs/compta/paiement/class/cpaiement.class.php - - - message: '#^Property Cpaiement\:\:\$active \(int\<0, 1\>\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/compta/paiement/class/cpaiement.class.php - - message: '#^Property Cpaiement\:\:\$libelle \(string\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -3930,12 +3924,6 @@ parameters: count: 2 path: ../../../htdocs/compta/sociales/class/cchargesociales.class.php - - - message: '#^Property Cchargesociales\:\:\$active \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 2 - path: ../../../htdocs/compta/sociales/class/cchargesociales.class.php - - message: '#^Property Cchargesociales\:\:\$code \(string\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -5430,12 +5418,6 @@ parameters: count: 4 path: ../../../htdocs/core/class/ccountry.class.php - - - message: '#^Property CommonDict\:\:\$active \(int\<0, 1\>\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/core/class/ccountry.class.php - - message: '#^Property CommonDict\:\:\$code \(string\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -5460,12 +5442,6 @@ parameters: count: 1 path: ../../../htdocs/core/class/cgenericdic.class.php - - - message: '#^Property CGenericDic\:\:\$active \(int\<0, 1\>\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/core/class/cgenericdic.class.php - - message: '#^Property CGenericDic\:\:\$code \(string\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -5496,12 +5472,6 @@ parameters: count: 2 path: ../../../htdocs/core/class/cleadstatus.class.php - - - message: '#^Property CommonDict\:\:\$active \(int\<0, 1\>\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 2 - path: ../../../htdocs/core/class/cleadstatus.class.php - - message: '#^Property CommonDict\:\:\$code \(string\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -5952,12 +5922,6 @@ parameters: count: 1 path: ../../../htdocs/core/class/conf.class.php - - - message: '#^Property CommonDict\:\:\$active \(int\<0, 1\>\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 2 - path: ../../../htdocs/core/class/cproductnature.class.php - - message: '#^Property CommonDict\:\:\$code \(string\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -5976,48 +5940,6 @@ parameters: count: 2 path: ../../../htdocs/core/class/cproductnature.class.php - - - message: '#^Property CommonDict\:\:\$active \(int\<0, 1\>\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/core/class/cregion.class.php - - - - message: '#^Property CommonDict\:\:\$id \(int\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 1 - path: ../../../htdocs/core/class/cregion.class.php - - - - message: '#^Property Cregion\:\:\$cheflieu \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/core/class/cregion.class.php - - - - message: '#^Property Cregion\:\:\$code_region \(int\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/core/class/cregion.class.php - - - - message: '#^Property Cregion\:\:\$fk_pays \(int\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/core/class/cregion.class.php - - - - message: '#^Property Cregion\:\:\$name \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/core/class/cregion.class.php - - - - message: '#^Property CommonDict\:\:\$active \(int\<0, 1\>\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/core/class/cstate.class.php - - message: '#^Property Cstate\:\:\$code_departement \(string\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -6042,12 +5964,6 @@ parameters: count: 1 path: ../../../htdocs/core/class/cstate.class.php - - - message: '#^Property CommonDict\:\:\$active \(int\<0, 1\>\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/core/class/ctypent.class.php - - message: '#^Property CommonDict\:\:\$code \(string\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -6078,12 +5994,6 @@ parameters: count: 1 path: ../../../htdocs/core/class/ctyperesource.class.php - - - message: '#^Property CommonDict\:\:\$active \(int\<0, 1\>\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 4 - path: ../../../htdocs/core/class/ctyperesource.class.php - - message: '#^Property CommonDict\:\:\$code \(string\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -6114,12 +6024,6 @@ parameters: count: 4 path: ../../../htdocs/core/class/cunits.class.php - - - message: '#^Property CommonDict\:\:\$active \(int\<0, 1\>\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 3 - path: ../../../htdocs/core/class/cunits.class.php - - message: '#^Property CommonDict\:\:\$code \(string\) in isset\(\) is not nullable\.$#' identifier: isset.property diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 164f2134b88..adfd077542c 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -3,7 +3,7 @@ * Copyright (C) 2016 Laurent Destailleur * Copyright (C) 2017 Regis Houssin * Copyright (C) 2017 Neil Orley - * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2018-2025 Frédéric France * Copyright (C) 2018-2022 Thibault FOUCART * Copyright (C) 2024 Jon Bendtsen * Copyright (C) 2024-2025 MDW @@ -389,7 +389,7 @@ class Setup extends DolibarrApi $obj = $this->db->fetch_object($result); $region = new Cregion($this->db); if ($region->fetch($obj->rowid) > 0) { - if (empty($filter) || stripos($region->name, $filter) !== false) { + if (empty($filter) || stripos((string) $region->name, $filter) !== false) { $list[] = $this->_cleanObjectDatas($region); } } diff --git a/htdocs/compta/paiement/class/cpaiement.class.php b/htdocs/compta/paiement/class/cpaiement.class.php index ad4cb13dfdb..b997d2adab1 100644 --- a/htdocs/compta/paiement/class/cpaiement.class.php +++ b/htdocs/compta/paiement/class/cpaiement.class.php @@ -1,9 +1,9 @@ - * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015 Florian Henry - * Copyright (C) 2015 Raphaël Doursenaud - * Copyright (C) 2023-2024 Frédéric France +/* Copyright (C) 2007-2012 Laurent Destailleur + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2015 Florian Henry + * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2023-2025 Frédéric France * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify @@ -56,14 +56,12 @@ class Cpaiement extends CommonDict * @var string */ public $type; - /** - * @var int<0,1> - */ - public $active; + /** * @var string */ public $accountancy_code; + /** * @var string */ diff --git a/htdocs/compta/sociales/class/cchargesociales.class.php b/htdocs/compta/sociales/class/cchargesociales.class.php index d6cb25828ce..dc5451a8a7f 100644 --- a/htdocs/compta/sociales/class/cchargesociales.class.php +++ b/htdocs/compta/sociales/class/cchargesociales.class.php @@ -1,10 +1,10 @@ - * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015 Florian Henry - * Copyright (C) 2015 Raphaël Doursenaud - * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW +/* Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2015 Florian Henry + * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2024-2025 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 @@ -28,8 +28,7 @@ // Put here all includes required by your class file //require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + /** * Class Cchargesociales @@ -72,7 +71,7 @@ class Cchargesociales */ public $deductible; /** - * @var string + * @var ?int<0,1> */ public $active; /** @@ -81,7 +80,7 @@ class Cchargesociales public $code; /** - * @var int ID + * @var ?int ID */ public $fk_pays; @@ -127,13 +126,17 @@ class Cchargesociales array( 'libelle', 'deductible', - 'active', 'code', - 'fk_pays', 'module', 'accountancy_code', ) ); + if (isset($this->fk_pays)) { + $this->fk_pays = (int) $this->fk_pays; + } + if (isset($this->active)) { + $this->active = (int) $this->active; + } // Check parameters // Put here code to add control on parameters values @@ -150,7 +153,7 @@ class Cchargesociales $sql .= ') VALUES ('; $sql .= ' '.(!isset($this->libelle) ? 'NULL' : "'".$this->db->escape($this->libelle)."'").','; $sql .= ' '.(!isset($this->deductible) ? 'NULL' : $this->deductible).','; - $sql .= ' '.(!isset($this->active) ? 'NULL' : $this->active).','; + $sql .= ' ' . (int) $this->active . ','; $sql .= ' '.(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").','; $sql .= ' '.(!isset($this->fk_pays) ? 'NULL' : $this->fk_pays).','; $sql .= ' '.(!isset($this->module) ? 'NULL' : "'".$this->db->escape($this->module)."'").','; @@ -271,14 +274,17 @@ class Cchargesociales array( 'libelle', 'deductible', - 'active', 'code', - 'fk_pays', 'module', 'accountancy_code', ) ); - + if (isset($this->fk_pays)) { + $this->fk_pays = (int) $this->fk_pays; + } + if (isset($this->active)) { + $this->active = (int) $this->active; + } // Check parameters // Put here code to add a control on parameters values @@ -542,7 +548,7 @@ class Cchargesociales $this->libelle = ''; $this->label = ''; $this->deductible = ''; - $this->active = ''; + $this->active = 0; $this->code = ''; $this->fk_pays = 0; $this->module = ''; diff --git a/htdocs/core/class/cgenericdic.class.php b/htdocs/core/class/cgenericdic.class.php index 9c4e3317775..137b828db78 100644 --- a/htdocs/core/class/cgenericdic.class.php +++ b/htdocs/core/class/cgenericdic.class.php @@ -1,10 +1,10 @@ - * Copyright (C) 2014-2016 Juanjo Menent - * Copyright (C) 2016 Florian Henry - * Copyright (C) 2015 Raphaël Doursenaud - * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW +/* Copyright (C) 2007-2012 Laurent Destailleur + * Copyright (C) 2014-2016 Juanjo Menent + * Copyright (C) 2016 Florian Henry + * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2024-2025 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 @@ -58,12 +58,6 @@ class CGenericDic extends CommonDict */ public $label; - /** - * @var int<0,1> - */ - public $active; - - /** * Constructor * diff --git a/htdocs/core/class/commondict.class.php b/htdocs/core/class/commondict.class.php index f6dc107025b..240fded7ea9 100644 --- a/htdocs/core/class/commondict.class.php +++ b/htdocs/core/class/commondict.class.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2023 Laurent Destailleur + * Copyright (C) 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 @@ -64,7 +65,7 @@ abstract class CommonDict public $label; /** - * @var int<0,1> 1 if the entry is active, 0 if not + * @var ?int<0,1> 1 if the entry is active, 0 if not */ public $active; } diff --git a/htdocs/core/class/cregion.class.php b/htdocs/core/class/cregion.class.php index 6d5801f5279..54431f9a933 100644 --- a/htdocs/core/class/cregion.class.php +++ b/htdocs/core/class/cregion.class.php @@ -1,7 +1,8 @@ - * Copyright (C) 2007-2011 Laurent Destailleur - * Copyright (C) 2024-2025 MDW +/* Copyright (C) Richard Rondu + * Copyright (C) 2007-2011 Laurent Destailleur + * Copyright (C) 2024-2025 MDW + * Copyright (C) 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 @@ -36,22 +37,22 @@ class Cregion extends CommonDict //public $table_element = 'c_regions'; //!< Name of table without prefix where object is stored /** - * @var int The code of the region + * @var ?int The code of the region */ public $code_region; /** - * @var int The ID of the country of the region + * @var ?int The ID of the country of the region */ public $fk_pays; /** - * @var string The name of the region + * @var ?string The name of the region */ public $name; /** - * @var string The reference of the "chef-lieu" of the region + * @var ?string The reference of the "chef-lieu" of the region * A.k.a. the administrative headquarter of the region * (examples: HU33, PT9, 97601) */ @@ -89,10 +90,10 @@ class Cregion extends CommonDict $this->fk_pays = (int) $this->fk_pays; } if (isset($this->name)) { - $this->name = trim($this->name); + $this->name = trim((string) $this->name); } if (isset($this->cheflieu)) { - $this->cheflieu = trim($this->cheflieu); + $this->cheflieu = trim((string) $this->cheflieu); } if (isset($this->active)) { $this->active = (int) $this->active; @@ -110,12 +111,12 @@ class Cregion extends CommonDict $sql .= "cheflieu,"; $sql .= "active"; $sql .= ") VALUES ("; - $sql .= " ".(!isset($this->id) ? 'NULL' : (int) $this->id).","; - $sql .= " ".(!isset($this->code_region) ? 'NULL' : (int) $this->code_region).","; - $sql .= " ".(!isset($this->fk_pays) ? 'NULL' : (int) $this->fk_pays).","; - $sql .= " ".(!isset($this->name) ? 'NULL' : "'".$this->db->escape($this->name)."'").","; - $sql .= " ".(!isset($this->cheflieu) ? 'NULL' : "'".$this->db->escape($this->cheflieu)."'").","; - $sql .= " ".(!isset($this->active) ? 'NULL' : "'".$this->db->escape((string) $this->active)."'"); + $sql .= (int) $this->id; + $sql .= ", " . (!isset($this->code_region) ? 'NULL' : (int) $this->code_region); + $sql .= ", " . (int) $this->fk_pays; + $sql .= ", " . (!isset($this->name) ? 'NULL' : "'".$this->db->escape($this->name) . "'"); + $sql .= ", " . (!isset($this->cheflieu) ? 'NULL' : "'".$this->db->escape($this->cheflieu) . "'"); + $sql .= ", " . (int) $this->active; $sql .= ")"; $this->db->begin(); @@ -160,7 +161,7 @@ class Cregion extends CommonDict $sql .= " t.rowid,"; $sql .= " t.code_region,"; $sql .= " t.fk_pays,"; - $sql .= " t.nom,"; + $sql .= " t.nom as name,"; $sql .= " t.cheflieu,"; $sql .= " t.active"; $sql .= " FROM ".$this->db->prefix()."c_regions as t"; @@ -182,9 +183,9 @@ class Cregion extends CommonDict $this->id = $obj->rowid; $this->code_region = (int) $obj->code_region; $this->fk_pays = (int) $obj->fk_pays; - $this->name = $obj->nom; + $this->name = $obj->name; $this->cheflieu = $obj->cheflieu; - $this->active = $obj->active; + $this->active = (int) $obj->active; } $this->db->free($resql);