From 7690fd71916c7bc08944e7cf2b31185d4b033dec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 17 Jun 2024 13:17:38 +0200 Subject: [PATCH 1/3] phpstan ignore level 4 (#30047) --- htdocs/compta/bank/class/account.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 09f378255a5..d094dcc8fcb 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -74,7 +74,7 @@ class Account extends CommonObject * @deprecated * @see $type */ - private $courant; + private $courant; // @phpstan-ignore-line /** * Bank account type. Check TYPE_ constants. It's integer but Company bank account use string to identify type account @@ -278,7 +278,7 @@ class Account extends CommonObject * @deprecated * @see $balance */ - private $solde; + private $solde; // @phpstan-ignore-line /** * Balance. Used in Account::create From efdc7f92b9fdb94918c3b64516a843bbaf02e0d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 17 Jun 2024 13:22:20 +0200 Subject: [PATCH 2/3] fix phpstan empty oldcopy is not falsy (#30049) * fix phpstan empty olcopy is not falsy * fix phpstan empty olcopy is not falsy * remove code not used --------- Co-authored-by: Laurent Destailleur --- .../modules/mrp/doc/pdf_vinci.modules.php | 58 ------------------- htdocs/product/class/product.class.php | 2 +- htdocs/resource/class/dolresource.class.php | 3 +- .../class/html.formwebportal.class.php | 1 + 4 files changed, 4 insertions(+), 60 deletions(-) diff --git a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php index 4a4b0605514..50bd5549d38 100644 --- a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php +++ b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php @@ -168,9 +168,6 @@ class pdf_vinci extends ModelePDFMo $hidetop = getDolGlobalString('MAIN_PDF_DISABLE_COL_HEAD_TITLE'); } - // Loop on each lines to detect if there is at least one image to show - $realpatharray = array(); - if ($conf->mrp->dir_output) { $object->fetch_thirdparty(); @@ -340,7 +337,6 @@ class pdf_vinci extends ModelePDFMo while ($i < $pageposafternote) { $pdf->setPage($i); - $pdf->SetDrawColor(128, 128, 128); // Draw note frame if ($i > $pageposbeforenote) { @@ -421,12 +417,6 @@ class pdf_vinci extends ModelePDFMo $prod = new Product($this->db); $prod->fetch($bom->lines[$i]->fk_product); - // Define size of image if we need it - $imglinesize = array(); - if (!empty($realpatharray[$i])) { - $imglinesize = pdf_getSizeForImage($realpatharray[$i]); - } - $pdf->setTopMargin($tab_top_newpage); $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pageposbefore = $pdf->getPage(); @@ -435,33 +425,6 @@ class pdf_vinci extends ModelePDFMo $posYAfterImage = 0; $posYAfterDescription = 0; - // We start with Photo of product line - if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page - $pdf->AddPage('', '', true); - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } - if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { - $this->_pagehead($pdf, $object, 0, $outputlangs); - } - $pdf->setPage($pageposbefore + 1); - - $curY = $tab_top_newpage; - - // Allows data in the first page if description is long enough to break in multiples pages - if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) { - $showpricebeforepagebreak = 1; - } else { - $showpricebeforepagebreak = 0; - } - } - - if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) { - $curX = $this->posxpicture - 1; - $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi - // $pdf->Image does not increase value return by getY, so we save it manually - $posYAfterImage = $curY + $imglinesize['height']; - } // Description of product line $curX = $this->posxdesc - 1; $showpricebeforepagebreak = 1; @@ -595,8 +558,6 @@ class pdf_vinci extends ModelePDFMo } - - // Show square if ($pagenb == $pageposbeforeprintlines) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code); @@ -1397,25 +1358,6 @@ class pdf_vinci extends ModelePDFMo ), ); - $rank = $rank + 10; - $this->cols['photo'] = array( - 'rank' => $rank, - 'width' => getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH', 20), // in mm - 'status' => false, - 'title' => array( - 'textkey' => 'Photo', - 'label' => ' ' - ), - 'content' => array( - 'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left - ), - 'border-left' => false, // remove left line separator - ); - - if (getDolGlobalString('MAIN_GENERATE_ORDERS_WITH_PICTURE')) { - $this->cols['photo']['status'] = true; - } - $rank = $rank + 10; $this->cols['dim'] = array( 'rank' => $rank, diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index e9a89f7e337..3486a962ee6 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1178,7 +1178,7 @@ class Product extends CommonObject if ($result >= 0) { // $this->oldcopy should have been set by the caller of update (here properties were already modified) - if (empty($this->oldcopy)) { + if (is_null($this->oldcopy) || (is_object($this->oldcopy) && $this->oldcopy->isEmpty())) { $this->oldcopy = dol_clone($this, 1); } // Test if batch management is activated on existing product diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index f35dbfb5bad..328038c41f7 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2013-2015 Jean-François Ferry * Copyright (C) 2023-2024 William Mead * 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 @@ -385,7 +386,7 @@ class Dolresource extends CommonObject } // $this->oldcopy should have been set by the caller of update (here properties were already modified) - if (empty($this->oldcopy)) { + if (is_null($this->oldcopy) || (is_object($this->oldcopy) && $this->oldcopy->isEmpty())) { $this->oldcopy = dol_clone($this, 2); } diff --git a/htdocs/webportal/class/html.formwebportal.class.php b/htdocs/webportal/class/html.formwebportal.class.php index c379a0b7dfc..ab98fecb7a8 100644 --- a/htdocs/webportal/class/html.formwebportal.class.php +++ b/htdocs/webportal/class/html.formwebportal.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2023-2024 Lionel Vessiller * Copyright (C) 2023-2024 Patrice Andreani * 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 From 57c75aa350ca04836fafa4157184ea412b0d2ecd Mon Sep 17 00:00:00 2001 From: thibdrev Date: Mon, 17 Jun 2024 13:22:47 +0200 Subject: [PATCH 3/3] qual: phpdoc for htdocs/variants/class/ProductAttributeValue.class.php (#30050) * qual: phpdoc for htdocs/variants/class/ProductAttributeValue.class.php htdocs/variants/class/ProductAttributeValue.class.php 78 Plugin PhanPluginUnknownPropertyType Property \ProductAttributeValue->id has an initial type that cannot be inferred htdocs/variants/class/ProductAttributeValue.class.php 79 Plugin PhanPluginUnknownPropertyType Property \ProductAttributeValue->fk_product_attribute has an initial type that cannot be inferred htdocs/variants/class/ProductAttributeValue.class.php 80 Plugin PhanPluginUnknownPropertyType Property \ProductAttributeValue->ref has an initial type that cannot be inferred htdocs/variants/class/ProductAttributeValue.class.php 81 Plugin PhanPluginUnknownPropertyType Property \ProductAttributeValue->value has an initial type that cannot be inferred htdocs/variants/class/ProductAttributeValue.class.php 82 Plugin PhanPluginUnknownPropertyType Property \ProductAttributeValue->position has an initial type that cannot be inferred * phpcs * better wording * phpcs --- .../class/ProductAttributeValue.class.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/htdocs/variants/class/ProductAttributeValue.class.php b/htdocs/variants/class/ProductAttributeValue.class.php index e8e71f5a671..b3a2cb71b38 100644 --- a/htdocs/variants/class/ProductAttributeValue.class.php +++ b/htdocs/variants/class/ProductAttributeValue.class.php @@ -75,10 +75,35 @@ class ProductAttributeValue extends CommonObjectLine 'value' => array('type' => 'varchar(255)', 'label' => 'Value', 'enabled' => 1, 'position' => 30, 'notnull' => 1, 'visible' => 1, 'searchall' => 1, 'css' => 'minwidth300', 'help' => "", 'showoncombobox' => 1,), 'position' => array('type' => 'integer', 'label' => 'Rank', 'enabled' => 1, 'visible' => 0, 'default' => '0', 'position' => 200, 'notnull' => 1,), ); + + /** + * ID of the ProductAttributeValue + * @var int + */ public $id; + + /** + * ID of the parent attribute (ex: ID of the attribute "COLOR") + * @var int + */ public $fk_product_attribute; + + /** + * Reference of the ProductAttributeValue (ex: "BLUE_1" or "RED_3") + * @var string + */ public $ref; + + /** + * Label of the ProductAttributeValue (ex: "Dark blue" or "Chili Red") + * @var string + */ public $value; + + /** + * Sorting position of the ProductAttributeValue + * @var int + */ public $position; /**