From 4e5ea524f4bd3b6b0dfec8ef1dd33ad03ce5831c Mon Sep 17 00:00:00 2001 From: thibdrev Date: Wed, 21 Aug 2024 15:11:28 +0200 Subject: [PATCH] qual: PHPStan for tva.class.php (#30711) * qual: PPHStan for tva.class.php htdocs/compta/tva/class/tva.class.php 57 Property Tva::$total has no type specified. htdocs/compta/tva/class/tva.class.php 59 Property Tva::$datep has no type specified. htdocs/compta/tva/class/tva.class.php 60 Property Tva::$datev has no type specified. htdocs/compta/tva/class/tva.class.php 61 Property Tva::$amount has no type specified. htdocs/compta/tva/class/tva.class.php 62 Property Tva::$type_payment has no type specified. htdocs/compta/tva/class/tva.class.php 924 Method Tva::getKanbanView() has parameter $arraydata with no value type specified in iterable type array. * tva.class.php - correction of phan warnings * tva.class.php - correction of phan warnings * $amout can be float|string * Update card.php - fix phan warning --- htdocs/compta/tva/card.php | 2 +- htdocs/compta/tva/class/tva.class.php | 37 +++++++++++++++++++-------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 04e831dcf96..6328eca8bfd 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -173,7 +173,7 @@ if (empty($reshook)) { $error = 0; $object->fk_account = GETPOSTINT("accountid"); - $object->type_payment = GETPOST("type_payment", 'alphanohtml'); + $object->type_payment = GETPOSTINT("type_payment"); $object->num_payment = GETPOST("num_payment", 'alphanohtml'); $object->datev = $datev; diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 2d575ece8b9..f8a06cf0837 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -31,7 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; /** - * Put here description of your class + * Class to manage VAT - Value-added tax + * (also known in French as TVA - Taxe sur la valeur ajoutée) */ class Tva extends CommonObject { @@ -51,14 +52,30 @@ class Tva extends CommonObject public $picto = 'payment'; /** + * @var float * @deprecated * @see $amount */ public $total; + /** + * @var int Payment date + */ public $datep; + + /** + * @var int Validation date + */ public $datev; + + /** + * @var float|string VAT amount + */ public $amount; + + /** + * @var int Payment type ID + */ public $type_payment; /** @@ -146,7 +163,7 @@ class Tva extends CommonObject $now = dol_now(); // Clean parameters - $this->amount = trim($this->amount); + $this->amount = (float) price2num($this->amount); $this->label = trim($this->label); $this->type_payment = (int) $this->type_payment; $this->note = trim($this->note); @@ -226,7 +243,7 @@ class Tva extends CommonObject $error = 0; // Clean parameters - $this->amount = trim($this->amount); + $this->amount = (float) price2num($this->amount); $this->label = trim($this->label); $this->note = trim($this->note); $this->fk_user_creat = (int) $this->fk_user_creat; @@ -421,9 +438,9 @@ class Tva extends CommonObject $this->id = 0; $this->tms = dol_now(); - $this->datep = ''; - $this->datev = ''; - $this->amount = ''; + $this->datep = dol_now(); + $this->datev = dol_now(); + $this->amount = 100.0; $this->label = ''; $this->note = ''; $this->fk_bank = 0; @@ -570,7 +587,7 @@ class Tva extends CommonObject $this->db->begin(); // Clean parameters - $this->amount = price2num(trim($this->amount)); + $this->amount = (float) price2num($this->amount); $this->label = trim($this->label); $this->note = trim($this->note); $this->num_payment = trim($this->num_payment); @@ -917,9 +934,9 @@ class Tva extends CommonObject /** * Return clickable link of object (with eventually picto) * - * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) - * @param array $arraydata Array of data - * @return string HTML Code for Kanban thumb. + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array{string,mixed} $arraydata Array of data + * @return string HTML Code for Kanban thumb. */ public function getKanbanView($option = '', $arraydata = null) {