mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-05 09:08:09 +01:00
clean code (#35183)
* clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code
This commit is contained in:
@@ -12474,54 +12474,6 @@ parameters:
|
||||
count: 2
|
||||
path: ../../../htdocs/fichinter/card.php
|
||||
|
||||
-
|
||||
message: '#^Call to function method_exists\(\) with \$this\(Fichinter\) and ''getLibStatut'' will always evaluate to true\.$#'
|
||||
identifier: function.alreadyNarrowedType
|
||||
count: 1
|
||||
path: ../../../htdocs/fichinter/class/fichinter.class.php
|
||||
|
||||
-
|
||||
message: '#^Call to function method_exists\(\) with \$this\(Fichinter\) and ''getNomUrl'' will always evaluate to true\.$#'
|
||||
identifier: function.alreadyNarrowedType
|
||||
count: 1
|
||||
path: ../../../htdocs/fichinter/class/fichinter.class.php
|
||||
|
||||
-
|
||||
message: '#^Call to function property_exists\(\) with \$this\(Fichinter\) and ''duration'' will always evaluate to true\.$#'
|
||||
identifier: function.alreadyNarrowedType
|
||||
count: 1
|
||||
path: ../../../htdocs/fichinter/class/fichinter.class.php
|
||||
|
||||
-
|
||||
message: '#^Negated boolean expression is always true\.$#'
|
||||
identifier: booleanNot.alwaysTrue
|
||||
count: 7
|
||||
path: ../../../htdocs/fichinter/class/fichinter.class.php
|
||||
|
||||
-
|
||||
message: '#^Property Fichinter\:\:\$ref_client \(string\) in isset\(\) is not nullable\.$#'
|
||||
identifier: isset.property
|
||||
count: 2
|
||||
path: ../../../htdocs/fichinter/class/fichinter.class.php
|
||||
|
||||
-
|
||||
message: '#^Property Fichinter\:\:\$statut \(int\) in isset\(\) is not nullable\.$#'
|
||||
identifier: isset.property
|
||||
count: 1
|
||||
path: ../../../htdocs/fichinter/class/fichinter.class.php
|
||||
|
||||
-
|
||||
message: '#^Variable \$url in empty\(\) always exists and is not falsy\.$#'
|
||||
identifier: empty.variable
|
||||
count: 2
|
||||
path: ../../../htdocs/fichinter/class/fichinter.class.php
|
||||
|
||||
-
|
||||
message: '#^Negated boolean expression is always true\.$#'
|
||||
identifier: booleanNot.alwaysTrue
|
||||
count: 2
|
||||
path: ../../../htdocs/fichinter/class/fichinterligne.class.php
|
||||
|
||||
-
|
||||
message: '#^Right side of && is always false\.$#'
|
||||
identifier: booleanAnd.rightAlwaysFalse
|
||||
|
||||
@@ -929,7 +929,7 @@ if (empty($reshook)) {
|
||||
}
|
||||
if ($id == DICT_PAIEMENT && strlen(GETPOST("code")) >= 6) { // 6 char max on code for payment mode codes
|
||||
$ok = 0;
|
||||
setEventMessages($langs->transnoentities("ErrorFieldMustHaveLessThanXChar", $langs->transnoentities("Code"), 6), null, 'errors');
|
||||
setEventMessages($langs->transnoentities("ErrorFieldMustHaveLessThanXChar", $langs->transnoentities("Code"), '6'), null, 'errors');
|
||||
}
|
||||
|
||||
// Clean some parameters
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
|
||||
/* Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
|
||||
* 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
|
||||
@@ -49,7 +50,7 @@ trait CommonSignedObject
|
||||
'STATUS_SIGNED_SENDER' => 1,
|
||||
'STATUS_SIGNED_RECEIVER' => 2,
|
||||
'STATUS_SIGNED_RECEIVER_ONLINE' => 3,
|
||||
'STATUS_SIGNED_ALL' => 9 // To handle future kind of signature (ex: tripartite contract)
|
||||
'STATUS_SIGNED_ALL' => 9, // To handle future kind of signature (ex: tripartite contract)
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -140,11 +141,9 @@ trait CommonSignedObject
|
||||
$sql .= " WHERE rowid = ".((int) $this->id);
|
||||
|
||||
if ($this->db->query($sql)) {
|
||||
if (!$error) {
|
||||
$this->oldcopy = clone $this;
|
||||
}
|
||||
$this->oldcopy = clone $this;
|
||||
|
||||
if (!$error && !$notrigger) {
|
||||
if (!$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger($triggercode, $user);
|
||||
if ($result < 0) {
|
||||
|
||||
@@ -150,13 +150,13 @@ class Fichinter extends CommonObject
|
||||
public $duration;
|
||||
|
||||
/**
|
||||
* @var int status
|
||||
* @var int|null status
|
||||
* @deprecated Use $status instead
|
||||
*/
|
||||
public $statut = 0; // 0=draft, 1=validated, 2=invoiced, 3=Terminate
|
||||
|
||||
/**
|
||||
* @var int status
|
||||
* @var int|null status
|
||||
*/
|
||||
public $status = 0; // 0=draft, 1=validated, 2=invoiced, 3=Terminate
|
||||
|
||||
@@ -305,7 +305,7 @@ class Fichinter extends CommonObject
|
||||
if (!is_numeric($this->duration)) {
|
||||
$this->duration = 0;
|
||||
}
|
||||
if (isset($this->ref_client)) {
|
||||
if (!empty($this->ref_client)) {
|
||||
$this->ref_client = trim($this->ref_client);
|
||||
}
|
||||
|
||||
@@ -432,7 +432,7 @@ class Fichinter extends CommonObject
|
||||
if (!dol_strlen((string) $this->fk_project)) {
|
||||
$this->fk_project = 0;
|
||||
}
|
||||
if (isset($this->ref_client)) {
|
||||
if (!empty($this->ref_client)) {
|
||||
$this->ref_client = trim($this->ref_client);
|
||||
}
|
||||
|
||||
@@ -463,11 +463,9 @@ class Fichinter extends CommonObject
|
||||
|
||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||
if ($this->db->query($sql)) {
|
||||
if (!$error) {
|
||||
$result = $this->insertExtraFields();
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
$result = $this->insertExtraFields();
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error && !$notrigger) {
|
||||
@@ -596,12 +594,10 @@ class Fichinter extends CommonObject
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
if (!$error) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('FICHINTER_UNVALIDATE', $user);
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('FICHINTER_UNVALIDATE', $user);
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
@@ -640,7 +636,7 @@ class Fichinter extends CommonObject
|
||||
$now = dol_now();
|
||||
|
||||
// Define new ref
|
||||
if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
|
||||
if ((preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
|
||||
$num = $this->getNextNumRef($this->thirdparty);
|
||||
} else {
|
||||
$num = $this->ref;
|
||||
@@ -976,13 +972,13 @@ class Fichinter extends CommonObject
|
||||
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
|
||||
}
|
||||
|
||||
if ($option == 'nolink' || empty($url)) {
|
||||
if ($option == 'nolink') {
|
||||
$linkstart = '<span';
|
||||
} else {
|
||||
$linkstart = '<a href="'.$url.'"';
|
||||
}
|
||||
$linkstart .= $linkclose.'>';
|
||||
if ($option == 'nolink' || empty($url)) {
|
||||
if ($option == 'nolink') {
|
||||
$linkend = '</span>';
|
||||
} else {
|
||||
$linkend = '</a>';
|
||||
@@ -1119,7 +1115,7 @@ class Fichinter extends CommonObject
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
if (!$error && !$notrigger) {
|
||||
if (!$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('FICHINTER_DELETE', $user);
|
||||
if ($result < 0) {
|
||||
@@ -1131,11 +1127,9 @@ class Fichinter extends CommonObject
|
||||
}
|
||||
|
||||
// Delete linked object
|
||||
if (!$error) {
|
||||
$res = $this->deleteObjectLinked();
|
||||
if ($res < 0) {
|
||||
$error++;
|
||||
}
|
||||
$res = $this->deleteObjectLinked();
|
||||
if ($res < 0) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
// Delete linked contacts
|
||||
@@ -1510,6 +1504,7 @@ class Fichinter extends CommonObject
|
||||
$this->note_private = 'Private note';
|
||||
$this->note_public = 'SPECIMEN';
|
||||
$this->duration = 0;
|
||||
$this->user_creation_id = 1;
|
||||
$nbp = 25;
|
||||
$xnbp = 0;
|
||||
while ($xnbp < $nbp) {
|
||||
@@ -1673,21 +1668,20 @@ class Fichinter extends CommonObject
|
||||
$return .= img_picto('', $this->picto);
|
||||
$return .= '</span>';
|
||||
$return .= '<div class="info-box-content">';
|
||||
$return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).'</span>';
|
||||
$return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">' . $this->getNomUrl() . '</span>';
|
||||
if ($selected >= 0) {
|
||||
$return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
|
||||
}
|
||||
if (!empty($arraydata['thirdparty'])) {
|
||||
$tmpthirdparty = $arraydata['thirdparty'];
|
||||
'@phan-var-force Societe $tmpthirdparty';
|
||||
/** @var Societe $tmpthirdparty */
|
||||
$return .= '<br><span class="info-box-label">'.$tmpthirdparty->getNomUrl(1).'</span>';
|
||||
}
|
||||
if (property_exists($this, 'duration')) {
|
||||
if (!empty($this->duration)) {
|
||||
$return .= '<br><span class="info-box-label ">'.$langs->trans("Duration").' : '.convertSecondToTime($this->duration, 'allhourmin').'</span>';
|
||||
}
|
||||
if (method_exists($this, 'getLibStatut')) {
|
||||
$return .= '<br><div class="info-box-status">'.$this->getLibStatut(3).'</div>';
|
||||
}
|
||||
$return .= '<br><div class="info-box-status">'.$this->getLibStatut(3).'</div>';
|
||||
$return .= '</div>';
|
||||
$return .= '</div>';
|
||||
$return .= '</div>';
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2015-2020 Charlene Benke <charlie@patas-monkey.com>
|
||||
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
* 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) 2023-2024 William Mead <william.mead@manchenumerique.fr>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
*
|
||||
@@ -204,11 +204,9 @@ class FichinterLigne extends CommonObjectLine
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'fichinterdet');
|
||||
$this->rowid = $this->id;
|
||||
|
||||
if (!$error) {
|
||||
$result = $this->insertExtraFields();
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
$result = $this->insertExtraFields();
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
|
||||
@@ -270,11 +268,9 @@ class FichinterLigne extends CommonObjectLine
|
||||
dol_syslog("FichinterLigne::update", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
if (!$error) {
|
||||
$result = $this->insertExtraFields();
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
$result = $this->insertExtraFields();
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
$result = $this->update_total();
|
||||
|
||||
Reference in New Issue
Block a user