clean code class commondict (#35952)
* add fetchAll in abstract class commondict * add fetchAll in abstract class commondict * add fetchAll in abstract class commondict * add fetchAll in abstract class commondict * add fetchAll in abstract class commondict * add fetchAll in abstract class commondict * add fetchAll in abstract class commondict * clean code
This commit is contained in:
parent
e37c7678a4
commit
03ea0cda01
11 changed files with 19 additions and 127 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/* Copyright (C) 2017-2020 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2019-2024 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2019-2025 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
|
||||
*
|
||||
* 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 '</td>';
|
||||
print '<td class="linecolstock right">'.price(price2num($prod->stock_reel, 'MS')).'</td>';
|
||||
|
|
|
|||
|
|
@ -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 '</td>';
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/* Copyright (C) 2007-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2024-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
|
||||
|
|
|
|||
|
|
@ -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 = '';
|
||||
|
|
|
|||
|
|
@ -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 '<tr><td class="titlefieldmiddle">'.$langs->trans("Duration").'</td><td>';
|
||||
|
|
|
|||
|
|
@ -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 .= '</option>';
|
||||
}
|
||||
|
|
@ -695,7 +695,7 @@ class FormProduct
|
|||
}
|
||||
|
||||
$return .= '>';
|
||||
$return .= $langs->trans($lines->label);
|
||||
$return .= $langs->trans((string) $lines->label);
|
||||
$return .= '</option>';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Reference in a new issue