From afb39d80913f54934d9b9509112b5fc5abf4e0ef Mon Sep 17 00:00:00 2001 From: Henning <leutz@pcsg.de> Date: Sun, 23 Feb 2025 10:29:13 +0100 Subject: [PATCH] fix(phpstan): handle non-existing classes in abstractOrder.php This commit fixes the errors arising from non-existing classes in the AbstractOrder.php Changes include: - Added a comment on the shipping validation - Corrected type declaration in the reversal function signature to include the possibility of the parameter being null. - Checked for the existence of ShippingStatus and ShippingEntry classes before attempting to get Shipping status and Shipping Ids, respectively. This prevents errors if these classes do not exist. Related: quiqqer/order#172 --- src/QUI/ERP/Order/AbstractOrder.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/QUI/ERP/Order/AbstractOrder.php b/src/QUI/ERP/Order/AbstractOrder.php index 642fa31d..e5e45d5d 100644 --- a/src/QUI/ERP/Order/AbstractOrder.php +++ b/src/QUI/ERP/Order/AbstractOrder.php @@ -439,6 +439,7 @@ protected function setDataBaseData(array $data): void // validate shipping try { + // @phpstan-ignore-next-line $this->validateShipping($this->getShipping()); } catch (QUI\Exception) { $this->shippingId = null; @@ -473,7 +474,7 @@ protected function setDataBaseData(array $data): void * @param QUI\Interfaces\Users\User|null $PermissionUser * @return ErpEntityInterface|null */ - public function reversal(string $reason = '', QUI\Interfaces\Users\User $PermissionUser = null): ?ErpEntityInterface + public function reversal(string $reason = '', null | QUI\Interfaces\Users\User $PermissionUser = null): ?ErpEntityInterface { $this->delete($PermissionUser); return null; @@ -673,13 +674,13 @@ public function toArray(): array QUI\System\Log::writeDebugException($Exception); } - if ($this->getShippingStatus()) { + if (class_exists('QUI\ERP\Shipping\ShippingStatus\Status') && $this->getShippingStatus()) { $shippingStatus = $this->getShippingStatus()->getId(); } $shipping = ''; - if ($this->getShipping()) { + if (class_exists('QUI\ERP\Shipping\Types\ShippingEntry') && $this->getShipping()) { $shipping = $this->getShipping()->getId(); } -- GitLab