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:
Frédéric FRANCE
2025-09-02 22:46:55 +02:00
committed by GitHub
parent 5b4295912e
commit 24bd6d918a
5 changed files with 36 additions and 95 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -1,5 +1,6 @@
<?php
/* 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;
}
if (!$error && !$notrigger) {
if (!$notrigger) {
// Call trigger
$result = $this->call_trigger($triggercode, $user);
if ($result < 0) {

View File

@@ -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,12 +463,10 @@ 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++;
}
}
if (!$error && !$notrigger) {
// Call trigger
@@ -596,13 +594,11 @@ 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++;
}
}
if (!$error) {
$this->status = self::STATUS_DRAFT;
@@ -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,12 +1127,10 @@ class Fichinter extends CommonObject
}
// Delete linked object
if (!$error) {
$res = $this->deleteObjectLinked();
if ($res < 0) {
$error++;
}
}
// Delete linked contacts
if (!$error) {
@@ -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 .= '</div>';
$return .= '</div>';
$return .= '</div>';

View File

@@ -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,12 +204,10 @@ 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->update_total();
@@ -270,12 +268,10 @@ 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->update_total();
if ($result > 0) {