From eefbf9a0789a81ee742e539bb2b38c2e0b5098f0 Mon Sep 17 00:00:00 2001 From: Henning <leutz@pcsg.de> Date: Wed, 26 Feb 2025 09:51:01 +0100 Subject: [PATCH] fix: allow null user type in setuser methods and improve type hinting This commit includes changes made to both the Article.php and ArticleList.php classes in the QUI\ERP\Accounting directory. The setUser methods now accept a null type for the 'User' parameter, giving more flexibility when calculating user details. Type hinting was also improved in the ArticleList class. The variable type indicators were changed from 'int|float' to 'int | float', and from 'Factor|QUI\\ERP\\Products\\Utils\\PriceFactor' to 'Factor | QUI\\ERP\\Products\\Utils\\PriceFactor', improving readability and clarity of code. Lastly, the 'template' and 'articleTemplate' parameters in the 'toHTMLWithCSS' method now support both 'bool' and 'string' types, adding flexibility to template usage. --- src/QUI/ERP/Accounting/Article.php | 4 ++-- src/QUI/ERP/Accounting/ArticleList.php | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/QUI/ERP/Accounting/Article.php b/src/QUI/ERP/Accounting/Article.php index 6410d40..c1375e9 100644 --- a/src/QUI/ERP/Accounting/Article.php +++ b/src/QUI/ERP/Accounting/Article.php @@ -499,9 +499,9 @@ public function getUser(): ?QUI\Interfaces\Users\User /** * Set the user to the product, this user will be used for the calculation * - * @param QUI\Interfaces\Users\User $User + * @param null|QUI\Interfaces\Users\User $User */ - public function setUser(QUI\Interfaces\Users\User $User): void + public function setUser(null | QUI\Interfaces\Users\User $User): void { $this->calculated = false; $this->User = $User; diff --git a/src/QUI/ERP/Accounting/ArticleList.php b/src/QUI/ERP/Accounting/ArticleList.php index e4e78a1..61608d6 100644 --- a/src/QUI/ERP/Accounting/ArticleList.php +++ b/src/QUI/ERP/Accounting/ArticleList.php @@ -34,17 +34,17 @@ class ArticleList extends ArticleListUnique implements IteratorAggregate /** * @var int|float */ - protected int|float $sum; + protected int | float $sum; /** * @var int|float */ - protected int|float $grandSubSum; + protected int | float $grandSubSum; /** * @var ?QUI\Interfaces\Users\User */ - protected QUI\Interfaces\Users\User|null $User = null; + protected QUI\Interfaces\Users\User | null $User = null; /** * @var ?QUI\ERP\Order\AbstractOrder @@ -59,17 +59,17 @@ class ArticleList extends ArticleListUnique implements IteratorAggregate /** * @var int|float */ - protected int|float $subSum; + protected int | float $subSum; /** * @var int|float */ - protected int|float $nettoSum; + protected int | float $nettoSum; /** * @var int|float */ - protected int|float $nettoSubSum; + protected int | float $nettoSubSum; /** * key 19% value[sum] = sum value[text] = text value[display_sum] formatted @@ -140,9 +140,9 @@ public function __construct(array $attributes = []) * Set the user for the list * User for calculation * - * @param QUI\Interfaces\Users\User $User + * @param null|QUI\Interfaces\Users\User $User */ - public function setUser(QUI\Interfaces\Users\User $User): void + public function setUser(null | QUI\Interfaces\Users\User $User): void { if ($this->User === $User) { return; @@ -486,7 +486,7 @@ public function importPriceFactors(QUI\ERP\Accounting\PriceFactors\FactorList $P * * @throws Exception */ - public function addPriceFactor(Factor|QUI\ERP\Products\Utils\PriceFactor $PriceFactor): void + public function addPriceFactor(Factor | QUI\ERP\Products\Utils\PriceFactor $PriceFactor): void { if ($PriceFactor instanceof QUI\ERP\Products\Utils\PriceFactor) { $isNetto = $this->isNetto; @@ -550,8 +550,8 @@ public function renderForMail(): string } public function toHTMLWithCSS( - bool|string $template = false, - bool|string $articleTemplate = false, + bool | string $template = false, + bool | string $articleTemplate = false, ?QUI\Interfaces\Template\EngineInterface $Engine = null, ): string { return $this->toUniqueList()->toHTMLWithCSS($template, $articleTemplate, $Engine); -- GitLab