clean code (#35442)
* clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code
This commit is contained in:
parent
21100454f6
commit
00fe10a75f
7 changed files with 60 additions and 156 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2017 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2017 Neil Orley <neil.orley@oeris.fr>
|
||||
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2018-2025 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2018-2022 Thibault FOUCART <support@ptibogxiv.net>
|
||||
* Copyright (C) 2024 Jon Bendtsen <jon.bendtsen.github@jonb.dk>
|
||||
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2023-2024 Frédéric France <frederic.france@free.fr>
|
||||
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2023-2025 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
<?php
|
||||
/* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
/* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
*
|
||||
* 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 = '';
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
<?php
|
||||
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2014-2016 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2016 Florian Henry <florian.henry@atm-consulting.fr>
|
||||
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2014-2016 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2016 Florian Henry <florian.henry@atm-consulting.fr>
|
||||
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
*
|
||||
* 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
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
/* Copyright (C) 2023 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2023 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2025 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
<?php
|
||||
/* Copyright (C) Richard Rondu <rondu.richard@lainwir3d.net>
|
||||
* Copyright (C) 2007-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
|
||||
/* Copyright (C) Richard Rondu <rondu.richard@lainwir3d.net>
|
||||
* Copyright (C) 2007-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2025 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* 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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue