From acda13eddf518bd2b5bbfd37a5d7cbab4c2df22a Mon Sep 17 00:00:00 2001 From: MDW Date: Fri, 25 Oct 2024 17:11:39 +0200 Subject: [PATCH 1/2] Qual: Fix phan/stan notices for facture-rec.class (#31489) * Qual: Fix phan/stan notices for facture-rec.class * Update fournisseur.facture-rec.class.php * Update fournisseur.facture.class.php * Update fournisseur.facture-rec.class.php * Update fournisseur.facture-rec.class.php * Update fournisseur.facture-rec.class.php --------- Co-authored-by: Laurent Destailleur --- dev/tools/phan/baseline.txt | 1 - .../class/fournisseur.facture-rec.class.php | 119 ++++++++++++++---- 2 files changed, 92 insertions(+), 28 deletions(-) diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 2e64f9eafdacb..581e6260bedcc 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -532,7 +532,6 @@ return [ 'htdocs/fourn/class/api_supplier_orders.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/fourn/class/fournisseur.class.php' => ['PhanPluginUnknownArrayMethodReturnType'], 'htdocs/fourn/class/fournisseur.commande.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredProperty'], - 'htdocs/fourn/class/fournisseur.facture-rec.class.php' => ['PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'], 'htdocs/fourn/class/paiementfourn.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType', 'PhanPossiblyNullTypeMismatchProperty', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/fourn/commande/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], 'htdocs/fourn/commande/contact.php' => ['PhanUndeclaredGlobalVariable'], diff --git a/htdocs/fourn/class/fournisseur.facture-rec.class.php b/htdocs/fourn/class/fournisseur.facture-rec.class.php index b1359c344e667..db1b79ad4c6ea 100644 --- a/htdocs/fourn/class/fournisseur.facture-rec.class.php +++ b/htdocs/fourn/class/fournisseur.facture-rec.class.php @@ -83,7 +83,14 @@ class FactureFournisseurRec extends CommonInvoice */ public $title; + /** + * @var string + * @deprecated + */ public $ref_supplier; + /** + * @var int + */ public $socid; /** @@ -92,6 +99,9 @@ class FactureFournisseurRec extends CommonInvoice */ public $fk_soc; + /** + * @var int + */ public $suspended; // status /** @@ -105,39 +115,87 @@ class FactureFournisseurRec extends CommonInvoice public $label; /** - * @var double $amount + * @var float $amount * @deprecated */ public $amount; /** - * @var double $remise + * @var float * @deprecated */ public $remise; + /** + * @var string + */ public $vat_src_code; + /** + * @var float + */ public $localtax1; + /** + * @var float + */ public $localtax2; + /** + * @var User + */ public $user_author; + /** + * @var int + */ public $user_modif; + /** + * @var int + */ public $fk_project; + /** + * @var int + */ public $mode_reglement_id; + /** + * @var string + */ public $mode_reglement_code; + /** + * @var string + */ public $cond_reglement_code; + /** + * @var string + */ public $cond_reglement_doc; + /** + * @var int + */ public $cond_reglement_id; /** - * @var int Deadline for payment + * @var int Deadline for payment */ public $date_lim_reglement; + /** + * @var int<0,1> + */ public $usenewprice = 0; + /** + * @var int + */ public $frequency; + /** + * @var string + */ public $unit_frequency; + /** + * @var ?int + */ public $date_when; + /** + * @var ?int + */ public $date_last_gen; /** @@ -154,6 +212,9 @@ class FactureFournisseurRec extends CommonInvoice * @var int<0,1> auto validate 0 to create in draft, 1 to create and validate the new invoice */ public $auto_validate; // + /** + * @var ?int<0,1> + */ public $generate_pdf; // 1 to generate PDF on invoice generation (default) /** @@ -384,31 +445,34 @@ public function create($user, $facFournId, $notrigger = 0) // Add lines $num = count($facfourn_src->lines); for ($i = 0; $i < $num; $i++) { - $tva_tx = $facfourn_src->lines[$i]->tva_tx; - if (!empty($facfourn_src->lines[$i]->vat_src_code) && !preg_match('/\(/', (string) $tva_tx)) { - $tva_tx .= ' ('.$facfourn_src->lines[$i]->vat_src_code.')'; + $facfourn_line = $facfourn_src->lines[$i]; + '@phan-var-force SupplierInvoiceLine $facfourn_line'; + + $tva_tx = $facfourn_line->tva_tx; + if (!empty($facfourn_line->vat_src_code) && !preg_match('/\(/', (string) $tva_tx)) { + $tva_tx .= ' ('.$facfourn_line->vat_src_code.')'; } $result_insert = $this->addline( - $facfourn_src->lines[$i]->fk_product, - $facfourn_src->lines[$i]->ref_supplier, - $facfourn_src->lines[$i]->product_label, - $facfourn_src->lines[$i]->desc ? $facfourn_src->lines[$i]->desc : $facfourn_src->lines[$i]->description, - $facfourn_src->lines[$i]->pu_ht, - $facfourn_src->lines[$i]->pu_ttc, - $facfourn_src->lines[$i]->qty, - $facfourn_src->lines[$i]->remise_percent, + $facfourn_line->fk_product, + $facfourn_line->ref_supplier, + $facfourn_line->product_label, + $facfourn_line->desc ? $facfourn_line->desc : $facfourn_line->description, + $facfourn_line->pu_ht, + $facfourn_line->pu_ttc, + $facfourn_line->qty, + $facfourn_line->remise_percent, $tva_tx, - $facfourn_src->lines[$i]->localtax1_tx, - $facfourn_src->lines[$i]->localtax2_tx, + $facfourn_line->localtax1_tx, + $facfourn_line->localtax2_tx, 'HT', - $facfourn_src->lines[$i]->product_type, - $facfourn_src->lines[$i]->date_start, - $facfourn_src->lines[$i]->date_end, - $facfourn_src->lines[$i]->info_bits, - $facfourn_src->lines[$i]->special_code, - $facfourn_src->lines[$i]->rang, - $facfourn_src->lines[$i]->fk_unit + $facfourn_line->product_type, + $facfourn_line->date_start, + $facfourn_line->date_end, + $facfourn_line->info_bits, + $facfourn_line->special_code, + $facfourn_line->rang, + $facfourn_line->fk_unit ); if ($result_insert < 0) { @@ -419,9 +483,9 @@ public function create($user, $facFournId, $notrigger = 0) $result2 = $objectline->fetch($result_insert); if ($result2 > 0) { // Extrafields - if (method_exists($facfourn_src->lines[$i], 'fetch_optionals')) { - $facfourn_src->lines[$i]->fetch_optionals($facfourn_src->lines[$i]->id); - $objectline->array_options = $facfourn_src->lines[$i]->array_options; + if (method_exists($facfourn_line, 'fetch_optionals')) { + $facfourn_line->fetch_optionals($facfourn_line->id); + $objectline->array_options = $facfourn_line->array_options; } $result = $objectline->insertExtraFields(); @@ -1403,7 +1467,8 @@ public function createRecurringInvoices($restrictioninvoiceid = 0, $forcevalidat if (!$error && $invoiceidgenerated >= 0) { $facturerec->nb_gen_done++; $facturerec->date_last_gen = dol_now(); - $facturerec->date_when = $facturerec->getNextDate(); + $nextDate = $facturerec->getNextDate(); + $facturerec->date_when = (($nextDate === false) ? null : $nextDate); $facturerec->update($user); $this->db->commit('createRecurringInvoices Process invoice template id=' .$facturerec->id. ', title=' .$facturerec->title); dol_syslog('createRecurringInvoices Process invoice template ' .$facturerec->title. ' is finished with a success generation'); From f0e5bb4ce1da2f407c17b38a8aa4959ebb63bc68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 25 Oct 2024 17:12:04 +0200 Subject: [PATCH 2/2] fix phpstan level 6 (#31555) --- phpstan.neon.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index fc70513563855..38cbbbd496b81 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -116,7 +116,7 @@ parameters: - '#Call to function array_key_exists.. with .error. .* will always evaluate to false.#' - '#function dolGetButtonAction expects array\{confirm\?: array.*confirm: true} given.#' - '#(?:make_substitutions expects array,) string given\.#' - - '# (DolibarrApiAccess|Documents|Login|Setup|Status|Boms|Categories|AgendaEvents|Proposals|Orders|BankAccounts|Invoices|Contracts|Donations|Shipments|KnowledgeManagement|Mos|MultiCurrencies|Partnerships|Products|Tasks|Warehouses|Tickets|Workstation|WorkstationResource|WorkstationUserGroup|Zapier)::.* has no value type specified in iterable type array\.#' + - '# (DolibarrApiAccess|Documents|Login|Setup|Status|Boms|Categories|AgendaEvents|Proposals|Orders|BankAccounts|Invoices|Contracts|Donations|Shipments|KnowledgeManagement|Mos|MultiCurrencies|Partnerships|Products|Tasks|Warehouses|Tickets|Workstation|WorkstationResource|WorkstationUserGroup|Zapier)::.* no value type specified in iterable type array\.#' internalErrorsCountLimit: 50 cache: