From 0f62b8e7bcded5ae4bfd9aa8812282ff89dc1748 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Fri, 9 Feb 2024 11:28:33 +0100 Subject: [PATCH] qual: phpstan (#28075) * qual: phpstan for htdocs/core/lib/images.lib.php htdocs/core/lib/images.lib.php 636 Function vignette() should return string but returns int. * qual: phpstan for htdocs/core/lib/product.lib.php htdocs/core/lib/product.lib.php 839 Function measuringUnitString() should return string but returns int. * qual: phpstan for htdocs/core/lib/website.lib.php htdocs/core/lib/website.lib.php 222 Function dolWebsiteReplacementOfLinks() should return bool but returns string. * qual: phpstan for htdocs/core/lib/functions.lib.php htdocs/core/lib/functions.lib.php 9576 Function dol_getIdFromCode() should return int but returns string. * qual: phpstan for htdocs/core/modules/import/modules_import.php htdocs/core/modules/import/modules_import.php 173 Method ModeleImports::getDriverId() should return int but returns string. * qual: phpstan for htdocs/core/modules/mailings/thirdparties_services_expired.modules.php htdocs/core/modules/mailings/thirdparties_services_expired.modules.php 100 Method mailing_thirdparties_services_expired::add_to_target() should return int but returns string. * qual:phpstan for htdocs/loan/schedule.php htdocs/loan/schedule.php 80 Property LoanSchedule::$datec (string) does not accept int. --- htdocs/core/lib/functions.lib.php | 2 +- htdocs/core/lib/images.lib.php | 2 +- htdocs/core/lib/product.lib.php | 2 +- htdocs/core/lib/website.lib.php | 2 +- htdocs/core/modules/import/modules_import.php | 2 +- .../modules/mailings/thirdparties_services_expired.modules.php | 2 +- htdocs/loan/class/loanschedule.class.php | 3 --- 7 files changed, 6 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 23558488e92..a73183435f5 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -9564,7 +9564,7 @@ function dol_osencode($str) * @param string $fieldid Field to get * @param int $entityfilter Filter by entity * @param string $filters Filters to add. WARNING: string must be escaped for SQL and not coming from user input. - * @return int Return integer <0 if KO, Id of code if OK + * @return int|string Return integer <0 if KO, Id of code if OK, '' if empty key provided. * @see $langs->getLabelFromKey */ function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = 'id', $entityfilter = 0, $filters = '') diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 5dc10149a72..0134180e4d8 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -507,7 +507,7 @@ function correctExifImageOrientation($fileSource, $fileDest, $quality = 95) * @param int $quality Quality of compression (0=worst, 100=best) * @param string $outdir Directory where to store thumb * @param int $targetformat New format of target (IMAGETYPE_GIF, IMAGETYPE_JPG, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_WBMP ... or 0 to keep old format) - * @return string Full path of thumb or '' if it fails or 'Error...' if it fails + * @return string|0 Full path of thumb or '' if it fails or 'Error...' if it fails, or 0 if it fails to detect the type of image */ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', $quality = 50, $outdir = 'thumbs', $targetformat = 0) { diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index d0de3ba385a..a631d7ff826 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -799,7 +799,7 @@ function measuring_units_string($scale = '', $measuring_style = '', $unit = 0, $ * @param string $scale Scale of unit: '0', '-3', '6', ... * @param int $use_short_label 1=Use short label ('g' instead of 'gram'). Short labels are not translated. * @param Translate $outputlangs Language object - * @return string Unit string + * @return string|-1 Unit string if OK, -1 if KO * @see formproduct->selectMeasuringUnits() */ function measuringUnitString($unit, $measuring_style = '', $scale = '', $use_short_label = 0, $outputlangs = null) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 062df9719ea..3eba94d6531 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -115,7 +115,7 @@ function dolKeepOnlyPhpCode($str) * @param int $removephppart 0=Replace PHP sections with a PHP badge. 1=Remove completely PHP sections. * @param string $contenttype Content type * @param int $containerid Contenair id - * @return boolean True if OK + * @return string html content * @see dolWebsiteOutput() for function used to replace content in a web server context */ function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0, $contenttype = 'html', $containerid = 0) diff --git a/htdocs/core/modules/import/modules_import.php b/htdocs/core/modules/import/modules_import.php index 8e24e1e3093..e9e82e7baa7 100644 --- a/htdocs/core/modules/import/modules_import.php +++ b/htdocs/core/modules/import/modules_import.php @@ -166,7 +166,7 @@ class ModeleImports /** * getDriverId * - * @return int Id + * @return string Code of driver */ public function getDriverId() { diff --git a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php index b628890f8a8..2af76669d2f 100644 --- a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php +++ b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php @@ -97,7 +97,7 @@ class mailing_thirdparties_services_expired extends MailingTargets if ($key == '0') { $this->error = "Error: You must choose a filter"; $this->errors[] = $this->error; - return $this->error; + return -1; } $product = $this->arrayofproducts[$key]; diff --git a/htdocs/loan/class/loanschedule.class.php b/htdocs/loan/class/loanschedule.class.php index 4ec3e2908b8..8b2fd532568 100644 --- a/htdocs/loan/class/loanschedule.class.php +++ b/htdocs/loan/class/loanschedule.class.php @@ -47,9 +47,6 @@ class LoanSchedule extends CommonObject public $bank_account; public $bank_line; - /** - * @var string Create date - */ public $datec; public $tms;