From c533dc3f4cd1aa10c1225335b589f311402969cf Mon Sep 17 00:00:00 2001 From: William Mead Date: Fri, 12 Jan 2024 12:34:49 +0100 Subject: [PATCH 1/9] Fixed method filter argument type. Cleaned code. --- htdocs/resource/class/dolresource.class.php | 12 ++++++------ htdocs/resource/class/html.formresource.class.php | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 2783a366405..9fc546e0802 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -502,12 +502,12 @@ class Dolresource extends CommonObject /** * Load resource objects into $this->lines * - * @param string $sortorder sort order - * @param string $sortfield sort field - * @param int $limit limit page - * @param int $offset page - * @param array $filter filter output - * @return int Return integer <0 if KO, Number of lines loaded if OK + * @param string $sortorder sort order + * @param string $sortfield sort field + * @param int $limit limit page + * @param int $offset page + * @param array $filter filter output + * @return int Return integer <0 if KO, Number of lines loaded if OK */ public function fetchAll($sortorder, $sortfield, $limit, $offset, $filter = []) { diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index 6186a90cd60..a2fce129532 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -65,9 +65,9 @@ class FormResource /** * Output html form to select a resource * - * @param int $selected Preselected resource id - * @param string $htmlname Name of field in form - * @param string $filter Optionnal filters criteras (example: 's.rowid <> x') + * @param int $selected Preselected resource id + * @param string $htmlname Name of field in form + * @param array $filter Optionnal filters criteras (example: 's.rowid <> x') * @param int $showempty Add an empty field * @param int $showtype Show third party type in combolist (customer, prospect or supplier) * @param int $forcecombo Force to use combo box @@ -76,10 +76,10 @@ class FormResource * @param int $outputmode 0=HTML select string, 1=Array, 2=without form tag * @param int $limit Limit number of answers * @param string $morecss More css - * @param bool $multiple add [] in the name of element and add 'multiple' attribut + * @param bool $multiple add [] in the name of element and add 'multiple' attribut * @return string|array HTML string with */ - public function select_resource_list($selected = '', $htmlname = 'fk_resource', $filter = '', $showempty = 0, $showtype = 0, $forcecombo = 0, $event = array(), $filterkey = '', $outputmode = 0, $limit = 20, $morecss = '', $multiple = false) + public function select_resource_list($selected = '', $htmlname = 'fk_resource', $filter = [], $showempty = 0, $showtype = 0, $forcecombo = 0, $event = array(), $filterkey = '', $outputmode = 0, $limit = 20, $morecss = '', $multiple = false) { // phpcs:enable global $conf, $user, $langs; From 18861291a0cb62b1068dedce98c00f429c215760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 14 Jan 2024 22:05:43 +0100 Subject: [PATCH 2/9] fix phpstan --- htdocs/fichinter/class/fichinterrec.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fichinter/class/fichinterrec.class.php b/htdocs/fichinter/class/fichinterrec.class.php index 671c566009d..beb2d6358c2 100644 --- a/htdocs/fichinter/class/fichinterrec.class.php +++ b/htdocs/fichinter/class/fichinterrec.class.php @@ -471,7 +471,7 @@ class FichinterRec extends Fichinter * @param double $remise_percent Percentage of discount on line * @param string $price_base_type HT or TTC * @param int $info_bits Bits for type of lines - * @param int $fk_remise_except Id discount + * @param int $fk_remise_except Id discount (not used) * @param double $pu_ttc Unit price with tax (> 0 even for credit note) * @param int $type Type of line (0=product, 1=service) * @param int $special_code Special code @@ -479,7 +479,7 @@ class FichinterRec extends Fichinter * @param string $fk_unit Unit * @return int Return integer <0 if KO, Id of line if OK */ - public function addline($desc, $duration, $date, $rang = -1, $pu_ht = 0, $qty = 0, $txtva = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $special_code = 0, $label = '', $fk_unit = null) + public function addline($desc, $duration, $date, $rang = -1, $pu_ht = 0, $qty = 0, $txtva = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = 0, $pu_ttc = 0, $type = 0, $special_code = 0, $label = '', $fk_unit = null) { global $mysoc; From 459c07abd84961442fcb09f340e647e181f87fd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 14 Jan 2024 22:22:10 +0100 Subject: [PATCH 3/9] fix phpstan --- htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 61681bc51e0..14de46cbd33 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -5,7 +5,7 @@ * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2015 Marcos García * Copyright (C) 2017 Ferran Marcet - * Copyright (C) 2018-2022 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2023 William Mead * * This program is free software; you can redistribute it and/or modify @@ -144,7 +144,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs = null, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user, $langs, $conf, $hookmanager, $mysoc, $nblines; From df48eb6032f1c41ad63ddf7ab0302bcdc335696a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 14 Jan 2024 22:23:50 +0100 Subject: [PATCH 4/9] fix phpstan --- .../core/modules/supplier_invoice/doc/pdf_canelle.modules.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php index 96e637adca2..0fdea1e01fe 100644 --- a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php @@ -2,7 +2,7 @@ /* Copyright (C) 2010-2011 Juanjo Menent * Copyright (C) 2010-2014 Laurent Destailleur * Copyright (C) 2015 Marcos García - * Copyright (C) 2018-2021 Frédéric France + * Copyright (C) 2018-2024 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 @@ -156,7 +156,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs = null, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user, $langs, $conf, $mysoc, $hookmanager, $nblines; From 13c9707c9dff3a250099606ec4cddd753d637841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 14 Jan 2024 22:34:37 +0100 Subject: [PATCH 5/9] fix phpstan --- htdocs/core/lib/files.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 060cb3f836f..cc48b80acc7 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -50,12 +50,12 @@ function dol_basename($pathfile) * but must not contains the start and end '/'. Filter is checked into basename only. * @param array $excludefilter Array of Regex for exclude filter (example: array('(\.meta|_preview.*\.png)$','^\.')). Exclude is checked both into fullpath and into basename (So '^xxx' may exclude 'xxx/dirscanned/...' and dirscanned/xxx'). * @param string $sortcriteria Sort criteria ('','fullname','relativename','name','date','size') - * @param string $sortorder Sort order (SORT_ASC, SORT_DESC) + * @param int $sortorder Sort order (SORT_ASC, SORT_DESC) * @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only, 4=Force load of perm * @param int $nohook Disable all hooks * @param string $relativename For recursive purpose only. Must be "" at first call. - * @param string $donotfollowsymlinks Do not follow symbolic links - * @param string $nbsecondsold Only files older than $nbsecondsold + * @param int $donotfollowsymlinks Do not follow symbolic links + * @param int $nbsecondsold Only files older than $nbsecondsold * @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file',...) * @see dol_dir_list_in_database() */ From 25de0779b2e23237fe877f740d71ae130323c00d Mon Sep 17 00:00:00 2001 From: Christophe TREMBLAY-GUILLOUX Date: Sun, 14 Jan 2024 22:57:16 +0100 Subject: [PATCH 6/9] File not joined : slash is missing in case DOL_DATA_ROOT doesn't end with slash --- htdocs/compta/facture/class/facture.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 84db8a44be2..e9b6e54ee67 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -5810,9 +5810,9 @@ class Facture extends CommonInvoice $joinFileName = []; $joinFileMime = []; if ($arraymessage->joinfiles == 1 && !empty($tmpinvoice->last_main_doc)) { - $joinFile[] = DOL_DATA_ROOT.$tmpinvoice->last_main_doc; + $joinFile[] = DOL_DATA_ROOT.'/'.$tmpinvoice->last_main_doc; $joinFileName[] = basename($tmpinvoice->last_main_doc); - $joinFileMime[] = dol_mimetype(DOL_DATA_ROOT.$tmpinvoice->last_main_doc); + $joinFileMime[] = dol_mimetype(DOL_DATA_ROOT.'/'.$tmpinvoice->last_main_doc); } // Mail Creation From 19f7fa0030b5618123605b49259f7ec3e72704c4 Mon Sep 17 00:00:00 2001 From: William Mead Date: Mon, 15 Jan 2024 09:18:18 +0100 Subject: [PATCH 7/9] Fixed selected default value --- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/tpl/resource_add.tpl.php | 2 +- htdocs/resource/class/html.formresource.class.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index d8653ba4220..8214d2c7956 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2425,7 +2425,7 @@ class Form $events = array(); $out .= img_picto('', 'resource', 'class="pictofixedwidth"'); - $out .= $formresources->select_resource_list('', $htmlname, '', 1, 1, 0, $events, '', 2, null); + $out .= $formresources->select_resource_list(0, $htmlname, '', 1, 1, 0, $events, '', 2, null); //$out .= $this->select_dolusers('', $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity, $maxlength, $showstatus, $morefilter); $out .= ' '; $out .= '
'; diff --git a/htdocs/core/tpl/resource_add.tpl.php b/htdocs/core/tpl/resource_add.tpl.php index 0595d636956..7fd994793d8 100644 --- a/htdocs/core/tpl/resource_add.tpl.php +++ b/htdocs/core/tpl/resource_add.tpl.php @@ -32,7 +32,7 @@ $out .= '
'; $events = array(); $out .= img_picto('', 'resource', 'class="pictofixedwidth"'); -$out .= $formresources->select_resource_list('', 'fk_resource', '', 1, 1, 0, $events, '', 2, null); +$out .= $formresources->select_resource_list(0, 'fk_resource', '', 1, 1, 0, $events, '', 2, null); $out .= '
'; $out .= '
'; diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index a2fce129532..b4b497212c2 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -79,7 +79,7 @@ class FormResource * @param bool $multiple add [] in the name of element and add 'multiple' attribut * @return string|array HTML string with */ - public function select_resource_list($selected = '', $htmlname = 'fk_resource', $filter = [], $showempty = 0, $showtype = 0, $forcecombo = 0, $event = array(), $filterkey = '', $outputmode = 0, $limit = 20, $morecss = '', $multiple = false) + public function select_resource_list($selected = 0, $htmlname = 'fk_resource', $filter = [], $showempty = 0, $showtype = 0, $forcecombo = 0, $event = array(), $filterkey = '', $outputmode = 0, $limit = 20, $morecss = '', $multiple = false) { // phpcs:enable global $conf, $user, $langs; From f03a8fdc65280601fc4a435ea91e225bcc7ec0bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 15 Jan 2024 09:20:57 +0100 Subject: [PATCH 8/9] fix phpstan --- htdocs/core/class/commonobject.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 75fd4a5e47a..49c9b8cd6b8 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -587,28 +587,28 @@ abstract class CommonObject // Dates /** - * @var integer|string date_creation + * @var integer|string|null date_creation */ public $date_creation; /** - * @var integer|string $date_validation; + * @var integer|string|null $date_validation; */ public $date_validation; // Date validation /** - * @var integer|string $date_modification; + * @var integer|string|null $date_modification; */ public $date_modification; // Date last change (tms field) /** - * @var integer|string $date_modification; + * @var integer|string|null $date_modification; * @deprecated Use date_modification */ public $date_update; /** - * @var integer|string $date_cloture; + * @var integer|string|null $date_cloture; */ public $date_cloture; // Date closing (tms field) From cc4cf8bf0dab136b262363cfde4dfc41215df73d Mon Sep 17 00:00:00 2001 From: William Mead Date: Mon, 15 Jan 2024 09:42:39 +0100 Subject: [PATCH 9/9] Updated PHPDoc --- htdocs/resource/class/html.formresource.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index b4b497212c2..7222264b939 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -67,16 +67,16 @@ class FormResource * * @param int $selected Preselected resource id * @param string $htmlname Name of field in form - * @param array $filter Optionnal filters criteras (example: 's.rowid <> x') + * @param array $filter Optional filters criteria (example: 's.rowid <> x') * @param int $showempty Add an empty field - * @param int $showtype Show third party type in combolist (customer, prospect or supplier) + * @param int $showtype Show third party type in combo list (customer, prospect or supplier) * @param int $forcecombo Force to use combo box * @param array $event Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @param string $filterkey Filter on key value * @param int $outputmode 0=HTML select string, 1=Array, 2=without form tag * @param int $limit Limit number of answers * @param string $morecss More css - * @param bool $multiple add [] in the name of element and add 'multiple' attribut + * @param bool $multiple add [] in the name of element and add 'multiple' attribute * @return string|array HTML string with */ public function select_resource_list($selected = 0, $htmlname = 'fk_resource', $filter = [], $showempty = 0, $showtype = 0, $forcecombo = 0, $event = array(), $filterkey = '', $outputmode = 0, $limit = 20, $morecss = '', $multiple = false) @@ -164,7 +164,7 @@ class FormResource // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Return html list of tickets type + * Return html list of tickets type // TODO translate PHPDoc to english * * @param string $selected Id du type pre-selectionne * @param string $htmlname Nom de la zone select