From 044395bda6f7a267f906eeee737fa984c50fbb11 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Sun, 28 Jan 2024 17:53:16 +0100 Subject: [PATCH] qual: phpstan for htdocs/product/class/product.class.php htdocs/product/class/product.class.php 2449 Property Product::$price (float) does not accept string. htdocs/product/class/product.class.php 2450 Property Product::$price_ttc (float) does not accept string. htdocs/product/class/product.class.php 2909 Property Product::$price_ttc (float) does not accept string. htdocs/product/class/product.class.php 5077 Method Product::isVariant() should return int but returns false. htdocs/product/class/product.class.php 5079 Method Product::isVariant() should return int but returns true. htdocs/product/class/product.class.php 5085 Method Product::isVariant() should return int but returns false. htdocs/product/class/product.class.php 5608 Method Product::getLibFinished() should return string but returns int. --- htdocs/product/class/product.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 3e0d45f75f4..1858ed5f985 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2358,7 +2358,7 @@ class Product extends CommonObject $price_min_ttc = 0; } } else { - $price = price2num($newprice, 'MU'); + $price = (float) price2num($newprice, 'MU'); $price_ttc = ($newnpr != 1) ? (float) price2num($newprice) * (1 + ($newvat / 100)) : $price; $price_ttc = price2num($price_ttc, 'MU'); @@ -2905,8 +2905,8 @@ class Product extends CommonObject if ($price_result >= 0) { $this->price = $price_result; // Calculate the VAT - $this->price_ttc = price2num($this->price) * (1 + ($this->tva_tx / 100)); - $this->price_ttc = price2num($this->price_ttc, 'MU'); + $this->price_ttc = (float) price2num($this->price) * (1 + ($this->tva_tx / 100)); + $this->price_ttc = (float) price2num($this->price_ttc, 'MU'); } } @@ -5062,7 +5062,7 @@ class Product extends CommonObject /** * Return if loaded product is a variant * - * @return int + * @return bool|int Return true if the product is a variant, false if not, -1 if error */ public function isVariant() { @@ -5587,7 +5587,7 @@ class Product extends CommonObject /** * Retour label of nature of product * - * @return string Label + * @return string|int Return label or ''. -1 if error */ public function getLibFinished() {