clean code (#35529)

* clean code

* clean code

* clean code
This commit is contained in:
Frédéric FRANCE
2025-09-28 13:54:39 +02:00
committed by GitHub
parent 1466698553
commit 6441c42323
3 changed files with 36 additions and 99 deletions

View File

@@ -9378,60 +9378,6 @@ parameters:
count: 1 count: 1
path: ../../../htdocs/document.php path: ../../../htdocs/document.php
-
message: '#^Negated boolean expression is always true\.$#'
identifier: booleanNot.alwaysTrue
count: 5
path: ../../../htdocs/don/class/paymentdonation.class.php
-
message: '#^Property PaymentDonation\:\:\$amount \(float\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 3
path: ../../../htdocs/don/class/paymentdonation.class.php
-
message: '#^Property PaymentDonation\:\:\$fk_bank \(int\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 3
path: ../../../htdocs/don/class/paymentdonation.class.php
-
message: '#^Property PaymentDonation\:\:\$fk_donation \(int\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 4
path: ../../../htdocs/don/class/paymentdonation.class.php
-
message: '#^Property PaymentDonation\:\:\$fk_typepayment \(int\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 3
path: ../../../htdocs/don/class/paymentdonation.class.php
-
message: '#^Property PaymentDonation\:\:\$fk_user_creat \(int\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 3
path: ../../../htdocs/don/class/paymentdonation.class.php
-
message: '#^Property PaymentDonation\:\:\$fk_user_modif \(int\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 3
path: ../../../htdocs/don/class/paymentdonation.class.php
-
message: '#^Property PaymentDonation\:\:\$num_payment \(string\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 3
path: ../../../htdocs/don/class/paymentdonation.class.php
-
message: '#^Result of && is always true\.$#'
identifier: booleanAnd.alwaysTrue
count: 2
path: ../../../htdocs/don/class/paymentdonation.class.php
- -
message: '#^Variable \$maxlength might not be defined\.$#' message: '#^Variable \$maxlength might not be defined\.$#'
identifier: variable.undefined identifier: variable.undefined

View File

@@ -758,13 +758,13 @@ abstract class CommonObject
public $user_modification_id; public $user_modification_id;
/** /**
* @var int ID * @var int|null ID
* @deprecated Use $user_creation_id * @deprecated Use $user_creation_id
*/ */
public $fk_user_creat; public $fk_user_creat;
/** /**
* @var ?int ID * @var int|null ID
* @deprecated Use $user_modification_id * @deprecated Use $user_modification_id
*/ */
public $fk_user_modif; public $fk_user_modif;
@@ -11342,7 +11342,7 @@ abstract class CommonObject
$comment = new Comment($this->db); $comment = new Comment($this->db);
$result = $comment->fetchAllFor($this->element, $this->id); $result = $comment->fetchAllFor($this->element, $this->id);
if ($result < 0) { if ($result < 0) {
$this->errors = array_merge($this->errors, $comment->errors); $this->setErrorsFromObject($comment);
return -1; return -1;
} else { } else {
$this->comments = $comment->comments; $this->comments = $comment->comments;

View File

@@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr> /* Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -52,7 +52,7 @@ class PaymentDonation extends CommonObject
public $rowid; public $rowid;
/** /**
* @var int ID * @var ?int ID
*/ */
public $fk_donation; public $fk_donation;
@@ -67,7 +67,7 @@ class PaymentDonation extends CommonObject
public $datep = ''; public $datep = '';
/** /**
* @var float amount * @var ?float amount
*/ */
public $amount; // Total amount of payment public $amount; // Total amount of payment
@@ -77,42 +77,42 @@ class PaymentDonation extends CommonObject
public $amounts = array(); // Array of amounts public $amounts = array(); // Array of amounts
/** /**
* @var int Payment mode ID * @var ?int Payment mode ID
* @deprecated Use $paymenttype * @deprecated Use $paymenttype
* @see $paymenttype * @see $paymenttype
*/ */
public $fk_typepayment; public $fk_typepayment;
/** /**
* @var int Payment mode ID or Code. TODO Use only the code in this field. * @var ?int Payment mode ID or Code. TODO Use only the code in this field.
*/ */
public $paymenttype; public $paymenttype;
/** /**
* @var string Payment reference * @var ?string Payment reference
* (Cheque or bank transfer reference. Can be "ABC123") * (Cheque or bank transfer reference. Can be "ABC123")
*/ */
public $num_payment; public $num_payment;
/** /**
* @var int ID * @var ?int ID
*/ */
public $fk_bank; public $fk_bank;
/** /**
* @var int ID * @var ?int ID
*/ */
public $fk_user_creat; public $fk_user_creat;
/** /**
* @var int ID * @var ?int ID
*/ */
public $fk_user_modif; public $fk_user_modif;
/** /**
* @deprecated Use $amount, $amounts * @deprecated Use $amount, $amounts
* @see $amount, $amounts * @see $amount, $amounts
* @var float * @var ?float
*/ */
public $total; public $total;
@@ -320,8 +320,8 @@ class PaymentDonation extends CommonObject
$this->num_payment = $obj->num_payment; $this->num_payment = $obj->num_payment;
$this->note_public = $obj->note_public; $this->note_public = $obj->note_public;
$this->fk_bank = $obj->fk_bank; $this->fk_bank = $obj->fk_bank;
$this->fk_user_creat = $obj->fk_user_creat; $this->fk_user_creat = $obj->fk_user_creat;
$this->fk_user_modif = $obj->fk_user_modif; $this->fk_user_modif = $obj->fk_user_modif;
$this->type_code = $obj->type_code; $this->type_code = $obj->type_code;
$this->type_label = $obj->type_label; $this->type_label = $obj->type_label;
@@ -405,17 +405,13 @@ class PaymentDonation extends CommonObject
$this->errors[] = "Error ".$this->db->lasterror(); $this->errors[] = "Error ".$this->db->lasterror();
} }
if (!$error) { if (!$error && !$notrigger) {
if (!$notrigger) { // Call triggers
if (!$error && !$notrigger) { $result = $this->call_trigger('DONATION_PAYMENT_MODIFY', $user);
// Call triggers if ($result < 0) {
$result = $this->call_trigger('DONATION_PAYMENT_MODIFY', $user); $error++;
if ($result < 0) {
$error++;
}
// End call triggers
}
} }
// End call triggers
} }
// Commit or rollback // Commit or rollback
@@ -443,20 +439,19 @@ class PaymentDonation extends CommonObject
public function delete($user, $notrigger = 0) public function delete($user, $notrigger = 0)
{ {
global $conf, $langs; global $conf, $langs;
$error = 0; $error = 0;
$this->db->begin(); $this->db->begin();
if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url";
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url"; $sql .= " WHERE type='payment_donation' AND url_id=".(int) $this->id;
$sql .= " WHERE type='payment_donation' AND url_id=".(int) $this->id;
dol_syslog(get_class($this)."::delete", LOG_DEBUG); dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (!$resql) { if (!$resql) {
$error++; $error++;
$this->errors[] = "Error ".$this->db->lasterror(); $this->errors[] = "Error ".$this->db->lasterror();
}
} }
if (!$error) { if (!$error) {
@@ -471,17 +466,13 @@ class PaymentDonation extends CommonObject
} }
} }
if (!$error) { if (!$error && !$notrigger) {
if (!$notrigger) { // Call triggers
if (!$error && !$notrigger) { $result = $this->call_trigger('DONATION_PAYMENT_DELETE', $user);
// Call triggers if ($result < 0) {
$result = $this->call_trigger('DONATION_PAYMENT_DELETE', $user); $error++;
if ($result < 0) {
$error++;
}
// End call triggers
}
} }
// End call triggers
} }
// Commit or rollback // Commit or rollback
@@ -639,7 +630,7 @@ class PaymentDonation extends CommonObject
$this->datep, $this->datep,
(string) $this->paymenttype, // Payment mode id or code ("CHQ or VIR for example") (string) $this->paymenttype, // Payment mode id or code ("CHQ or VIR for example")
$label, $label,
$amount, (float) $amount,
$this->num_payment, $this->num_payment,
0, 0,
$user, $user,