From 23fecf4524f3424bc5b79bd7bc9540fd73e925a3 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 19:25:55 +0100 Subject: [PATCH 01/21] Fix Add to errors, not error which is not an array --- htdocs/contrat/class/contrat.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 232084addce..53102bc5a07 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1657,7 +1657,7 @@ class Contrat extends CommonObject $contractline->id = $contractlineid; $result = $contractline->insertExtraFields(); if ($result < 0) { - $this->error[] = $contractline->error; + $this->errors[] = $contractline->error; $error++; } } @@ -1851,7 +1851,7 @@ class Contrat extends CommonObject $result = $contractline->insertExtraFields(); if ($result < 0) { - $this->error[] = $contractline->error; + $this->errors[] = $contractline->error; $error++; } } From b28a17ee5195c2290a81a9424f75859d1f9fcc25 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 19:28:10 +0100 Subject: [PATCH 02/21] Fix Assign to error as string, not to error as array --- htdocs/variants/class/ProductCombination.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index ef23ce4857d..7e183f75362 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -884,7 +884,7 @@ class ProductCombination if ($result < 0) { //In case the error is not related with an already existing product if ($newproduct->error != 'ErrorProductAlreadyExists') { - $this->error[] = $newproduct->error; + $this->error = $newproduct->error; $this->errors = $newproduct->errors; $this->db->rollback(); return -1; From b57b4c8f1733fd578350862965417d1a1e05cd14 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 19:42:07 +0100 Subject: [PATCH 03/21] Qual: Improve typing hints, in particular sendtoid --- htdocs/core/class/commonobject.class.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 44de1d12109..9b4c10a21fd 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -226,13 +226,13 @@ abstract class CommonObject /** * @var Project The related project object - * @deprecated - * @see project + * @deprecated Use $project instead + * @see $project */ public $projet; /** - * @deprecated + * @deprecated Use $fk_project instead * @see $fk_project */ public $fk_projet; @@ -322,7 +322,7 @@ abstract class CommonObject /** * @var int The object's status. Use status instead. - * @deprecated + * @deprecated Use $status instead * @see setStatut() */ public $statut; @@ -369,7 +369,7 @@ abstract class CommonObject /** * var int State ID - * @deprecated Use state_id. We can remove this property when the field 'fk_departement' have been renamed into 'state_id' in all tables + * @deprecated Use $state_id. We can remove this property when the field 'fk_departement' have been renamed into 'state_id' in all tables */ public $fk_departement; @@ -447,7 +447,7 @@ abstract class CommonObject /** * @var int Payment terms ID - * @deprecated Kept for compatibility + * @deprecated Use $cond_reglement_id instead - Kept for compatibility * @see cond_reglement_id; */ public $cond_reglement; @@ -730,13 +730,13 @@ abstract class CommonObject public $specimen = 0; /** - * @var int Id of contact to send object (used by the trigger of module Agenda) + * @var int[] Id of contacts to send objects (mails, etc.) */ public $sendtoid; /** * @var float Amount already paid from getSommePaiement() (used to show correct status) - * @deprecated Duplicate of $totalpaid + * @deprecated Use $totalpaid instead */ public $alreadypaid; /** From 6ab1e6e7d91d10f919d2bf818a262c2f8e247596 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 19:43:34 +0100 Subject: [PATCH 04/21] Qual: Add typing information --- htdocs/core/actions_sendmails.inc.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 2a5dc287f2b..58a877cca75 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 MDW * Copyright (C) 2013 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -29,6 +30,10 @@ // $triggersendname must be set (can be '') // $actiontypecode can be set // $object and $uobject may be defined +' +@phan-var-force Societe $mysoc +@phan-var-force CommonObject $object +'; /* * Add file in email form @@ -357,7 +362,7 @@ if (($action == 'send' || $action == 'relance') && !GETPOST('addfile') && !GETPO $substitutionarray['__EMAIL__'] = $sendto; $substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? '' : ''; - $parameters = array('mode'=>'formemail'); + $parameters = array('mode' => 'formemail'); complete_substitutions_array($substitutionarray, $langs, $object, $parameters); $subject = make_substitutions($subject, $substitutionarray); From db0134183de93f8263f25e811578bd947d7c633c Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 19:57:49 +0100 Subject: [PATCH 05/21] Qual: improve hist typing --- htdocs/core/lib/company.lib.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 0e9927aad5d..2c82eec316b 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -2043,6 +2043,8 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = null, $nopr } } + '@phan-var-force array,datestart:int,dateend:int,fk_element:string,elementtype:string,contact_id:string,lastname:string,firstname:string,contact_photo:string,socpeaopleassigned:int[],login:string,userfirstname:string,userlastname:string,userphoto:string}> $histo'; + if (isModEnabled('agenda') || (isModEnabled('mailing') && !empty($objcon->email))) { $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; From 07d63e5bf376b4c3f01918ee2ef04ae7ead3df3f Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 20:02:25 +0100 Subject: [PATCH 06/21] Fix Add to errors, not error which is not an array --- htdocs/delivery/class/delivery.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index b4d139a0120..d57a25e96ba 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -7,6 +7,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2023-2024 Frédéric France + * 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 @@ -615,7 +616,7 @@ class Delivery extends CommonObject $result = $line->insertExtraFields(); if ($result < 0) { - $this->error[] = $line->error; + $this->errors[] = $line->error; $error++; } } @@ -826,7 +827,7 @@ class Delivery extends CommonObject global $action; $hookmanager->initHooks(array($this->element . 'dao')); - $parameters = array('id'=>$this->id, 'getnomurl' => &$result); + $parameters = array('id' => $this->id, 'getnomurl' => &$result); $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) { $result = $hookmanager->resPrint; From 29644f2ae869c353ee59e0a64df6871d0ec1d5d9 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 20:05:00 +0100 Subject: [PATCH 07/21] Fix Add to errors, not error which is not an array --- htdocs/partnership/class/partnership.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index 51e44645703..b03747a8129 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -205,7 +205,7 @@ class Partnership extends CommonObject public function create(User $user, $notrigger = 0) { if ($this->fk_soc <= 0 && $this->fk_member <= 0) { - $this->error[] = "ErrorThirpdartyOrMemberidIsMandatory"; + $this->errors[] = "ErrorThirpdartyOrMemberidIsMandatory"; return -1; } @@ -522,7 +522,7 @@ class Partnership extends CommonObject public function update(User $user, $notrigger = 0) { if ($this->fk_soc <= 0 && $this->fk_member <= 0) { - $this->error[] = "ErrorThirpdartyOrMemberidIsMandatory"; + $this->errors[] = "ErrorThirpdartyOrMemberidIsMandatory"; // Mistyping in key is in translations return -1; } if (empty($this->fk_user_creat)) { // For the case the object was created with empty user (from public page). From 18c4bfd808d03afc4347c9db8e4bbfb89002ea9e Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 20:08:10 +0100 Subject: [PATCH 08/21] Fix Initialise ->error as '' --- .../dynamic_price/class/price_global_variable_updater.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php b/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php index c0ec8226e3d..11b8b1db214 100644 --- a/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php +++ b/htdocs/product/dynamic_price/class/price_global_variable_updater.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Ion Agorria * Copyright (C) 2024 Frédéric France + * 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 From 59abbda92ff3604af9877b137b2f3e5a8210e882 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 20:16:45 +0100 Subject: [PATCH 09/21] Fix Assign 0 to fk_bank not null (dolibarr's way) --- htdocs/expensereport/payment/list.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/expensereport/payment/list.php b/htdocs/expensereport/payment/list.php index bd3ba374d76..c1f474af0db 100644 --- a/htdocs/expensereport/payment/list.php +++ b/htdocs/expensereport/payment/list.php @@ -12,6 +12,7 @@ * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2020 Tobias Sekan * Copyright (C) 2021 Ferran Marcet + * 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 From 575e620300ef502c790d645375bdc6a9f10e299c Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 20:19:01 +0100 Subject: [PATCH 10/21] Fix Assign 0 to fk_project, not null (dolibarr's way) --- htdocs/fourn/class/fournisseur.facture.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index cd90cf86179..8084c99c40b 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -15,6 +15,7 @@ * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2022 Gauthier VERDOL * Copyright (C) 2023 Nick Fragoulis + * 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 @@ -1196,9 +1197,9 @@ class FactureFournisseur extends CommonInvoice } if (isset($this->fk_project)) { if (empty($this->fk_project)) { - $this->fk_project = null; + $this->fk_project = 0; } else { - $this->fk_project = intval($this->fk_project); + $this->fk_project = (int) $this->fk_project; } } if (isset($this->cond_reglement_id)) { From cc5207a5316e42d4ce0ec2a7b6f5f2fe5cea114a Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 20:20:38 +0100 Subject: [PATCH 11/21] Fix rate can be null --- htdocs/multicurrency/class/multicurrency.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index f2ff645052c..ed4affb4e1a 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -5,6 +5,7 @@ * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2016 Pierre-Henry Favre * Copyright (C) 2024 Frédéric France + * 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 @@ -90,7 +91,7 @@ class MultiCurrency extends CommonObject public $fk_user; /** - * @var CurrencyRate|null The currency rate + * @var ?CurrencyRate The currency rate */ public $rate; From 3e49424f2fc04e76d3f83310512432ae4630df4c Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 20:29:05 +0100 Subject: [PATCH 12/21] Fix finished can be null && defautl fk is 0 --- htdocs/product/card.php | 2 +- htdocs/product/class/product.class.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 086163975a3..0f37edaf398 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -807,7 +807,7 @@ if (empty($reshook)) { if ($fk_default_bom >= 0) { $object->fk_default_bom = $fk_default_bom; } else { - $object->fk_default_bom = null; + $object->fk_default_bom = 0; } $units = GETPOSTINT('units'); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 5c59e925394..dc69488ce8b 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -310,7 +310,7 @@ class Product extends CommonObject /** * Status indicates whether the product is on sale '1' or not '0' * @var int - * @deprecated + * @deprecated Use $status instead * @see $status */ public $tosell; @@ -325,7 +325,7 @@ class Product extends CommonObject /** * Status indicate whether the product is available for purchase '1' or not '0' * @var int - * @deprecated + * @deprecated Use $status_buy instead * @see $status_buy */ public $tobuy; @@ -333,7 +333,7 @@ class Product extends CommonObject /** * Status indicates whether the product is a finished product '1' or a raw material '0' * - * @var int + * @var ?int */ public $finished; From 8cc6b3133778c7495f6e77c2e07a7f5b8975dec1 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 21:25:44 +0100 Subject: [PATCH 13/21] Fix empty label is '', not null --- htdocs/public/stripe/ipn.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index 1cbedcc9342..0b78780cfe4 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -2,6 +2,7 @@ /* Copyright (C) 2018-2020 Thibault FOUCART * Copyright (C) 2018 Fédéric France * Copyright (C) 2023 Laurent Destailleur + * 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 @@ -689,7 +690,7 @@ if ($event->type == 'payout.created') { $companypaymentmode->stripe_card_ref = $db->escape($event->data->object->id); $companypaymentmode->fk_soc = $idthirdparty; $companypaymentmode->bank = null; - $companypaymentmode->label = null; + $companypaymentmode->label = ''; $companypaymentmode->number = $db->escape($event->data->object->id); $companypaymentmode->last_four = $db->escape($event->data->object->card->last4); $companypaymentmode->card_type = $db->escape($event->data->object->card->branding); @@ -725,7 +726,7 @@ if ($event->type == 'payout.created') { if ($companypaymentmode->id > 0) { // If we found a payment mode with the ID $companypaymentmode->bank = null; - $companypaymentmode->label = null; + $companypaymentmode->label = ''; $companypaymentmode->number = $db->escape($event->data->object->id); $companypaymentmode->last_four = $db->escape($event->data->object->card->last4); $companypaymentmode->proprio = $db->escape($event->data->object->billing_details->name); From 6a606bf7c11f033059a2663d761411d5ae2a0a20 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 21:34:07 +0100 Subject: [PATCH 14/21] Adjust typing for 'origin' & 'origin_object' --- htdocs/core/class/commonobject.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 9b4c10a21fd..ea197a8d0d0 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -274,13 +274,13 @@ abstract class CommonObject public $origin_id; /** - * @var Object Origin object. This is set by fetch_origin() from this->origin and this->origin_id. + * @var ?CommonObject Origin object. This is set by fetch_origin() from this->origin and this->origin_id. */ public $origin_object; /** - * @var string|CommonObject Sometime the type of the originating object ('commande', 'facture', ...), sometime the object (like onh MouvementStock) - * @deprecated Use now $origin_type and $origin_id; + * @var CommonObject|string|null Sometimes the type of the originating object ('commande', 'facture', ...), sometimes the object (as with MouvementStock) + * @deprecated Use now $origin_type and $origin_id; * @see fetch_origin() */ public $origin; From c31c883a9175e057d6ef7432fdd5d8b2bb6f3f02 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 21:37:09 +0100 Subject: [PATCH 15/21] Ensure typing for commandeFournisseur matches --- htdocs/reception/class/reception.class.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 5d7b262f22e..67e29c85fc1 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -12,6 +12,7 @@ * Copyright (C) 2016-2022 Ferran Marcet * Copyright (C) 2018 Quentin Vial-Gouteyron * Copyright (C) 2022-2024 Frédéric France + * 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 @@ -125,7 +126,7 @@ class Reception extends CommonObject public $listmeths; // List of carriers /** - * @var CommandeFournisseur + * @var ?CommandeFournisseur */ public $commandeFournisseur; @@ -731,7 +732,11 @@ class Reception extends CommonObject $this->fetch_origin(); if (empty($this->origin_object->lines)) { $res = $this->origin_object->fetch_lines(); - $this->commandeFournisseur = $this->origin_object; // deprecated + if ($this->origin_object instanceof CommandeFournisseur) { + $this->commandeFournisseur = $this->origin_object; // deprecated + } else { + $this->commandeFournisseur = null; // deprecated + } if ($res < 0) { return $res; } @@ -742,7 +747,7 @@ class Reception extends CommonObject $qty_wished = array(); $supplierorderdispatch = new CommandeFournisseurDispatch($this->db); - $filter = array('t.fk_commande'=>$this->origin_id); + $filter = array('t.fk_commande' => $this->origin_id); if (getDolGlobalInt('SUPPLIER_ORDER_USE_DISPATCH_STATUS')) { $filter['t.status'] = 1; // Restrict to lines with status validated } @@ -1305,7 +1310,7 @@ class Reception extends CommonObject global $action; $hookmanager->initHooks(array($this->element . 'dao')); - $parameters = array('id'=>$this->id, 'getnomurl' => &$result); + $parameters = array('id' => $this->id, 'getnomurl' => &$result); $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) { $result = $hookmanager->resPrint; From b072966cc8cd8e787c91d08cabb38b7c4eaf091c Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 21:40:27 +0100 Subject: [PATCH 16/21] Fix Initialise id to 0 and ref to '' --- htdocs/salaries/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 0159b9b93a9..4e7024d83c2 100644 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -402,7 +402,8 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) { if ($object->id > 0) { $object->paye = 0; - $object->id = $object->ref = null; + $object->id = 0; + $object->ref = ''; if (GETPOST('amount', 'alphanohtml')) { $object->amount = price2num(GETPOST('amount', 'alphanohtml'), 'MT', 2); From e36dccff599fd722c507068d5aef91186efc77d9 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 21:46:14 +0100 Subject: [PATCH 17/21] Qual: better typing for getCountry() --- htdocs/core/lib/company.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 2c82eec316b..bae98beff93 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -524,7 +524,7 @@ function societe_admin_prepare_head() * @param Translate $outputlangs Langs object for output translation * @param int $entconv 0=Return value without entities and not converted to output charset, 1=Ready for html output * @param string $searchlabel Label of country to search (warning: searching on label is not reliable) - * @return mixed Integer with country id or String with country code or translated country name or Array('id','code','label') or 'NotDefined' + * @return int|string|array{id:int,code:string,label:string} Integer with country id or String with country code or translated country name or Array('id','code','label') or 'NotDefined' */ function getCountry($searchkey, $withcode = '', $dbtouse = null, $outputlangs = null, $entconv = 1, $searchlabel = '') { From 4e05ac84f147b878e80f890646ec71f08f85af11 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 21:55:43 +0100 Subject: [PATCH 18/21] Init code_client and code_fournisseur to '', not null --- htdocs/societe/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 8eda5988f80..52921b28c80 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -562,12 +562,12 @@ if (empty($reshook)) { } else { if ($result == -3 && in_array('ErrorCustomerCodeAlreadyUsed', $object->errors)) { $duplicate_code_error = true; - $object->code_client = null; + $object->code_client = ''; } if ($result == -3 && in_array('ErrorSupplierCodeAlreadyUsed', $object->errors)) { $duplicate_code_error = true; - $object->code_fournisseur = null; + $object->code_fournisseur = ''; } if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { // TODO Sometime errors on duplicate on profid and not on code, so we must manage this case From 7025738db859466d284810e16ca4e82b4ef14b35 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 22:00:55 +0100 Subject: [PATCH 19/21] Fix fields initialisation --- .../class/companybankaccount.class.php | 74 +++++++++---------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index 86bbab8910c..a30927fafb3 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -94,43 +94,43 @@ class CompanyBankAccount extends Account 'fk_soc' => array('type' => 'integer:Societe:societe/class/societe.class.php', 'label' => 'ThirdParty', 'picto' => 'company', 'enabled' => 1, 'position' => 20, 'notnull' => 1, 'visible' => -1, 'css' => 'maxwidth500 widthcentpercentminusxx', 'csslist' => 'tdoverflowmax150',), 'datec' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'position' => 25, 'notnull' => 0, 'visible' => -1,), 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'position' => 30, 'notnull' => 1, 'visible' => -1,), - 'label' => array('type' => 'varchar(200)', 'label' => 'Label', 'enabled' => 1, 'position' => 35, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1', 'css' => 'minwidth300', 'cssview' => 'wordbreak', 'csslist' => 'tdoverflowmax150',), - 'bank' => array('type' => 'varchar(255)', 'label' => 'Bank', 'enabled' => 1, 'position' => 40, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'code_banque' => array('type' => 'varchar(128)', 'label' => 'Codebanque', 'enabled' => 1, 'position' => 45, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'code_guichet' => array('type' => 'varchar(6)', 'label' => 'Codeguichet', 'enabled' => 1, 'position' => 50, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'number' => array('type' => 'varchar(255)', 'label' => 'Number', 'enabled' => 1, 'position' => 55, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'cle_rib' => array('type' => 'varchar(5)', 'label' => 'Clerib', 'enabled' => 1, 'position' => 60, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'bic' => array('type' => 'varchar(20)', 'label' => 'Bic', 'enabled' => 1, 'position' => 65, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'iban_prefix' => array('type' => 'varchar(34)', 'label' => 'Ibanprefix', 'enabled' => 1, 'position' => 70, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'domiciliation' => array('type' => 'varchar(255)', 'label' => 'Domiciliation', 'enabled' => 1, 'position' => 75, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'proprio' => array('type' => 'varchar(60)', 'label' => 'Proprio', 'enabled' => 1, 'position' => 80, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'owner_address' => array('type' => 'varchar(255)', 'label' => 'Owneraddress', 'enabled' => 1, 'position' => 85, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'default_rib' => array('type' => 'smallint(6)', 'label' => 'Defaultrib', 'enabled' => 1, 'position' => 90, 'notnull' => 1, 'visible' => -1, 'alwayseditable' => '1',), - 'state_id' => array('type' => 'integer', 'label' => 'Stateid', 'enabled' => 1, 'position' => 95, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'fk_country' => array('type' => 'integer', 'label' => 'Fkcountry', 'enabled' => 1, 'position' => 100, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1', 'css' => 'maxwidth500 widthcentpercentminusxx',), - 'currency_code' => array('type' => 'varchar(3)', 'label' => 'Currencycode', 'enabled' => 1, 'position' => 105, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'rum' => array('type' => 'varchar(32)', 'label' => 'Rum', 'enabled' => 1, 'position' => 110, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'date_rum' => array('type' => 'date', 'label' => 'Daterum', 'enabled' => 1, 'position' => 115, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'frstrecur' => array('type' => 'varchar(16)', 'label' => 'Frstrecur', 'enabled' => 1, 'position' => 120, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'position' => 900, 'notnull' => 0, 'visible' => -2, 'alwayseditable' => '1',), - 'last_four' => array('type' => 'varchar(4)', 'label' => 'Lastfour', 'enabled' => 1, 'position' => 130, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'card_type' => array('type' => 'varchar(255)', 'label' => 'Cardtype', 'enabled' => 1, 'position' => 135, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'cvn' => array('type' => 'varchar(255)', 'label' => 'Cvn', 'enabled' => 1, 'position' => 140, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'exp_date_month' => array('type' => 'integer', 'label' => 'Expdatemonth', 'enabled' => 1, 'position' => 145, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'exp_date_year' => array('type' => 'integer', 'label' => 'Expdateyear', 'enabled' => 1, 'position' => 150, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'country_code' => array('type' => 'varchar(10)', 'label' => 'Countrycode', 'enabled' => 1, 'position' => 155, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'approved' => array('type' => 'integer', 'label' => 'Approved', 'enabled' => 1, 'position' => 160, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'email' => array('type' => 'varchar(255)', 'label' => 'Email', 'enabled' => 1, 'position' => 165, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'ending_date' => array('type' => 'date', 'label' => 'Endingdate', 'enabled' => 1, 'position' => 170, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'max_total_amount_of_all_payments' => array('type' => 'double(24,8)', 'label' => 'Maxtotalamountofallpayments', 'enabled' => 1, 'position' => 175, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'preapproval_key' => array('type' => 'varchar(255)', 'label' => 'Preapprovalkey', 'enabled' => 1, 'position' => 180, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'starting_date' => array('type' => 'date', 'label' => 'Startingdate', 'enabled' => 1, 'position' => 185, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'total_amount_of_all_payments' => array('type' => 'double(24,8)', 'label' => 'Totalamountofallpayments', 'enabled' => 1, 'position' => 190, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'stripe_card_ref' => array('type' => 'varchar(128)', 'label' => 'Stripecardref', 'enabled' => 1, 'position' => 195, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'status' => array('type' => 'integer', 'label' => 'Status', 'enabled' => 1, 'position' => 500, 'notnull' => 1, 'visible' => -1, 'alwayseditable' => '1',), - 'comment' => array('type' => 'varchar(255)', 'label' => 'Comment', 'enabled' => 1, 'position' => 205, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'ipaddress' => array('type' => 'varchar(68)', 'label' => 'Ipaddress', 'enabled' => 1, 'position' => 210, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), - 'stripe_account' => array('type' => 'varchar(128)', 'label' => 'Stripeaccount', 'enabled' => 1, 'position' => 215, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => '1',), + 'label' => array('type' => 'varchar(200)', 'label' => 'Label', 'enabled' => 1, 'position' => 35, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1, 'css' => 'minwidth300', 'cssview' => 'wordbreak', 'csslist' => 'tdoverflowmax150',), + 'bank' => array('type' => 'varchar(255)', 'label' => 'Bank', 'enabled' => 1, 'position' => 40, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'code_banque' => array('type' => 'varchar(128)', 'label' => 'Codebanque', 'enabled' => 1, 'position' => 45, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'code_guichet' => array('type' => 'varchar(6)', 'label' => 'Codeguichet', 'enabled' => 1, 'position' => 50, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'number' => array('type' => 'varchar(255)', 'label' => 'Number', 'enabled' => 1, 'position' => 55, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'cle_rib' => array('type' => 'varchar(5)', 'label' => 'Clerib', 'enabled' => 1, 'position' => 60, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'bic' => array('type' => 'varchar(20)', 'label' => 'Bic', 'enabled' => 1, 'position' => 65, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'iban_prefix' => array('type' => 'varchar(34)', 'label' => 'Ibanprefix', 'enabled' => 1, 'position' => 70, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'domiciliation' => array('type' => 'varchar(255)', 'label' => 'Domiciliation', 'enabled' => 1, 'position' => 75, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'proprio' => array('type' => 'varchar(60)', 'label' => 'Proprio', 'enabled' => 1, 'position' => 80, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'owner_address' => array('type' => 'varchar(255)', 'label' => 'Owneraddress', 'enabled' => 1, 'position' => 85, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'default_rib' => array('type' => 'smallint(6)', 'label' => 'Defaultrib', 'enabled' => 1, 'position' => 90, 'notnull' => 1, 'visible' => -1, 'alwayseditable' => 1,), + 'state_id' => array('type' => 'integer', 'label' => 'Stateid', 'enabled' => 1, 'position' => 95, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'fk_country' => array('type' => 'integer', 'label' => 'Fkcountry', 'enabled' => 1, 'position' => 100, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1, 'css' => 'maxwidth500 widthcentpercentminusxx',), + 'currency_code' => array('type' => 'varchar(3)', 'label' => 'Currencycode', 'enabled' => 1, 'position' => 105, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'rum' => array('type' => 'varchar(32)', 'label' => 'Rum', 'enabled' => 1, 'position' => 110, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'date_rum' => array('type' => 'date', 'label' => 'Daterum', 'enabled' => 1, 'position' => 115, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'frstrecur' => array('type' => 'varchar(16)', 'label' => 'Frstrecur', 'enabled' => 1, 'position' => 120, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'position' => 900, 'notnull' => 0, 'visible' => -2, 'alwayseditable' => 1,), + 'last_four' => array('type' => 'varchar(4)', 'label' => 'Lastfour', 'enabled' => 1, 'position' => 130, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'card_type' => array('type' => 'varchar(255)', 'label' => 'Cardtype', 'enabled' => 1, 'position' => 135, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'cvn' => array('type' => 'varchar(255)', 'label' => 'Cvn', 'enabled' => 1, 'position' => 140, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'exp_date_month' => array('type' => 'integer', 'label' => 'Expdatemonth', 'enabled' => 1, 'position' => 145, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'exp_date_year' => array('type' => 'integer', 'label' => 'Expdateyear', 'enabled' => 1, 'position' => 150, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'country_code' => array('type' => 'varchar(10)', 'label' => 'Countrycode', 'enabled' => 1, 'position' => 155, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'approved' => array('type' => 'integer', 'label' => 'Approved', 'enabled' => 1, 'position' => 160, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'email' => array('type' => 'varchar(255)', 'label' => 'Email', 'enabled' => 1, 'position' => 165, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'ending_date' => array('type' => 'date', 'label' => 'Endingdate', 'enabled' => 1, 'position' => 170, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'max_total_amount_of_all_payments' => array('type' => 'double(24,8)', 'label' => 'Maxtotalamountofallpayments', 'enabled' => 1, 'position' => 175, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'preapproval_key' => array('type' => 'varchar(255)', 'label' => 'Preapprovalkey', 'enabled' => 1, 'position' => 180, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'starting_date' => array('type' => 'date', 'label' => 'Startingdate', 'enabled' => 1, 'position' => 185, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'total_amount_of_all_payments' => array('type' => 'double(24,8)', 'label' => 'Totalamountofallpayments', 'enabled' => 1, 'position' => 190, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'stripe_card_ref' => array('type' => 'varchar(128)', 'label' => 'Stripecardref', 'enabled' => 1, 'position' => 195, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'status' => array('type' => 'integer', 'label' => 'Status', 'enabled' => 1, 'position' => 500, 'notnull' => 1, 'visible' => -1, 'alwayseditable' => 1,), + 'comment' => array('type' => 'varchar(255)', 'label' => 'Comment', 'enabled' => 1, 'position' => 205, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'ipaddress' => array('type' => 'varchar(68)', 'label' => 'Ipaddress', 'enabled' => 1, 'position' => 210, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), + 'stripe_account' => array('type' => 'varchar(128)', 'label' => 'Stripeaccount', 'enabled' => 1, 'position' => 215, 'notnull' => 0, 'visible' => -1, 'alwayseditable' => 1,), 'last_main_doc' => array('type' => 'varchar(255)', 'label' => 'LastMainDoc', 'enabled' => 1, 'visible' => 0, 'position' => 230), ); From a5acb448902189ba19839d467b5950501ba79a95 Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 22:18:13 +0100 Subject: [PATCH 20/21] Fix origin_email and track_id can be null --- htdocs/ticket/class/ticket.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 778bd6ef730..cdfb8beef07 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -76,7 +76,7 @@ class Ticket extends CommonObject /** - * @var string Hash to identify ticket publicly + * @var ?string Hash to identify ticket publicly */ public $track_id; @@ -97,17 +97,17 @@ class Ticket extends CommonObject public $fk_contract; /** - * @var string Person email who have create ticket + * @var ?string Email of person who created the ticket */ public $origin_email; /** - * @var int User id who have create ticket + * @var int User id who created the ticket */ public $fk_user_create; /** - * @var int User id who have ticket assigned + * @var int User id who the ticket is assigned to */ public $fk_user_assign; From ec6786ece323eb168c8a6fb1f4201b5046b5f0de Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 13 Mar 2024 19:56:19 +0100 Subject: [PATCH 21/21] Detect PhanTypeMismatchPropertyProbablyReal --- dev/tools/phan/baseline.txt | 2 ++ dev/tools/phan/config.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index c56fd81b5d6..0fa37276d34 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -70,6 +70,7 @@ return [ 'htdocs/core/modules/mrp/doc/pdf_vinci.modules.php' => ['PhanTypeArraySuspiciousNull'], 'htdocs/core/modules/syslog/mod_syslog_file.php' => ['PhanParamSignatureMismatch', 'PhanParamSuspiciousOrder'], 'htdocs/core/modules/syslog/mod_syslog_syslog.php' => ['PhanParamSignatureMismatch'], + 'htdocs/core/triggers/interface_80_modStripe_Stripe.class.php' => ['PhanTypeMismatchPropertyProbablyReal'], 'htdocs/don/class/don.class.php' => ['PhanParamTooMany'], 'htdocs/expensereport/class/paymentexpensereport.class.php' => ['PhanTypeInvalidUnaryOperandNumeric'], 'htdocs/fourn/class/api_supplier_invoices.class.php' => ['PhanPluginSuspiciousParamOrder'], @@ -82,6 +83,7 @@ return [ 'htdocs/public/opensurvey/index.php' => ['PhanPluginSuspiciousParamOrder'], 'htdocs/public/payment/paymentok.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/public/recruitment/index.php' => ['PhanPluginSuspiciousParamOrder'], + 'htdocs/societe/paymentmodes.php' => ['PhanTypeMismatchPropertyProbablyReal'], 'htdocs/societe/class/companybankaccount.class.php' => ['PhanParamSignatureMismatch'], 'htdocs/stripe/class/actions_stripe.class.php' => ['PhanPluginSuspiciousParamPosition'], 'htdocs/takepos/invoice.php' => ['PhanPluginSuspiciousParamPosition'], diff --git a/dev/tools/phan/config.php b/dev/tools/phan/config.php index 4232427191a..c698f693e59 100644 --- a/dev/tools/phan/config.php +++ b/dev/tools/phan/config.php @@ -457,7 +457,7 @@ return [ 'PhanPluginUnknownClosureReturnType', // 'PhanPluginNoCommentOnProtectedMethod', // 'PhanTypeArraySuspicious', - 'PhanTypeMismatchPropertyProbablyReal', + // 'PhanTypeMismatchPropertyProbablyReal', // 'PhanPluginNoCommentOnPrivateMethod', 'PhanPluginUnknownArrayFunctionReturnType', 'PhanTypeInvalidLeftOperandOfAdd',