From eb7c4a71cbb7d93fc095499a411bb399e3f1d1d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Wed, 3 Jul 2024 08:34:17 +0200 Subject: [PATCH 1/9] fix checkFunctionArgumentTypes --- .../core/modules/contract/mod_contract_magre.php | 16 +++++++++++----- phpstan.neon.dist | 1 - 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/htdocs/core/modules/contract/mod_contract_magre.php b/htdocs/core/modules/contract/mod_contract_magre.php index ebd7957780fe9..02345cda0f4d7 100644 --- a/htdocs/core/modules/contract/mod_contract_magre.php +++ b/htdocs/core/modules/contract/mod_contract_magre.php @@ -88,12 +88,18 @@ public function info($langs) */ public function getExample() { - global $langs, $mysoc; + global $db, $langs; + + require_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php'; + require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; + + $contract = new Contrat($db); + $contract->initAsSpecimen(); + $thirdparty = new Societe($db); + $thirdparty->initAsSpecimen(); + + $numExample = $this->getNextValue($thirdparty, $contract); - $old_code_client = $mysoc->code_client; - $mysoc->code_client = 'CCCCCCCCCC'; - $numExample = $this->getNextValue($mysoc, ''); - $mysoc->code_client = $old_code_client; if (!$numExample) { $numExample = $langs->trans('NotConfigured'); diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 3e2c708b9783e..c183bdfd97cbc 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -97,7 +97,6 @@ parameters: - '#expects object#' - '#expects Adherent#' - '#expects BOM#' - - '#expects Contrat#' - '#expects FTP\\Connection#' - '#expects Holiday#' - '#expects LDAP\\Connection#' From aafe139958a9441ba0ef458ce713074038b57cc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Wed, 3 Jul 2024 08:43:11 +0200 Subject: [PATCH 2/9] fix checkFunctionArgumentTypes --- htdocs/core/modules/stock/doc/pdf_standard.modules.php | 2 +- phpstan.neon.dist | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php index 21e3e2ffdf24d..7fac3e5ea6f69 100644 --- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php @@ -838,7 +838,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlek * Show footer of page. Need this->emetteur object * * @param TCPDF $pdf PDF - * @param Object $object Object to show + * @param Entrepot $object Object to show * @param Translate $outputlangs Object lang for output * @param int $hidefreetext 1=Hide free text * @return int Return height of bottom margin including footer text diff --git a/phpstan.neon.dist b/phpstan.neon.dist index c183bdfd97cbc..aaa5dfaa18ed5 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -113,10 +113,8 @@ parameters: - '#expects Translate#' - '#expects User#' - '#expects CommonObjectLine#' - - '#dol_eval expects#' - '#check_authentication expects#' - '#colorHexToHsl expects#' - - '#dolGetButtonTitle expects#' internalErrorsCountLimit: 50 cache: nodesByFileCountMax: 512 From 62687ba33aa0d5d6b6fb55bec333ca0a125a8d79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Wed, 3 Jul 2024 17:33:16 +0200 Subject: [PATCH 3/9] fix checkFunctionArgumentTypes --- htdocs/emailcollector/class/emailcollector.class.php | 2 +- phpstan.neon.dist | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 4139a23a52ef4..a5231a73b6e91 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -2665,7 +2665,7 @@ public function doCollectOneCollector($mode = 0) // Search country by name or code if (!empty($contactstatic->country)) { require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; - $result = getCountry('', 3, $this->db, '', 1, $contactstatic->country); + $result = getCountry('', 3, $this->db, null, 1, $contactstatic->country); if ($result == 'NotDefined') { $errorforactions++; $this->error = "Error country not found by this name '" . $contactstatic->country . "'"; diff --git a/phpstan.neon.dist b/phpstan.neon.dist index aaa5dfaa18ed5..f52ace386c5bf 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -110,7 +110,6 @@ parameters: - '#expects RemiseCheque#' - '#expects Societe#' - '#expects SupplierProposal#' - - '#expects Translate#' - '#expects User#' - '#expects CommonObjectLine#' - '#check_authentication expects#' From 025b46695b462a5a30bb1f52a7428a3fc1709879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Wed, 3 Jul 2024 17:43:31 +0200 Subject: [PATCH 4/9] fix checkFunctionArgumentTypes --- .../modules/cheque/mod_chequereceipt_thyme.php | 16 +++++++++++----- phpstan.neon.dist | 1 - 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php b/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php index 44eff63035d10..71cf8effc9224 100644 --- a/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php +++ b/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php @@ -93,16 +93,22 @@ public function info($langs) */ public function getExample() { - global $conf, $langs, $mysoc; + global $db, $langs; - $old_code_client = $mysoc->code_client; - $mysoc->code_client = 'CCCCCCCCCC'; - $numExample = $this->getNextValue($mysoc, ''); - $mysoc->code_client = $old_code_client; + require_once DOL_DOCUMENT_ROOT . '/compta/paiement/cheque/class/remisecheque.class.php'; + require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; + + $remise = new RemiseCheque($db); + $remise->initAsSpecimen(); + $thirdparty = new Societe($db); + $thirdparty->initAsSpecimen(); + + $numExample = $this->getNextValue($thirdparty, $remise); if (!$numExample) { $numExample = $langs->trans('NotConfigured'); } + return $numExample; } diff --git a/phpstan.neon.dist b/phpstan.neon.dist index f52ace386c5bf..53def3bed4464 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -107,7 +107,6 @@ parameters: - '#expects Paiement#' - '#expects PgSql\\Result#' - '#expects RecruitmentJobPosition#' - - '#expects RemiseCheque#' - '#expects Societe#' - '#expects SupplierProposal#' - '#expects User#' From 674deec5ab1494a1c468db5605892ebea9de2e71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Wed, 3 Jul 2024 18:14:01 +0200 Subject: [PATCH 5/9] fix checkFunctionArgumentTypes --- htdocs/expedition/card.php | 6 +++--- htdocs/reception/card.php | 5 +++-- phpstan.neon.dist | 11 +++++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index d7ed5a2c5e74f..9ec4182d0f9b8 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -11,10 +11,10 @@ * Copyright (C) 2015 Claudio Aschieri * Copyright (C) 2016-2018 Ferran Marcet * Copyright (C) 2016 Yasser Carreón - * Copyright (C) 2018-2022 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2020 Lenin Rivas * Copyright (C) 2022 Josep Lluís Amador - * Copyright (C) 2024 MDW + * Copyright (C) 2024 MDW * * 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 @@ -2082,7 +2082,7 @@ if ($volumeUnit < 50) { print showDimensionInBestUnit($calculatedVolume, $volumeUnit, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); } else { - print $calculatedVolume.' '.measuringUnitString(0, "volume", $volumeUnit); + print $calculatedVolume.' '.measuringUnitString(0, "volume", (string) $volumeUnit); } } if ($totalVolume > 0) { diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 4c06be7396b7d..457b21e046cbf 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -12,7 +12,8 @@ * Copyright (C) 2016 Ferran Marcet * Copyright (C) 2016 Yasser Carreón * Copyright (C) 2018 Quentin Vial-Gouteyron - * Copyright (C) 2024 MDW + * Copyright (C) 2024 MDW + * Copyright (C) 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 @@ -1613,7 +1614,7 @@ if ($volumeUnit < 50) { print showDimensionInBestUnit($calculatedVolume, $volumeUnit, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); } else { - print $calculatedVolume.' '.measuringUnitString(0, "volume", $volumeUnit); + print $calculatedVolume.' '.measuringUnitString(0, "volume", (string) $volumeUnit); } } if ($totalVolume > 0) { diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 53def3bed4464..09ca4e1d1ae9f 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -78,15 +78,18 @@ parameters: - '#expects float\|string#' - '#expects float\|null#' - '#expects float, string given.#' - - '#expects string#' - - '#expects string, int given.#' + - '#expects string\|null,#' + - '#expects string, int#' - '#expects string, \(float\|int\) given.#' - - '#expects string, array given.#' - - '#expects string, float given.#' + - '#expects string, array#' + - '#expects string, float#' + - '#expects string, bool given.#' - '#expects string, true given.#' + - '#expects string, false given.#' - '#expects string, null given.#' - '#expects string, int<0, 10> given.#' - '#expects string, DateTime given.#' + - '#expects string, bool\|mysqli_result\|resource given.#' - '#expects array#' - '#expects array, string given.#' - '#expects array, null given.#' From 1787211ca1bc802650ae4047fb0f863ce3123a27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Wed, 3 Jul 2024 18:28:59 +0200 Subject: [PATCH 6/9] fix checkFunctionArgumentTypes --- htdocs/contrat/class/contrat.class.php | 4 ++-- htdocs/user/group/list.php | 4 ++-- phpstan.neon.dist | 10 ++++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 985587f09dfd3..dac55d099e327 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2796,9 +2796,9 @@ public function doAutoRenewContracts($thirdparty_id = 0, $delayindaysshort = 0) if ($expirationdate && $expirationdate < $enddatetoscan) { dol_syslog("Define the newdate of end of services from expirationdate=".$expirationdate); $newdate = $expirationdate; - $protecti = 0; //$protecti is to avoid infinite loop + $protecti = 0; // $protecti is to avoid infinite loop while ($newdate < $enddatetoscan && $protecti < 1000) { - $newdate = dol_time_plus_duree($newdate, $duration_value, $duration_unit); + $newdate = dol_time_plus_duree($newdate, (int) $duration_value, $duration_unit); $protecti++; } diff --git a/htdocs/user/group/list.php b/htdocs/user/group/list.php index 98e79785fce15..54c09924e2ae5 100644 --- a/htdocs/user/group/list.php +++ b/htdocs/user/group/list.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2018 Laurent Destailleur * Copyright (C) 2005-2024 Regis Houssin * Copyright (C) 2011 Herve Prot - * Copyright (C) 2019-2021 Frédéric France + * Copyright (C) 2019-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 @@ -300,7 +300,7 @@ if ($caneditperms) { $newcardbutton .= dolGetButtonTitleSeparator(); - $newcardbutton .= dolGetButtonTitle($langs->trans('NewGroup'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/user/group/card.php?action=create&leftmenu=', '', $caneditperms); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewGroup'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/user/group/card.php?action=create&leftmenu=', '', $caneditperms ? 1 : 0); } print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 09ca4e1d1ae9f..67bc62ac5f017 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -65,11 +65,13 @@ parameters: - '#expects bool#' - '#expects bool, int given.#' - '#expects bool, string given.#' - - '#expects int#' + - '#expects int\|#' + - '#expects int\|#' - '#expects int<-2, 2>, bool given.#' - - '#expects int<0, 1>, false given.#' - - '#expects int, string given.#' - - '#expects int, float given.#' + - '#expects int<0, 1>#' + - '#expects int, string#' + - '#expects int, float#' + - '#expects int, null#' - '#expects int, bool given.#' - '#expects int, false given.#' - '#expects int, true given.#' From 129990d4ee3c96a721ed91ba85b90dda4876c3cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Wed, 3 Jul 2024 19:56:46 +0200 Subject: [PATCH 7/9] fix checkFunctionArgumentTypes --- htdocs/ecm/class/ecmfiles.class.php | 4 ++-- .../lib/recruitment_recruitmentcandidature.lib.php | 2 +- phpstan.neon.dist | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index 7cac5150b4815..f4ef399072643 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -117,12 +117,12 @@ class EcmFiles extends CommonObject public $extraparams; /** - * @var int|string date create + * @var int|'' date create */ public $date_c = ''; /** - * @var int|string date modify + * @var int|'' date modify */ public $date_m = ''; diff --git a/htdocs/recruitment/lib/recruitment_recruitmentcandidature.lib.php b/htdocs/recruitment/lib/recruitment_recruitmentcandidature.lib.php index d6a0de449dcd4..b6e8ae365d60d 100644 --- a/htdocs/recruitment/lib/recruitment_recruitmentcandidature.lib.php +++ b/htdocs/recruitment/lib/recruitment_recruitmentcandidature.lib.php @@ -25,7 +25,7 @@ /** * Prepare array of tabs for RecruitmentCandidature * - * @param RecruitmentJobPosition $object RecruitmentCandidature + * @param RecruitmentCandidature $object RecruitmentCandidature * @return array Array of tabs */ function recruitmentCandidaturePrepareHead($object) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 67bc62ac5f017..6f21edeb9259a 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -111,7 +111,6 @@ parameters: - '#expects FactureFournisseur#' - '#expects Paiement#' - '#expects PgSql\\Result#' - - '#expects RecruitmentJobPosition#' - '#expects Societe#' - '#expects SupplierProposal#' - '#expects User#' From 01717c1ed716e057b28656d941dc92fec798ea3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Wed, 3 Jul 2024 20:11:31 +0200 Subject: [PATCH 8/9] fix checkFunctionArgumentTypes --- .../core/modules/holiday/mod_holiday_immaculate.php | 12 ++++++++---- phpstan.neon.dist | 1 - 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/holiday/mod_holiday_immaculate.php b/htdocs/core/modules/holiday/mod_holiday_immaculate.php index 434b9614985f9..672a37885fa0e 100644 --- a/htdocs/core/modules/holiday/mod_holiday_immaculate.php +++ b/htdocs/core/modules/holiday/mod_holiday_immaculate.php @@ -1,6 +1,6 @@ - * Copyright (C) 2018 Charlene Benke +/* Copyright (C) 2011-2019 Juanjo Menent + * Copyright (C) 2018 Charlene Benke * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -88,11 +88,15 @@ public function info($langs) */ public function getExample() { - global $conf, $langs, $user; + global $db, $langs, $user; + require_once DOL_DOCUMENT_ROOT . '/holiday/class/holiday.class.php'; + + $holiday = new Holiday($db); + $holiday->initAsSpecimen(); $old_login = $user->login; $user->login = 'UUUUUUU'; - $numExample = $this->getNextValue($user, ''); + $numExample = $this->getNextValue($user, $holiday); $user->login = $old_login; if (!$numExample) { diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 6f21edeb9259a..63ed355b93843 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -103,7 +103,6 @@ parameters: - '#expects Adherent#' - '#expects BOM#' - '#expects FTP\\Connection#' - - '#expects Holiday#' - '#expects LDAP\\Connection#' - '#expects MultiCurrency#' - '#expects Productlot#' From bd764c16b3b24e4732fbb68c3f6ac7379c485dec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Wed, 3 Jul 2024 20:29:01 +0200 Subject: [PATCH 9/9] fix checkFunctionArgumentTypes --- htdocs/core/lib/functions2.lib.php | 2 +- .../core/modules/asset/mod_asset_advanced.php | 6 +++--- htdocs/core/modules/bom/mod_bom_advanced.php | 2 +- .../modules/product_batch/mod_sn_advanced.php | 19 +++++++++---------- .../modules/product_batch/mod_sn_free.php | 9 ++++++++- .../mod_knowledgerecord_advanced.php | 4 ++-- .../mymodule/mod_myobject_advanced.php | 4 ++-- .../partnership/mod_partnership_advanced.php | 4 ++-- .../mod_recruitmentcandidature_advanced.php | 2 +- .../mod_recruitmentjobposition_advanced.php | 2 +- phpstan.neon.dist | 1 + 11 files changed, 31 insertions(+), 24 deletions(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 00deffe10ad7d..3277bb7ab3c9f 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -893,7 +893,7 @@ function array2table($data, $tableMarkup = 1, $tableoptions = '', $troptions = ' * @param string $table Table containing field with counter * @param string $field Field containing already used values of counter * @param string $where To add a filter on selection (for example to filter on invoice types) - * @param Societe|string $objsoc The company that own the object we need a counter for + * @param Societe|'' $objsoc The company that own the object we need a counter for * @param string $date Date to use for the {y},{m},{d} tags. * @param string $mode 'next' for next value or 'last' for last value * @param bool $bentityon Activate the entity filter. Default is true (for modules not compatible with multicompany) diff --git a/htdocs/core/modules/asset/mod_asset_advanced.php b/htdocs/core/modules/asset/mod_asset_advanced.php index a1f800d309dce..a0aa657d536a6 100644 --- a/htdocs/core/modules/asset/mod_asset_advanced.php +++ b/htdocs/core/modules/asset/mod_asset_advanced.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) - * Copyright (C) 2019-2022 Frédéric France + * Copyright (C) 2019-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 @@ -98,7 +98,7 @@ public function info($langs) */ public function getExample() { - global $conf, $db, $langs, $mysoc; + global $db, $langs; $object = new Asset($db); $object->initAsSpecimen(); @@ -133,7 +133,7 @@ public function getNextValue($object) $date = $object->date; - $numFinal = get_next_value($db, $mask, 'asset', 'ref', '', null, $date); + $numFinal = get_next_value($db, $mask, 'asset', 'ref', '', '', $date); return $numFinal; } diff --git a/htdocs/core/modules/bom/mod_bom_advanced.php b/htdocs/core/modules/bom/mod_bom_advanced.php index 2428e79595d36..b1160222cba7c 100644 --- a/htdocs/core/modules/bom/mod_bom_advanced.php +++ b/htdocs/core/modules/bom/mod_bom_advanced.php @@ -138,7 +138,7 @@ public function getNextValue($objprod, $object) $date = ($object->date_bom ? $object->date_bom : $object->date); - $numFinal = get_next_value($db, $mask, 'bom_bom', 'ref', '', null, $date); + $numFinal = get_next_value($db, $mask, 'bom_bom', 'ref', '', '', $date); return $numFinal; } diff --git a/htdocs/core/modules/product_batch/mod_sn_advanced.php b/htdocs/core/modules/product_batch/mod_sn_advanced.php index 20fcb64d38218..6284ed2f7f3ad 100644 --- a/htdocs/core/modules/product_batch/mod_sn_advanced.php +++ b/htdocs/core/modules/product_batch/mod_sn_advanced.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019-2024 Frédéric France * Copyright (C) 2021 Christophe Battarel * Copyright (C) 2024 MDW * @@ -114,15 +114,14 @@ public function info($langs) */ public function getExample() { - global $conf, $langs, $mysoc; - - $old_code_client = $mysoc->code_client; - $old_code_type = $mysoc->typent_code; - $mysoc->code_client = 'CCCCCCCCCC'; - $mysoc->typent_code = 'TTTTTTTTTT'; - $numExample = $this->getNextValue($mysoc, ''); - $mysoc->code_client = $old_code_client; - $mysoc->typent_code = $old_code_type; + global $db, $langs; + + require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; + + $thirdparty = new Societe($db); + $thirdparty->initAsSpecimen(); + + $numExample = $this->getNextValue($thirdparty, ''); if (!$numExample) { $numExample = $langs->trans('NotConfigured'); diff --git a/htdocs/core/modules/product_batch/mod_sn_free.php b/htdocs/core/modules/product_batch/mod_sn_free.php index bd795c726a1b4..87d3e5e62cdde 100644 --- a/htdocs/core/modules/product_batch/mod_sn_free.php +++ b/htdocs/core/modules/product_batch/mod_sn_free.php @@ -75,7 +75,14 @@ public function info($langs) */ public function getExample() { - return $this->getNextValue(null, null); + global $db; + + require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; + + $thirdparty = new Societe($db); + $thirdparty->initAsSpecimen(); + + return $this->getNextValue($thirdparty, null); } /** diff --git a/htdocs/knowledgemanagement/core/modules/knowledgemanagement/mod_knowledgerecord_advanced.php b/htdocs/knowledgemanagement/core/modules/knowledgemanagement/mod_knowledgerecord_advanced.php index 0c1b043f00637..6e8903119d9ee 100644 --- a/htdocs/knowledgemanagement/core/modules/knowledgemanagement/mod_knowledgerecord_advanced.php +++ b/htdocs/knowledgemanagement/core/modules/knowledgemanagement/mod_knowledgerecord_advanced.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) - * Copyright (C) 2019-2021 Frédéric France + * Copyright (C) 2019-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 @@ -141,7 +141,7 @@ public function getNextValue($object) $date = $object->date; - $numFinal = get_next_value($db, $mask, 'knowledgemanagement_knowledgerecord', 'ref', '', null, $date); + $numFinal = get_next_value($db, $mask, 'knowledgemanagement_knowledgerecord', 'ref', '', '', $date); return $numFinal; } diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php index 208b4c4a054e3..25bb76993e73f 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019-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 @@ -140,7 +140,7 @@ public function getNextValue($object) $date = $object->date; - $numFinal = get_next_value($db, $mask, 'mymodule_myobject', 'ref', '', null, $date); + $numFinal = get_next_value($db, $mask, 'mymodule_myobject', 'ref', '', '', $date); return $numFinal; } diff --git a/htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php b/htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php index 75596eba9eae4..3db7ae28a6d52 100644 --- a/htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php +++ b/htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) - * Copyright (C) 2019-2023 Frédéric France + * Copyright (C) 2019-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 @@ -142,7 +142,7 @@ public function getNextValue($object) $date = $object->date; - $numFinal = get_next_value($db, $mask, 'partnership', 'ref', '', null, $date); + $numFinal = get_next_value($db, $mask, 'partnership', 'ref', '', '', $date); return $numFinal; } diff --git a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_advanced.php b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_advanced.php index c1258703e6cbc..8453dceacd48d 100644 --- a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_advanced.php +++ b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_advanced.php @@ -137,7 +137,7 @@ public function getNextValue($object) $date = $object->date ?? ''; - $numFinal = get_next_value($db, $mask, 'recruitment_recruitmentcandidature', 'ref', '', null, $date); + $numFinal = get_next_value($db, $mask, 'recruitment_recruitmentcandidature', 'ref', '', '', $date); return $numFinal; } diff --git a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php index 868b4b284e089..56efbf0239c20 100644 --- a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php +++ b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php @@ -137,7 +137,7 @@ public function getNextValue($object) $date = $object->date ?? ''; - $numFinal = get_next_value($db, $mask, 'recruitment_recruitmentjobposition', 'ref', '', null, $date); + $numFinal = get_next_value($db, $mask, 'recruitment_recruitmentjobposition', 'ref', '', '', $date); return $numFinal; } diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 63ed355b93843..8b2ec7364b7ad 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -111,6 +111,7 @@ parameters: - '#expects Paiement#' - '#expects PgSql\\Result#' - '#expects Societe#' + - '#expects ''''\|Societe#' - '#expects SupplierProposal#' - '#expects User#' - '#expects CommonObjectLine#'