diff --git a/dev/build/phpstan/phpstan-baseline.neon b/dev/build/phpstan/phpstan-baseline.neon index 9444300cfd6..fa230232d56 100644 --- a/dev/build/phpstan/phpstan-baseline.neon +++ b/dev/build/phpstan/phpstan-baseline.neon @@ -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 diff --git a/htdocs/core/class/commonsignedobject.class.php b/htdocs/core/class/commonsignedobject.class.php index 211c513fb84..6a2c0c599ea 100644 --- a/htdocs/core/class/commonsignedobject.class.php +++ b/htdocs/core/class/commonsignedobject.class.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2024 William Mead + * 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 @@ -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) { diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 5bf9bd446cb..6ff73e295fa 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -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 = ''; - if ($option == 'nolink' || empty($url)) { + if ($option == 'nolink') { $linkend = ''; } else { $linkend = ''; @@ -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 .= ''; $return .= '
'; - $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + $return .= '' . $this->getNomUrl() . ''; if ($selected >= 0) { $return .= ''; } if (!empty($arraydata['thirdparty'])) { $tmpthirdparty = $arraydata['thirdparty']; '@phan-var-force Societe $tmpthirdparty'; + /** @var Societe $tmpthirdparty */ $return .= '
'.$tmpthirdparty->getNomUrl(1).''; } - if (property_exists($this, 'duration')) { + if (!empty($this->duration)) { $return .= '
'.$langs->trans("Duration").' : '.convertSecondToTime($this->duration, 'allhourmin').''; } - if (method_exists($this, 'getLibStatut')) { - $return .= '
'.$this->getLibStatut(3).'
'; - } + $return .= '
'.$this->getLibStatut(3).'
'; $return .= '
'; $return .= ''; $return .= ''; diff --git a/htdocs/fichinter/class/fichinterligne.class.php b/htdocs/fichinter/class/fichinterligne.class.php index 3a43ea1303a..1a0115c2d13 100644 --- a/htdocs/fichinter/class/fichinterligne.class.php +++ b/htdocs/fichinter/class/fichinterligne.class.php @@ -6,7 +6,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2015-2020 Charlene Benke * Copyright (C) 2018 Nicolas ZABOURI - * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2018-2025 Frédéric France * Copyright (C) 2023-2024 William Mead * Copyright (C) 2024 MDW * @@ -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();