Skip to content
Code-Schnipsel Gruppen Projekte
Commit ca954d77 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

refactor: update union types with null

Improve readability and interpretability of code by explicitly stating null in union types. This
change has been applied across multiple files and functions.

PHP8.4 compatibility
Übergeordneter 30906ba4
No related branches found
No related tags found
2 Merge Requests!139Update 'next-3.x' with latest changes from 'main',!138fix(Basket): improve basket id handling and user check in Basket.php
Pipeline #14604 bestanden mit Phase
in 2 Minuten und 26 Sekunden
werden angezeigt mit 64 Ergänzungen und 60 Löschungen
......@@ -31,7 +31,7 @@ class Basket
*
* @var integer|bool
*/
protected int|bool $id = false;
protected int | bool $id = false;
/**
* List of products
......@@ -62,7 +62,7 @@ class Basket
* @param ?QUI\Interfaces\Users\User $User
* @throws ExceptionStack
*/
public function __construct(bool|int $basketId, QUI\Interfaces\Users\User $User = null)
public function __construct(bool | int $basketId, null | QUI\Interfaces\Users\User $User = null)
{
if (!$User) {
$User = QUI::getUserBySession();
......@@ -110,7 +110,7 @@ public function __construct(bool|int $basketId, QUI\Interfaces\Users\User $User
*
* @return bool|int
*/
public function getId(): bool|int
public function getId(): bool | int
{
return $this->id;
}
......@@ -174,13 +174,13 @@ public function addProduct(Product $Product): void
//endregion
/**
/**
* Import the products to the basket
*
* @param array|null $products
* @throws ExceptionStack
*/
public function import(array|null $products = []): void
public function import(array | null $products = []): void
{
$this->clear();
......
......@@ -50,7 +50,7 @@ class BasketOrder
/**
* @var int|null
*/
protected int|null $id = null;
protected int | null $id = null;
/**
* @var QUI\ERP\Comments|null
......@@ -66,7 +66,7 @@ class BasketOrder
* @throws Exception
* @throws QUI\Exception
*/
public function __construct(string $orderHash, QUI\Interfaces\Users\User $User = null)
public function __construct(string $orderHash, null | QUI\Interfaces\Users\User $User = null)
{
if (!$User) {
$User = QUI::getUserBySession();
......
......@@ -20,7 +20,7 @@ abstract class AbstractOrderingStep extends QUI\Control implements OrderingStepI
* @param Locale|null $Locale
* @return string
*/
public function getTitle(QUI\Locale $Locale = null): string
public function getTitle(null | QUI\Locale $Locale = null): string
{
if ($Locale === null) {
$Locale = QUI::getLocale();
......
......@@ -27,7 +27,7 @@ class Basket extends QUI\ERP\Order\Controls\AbstractOrderingStep
/**
* @var BasketClass|BasketOrder|BasketGuest
*/
protected BasketClass|BasketOrder|BasketGuest $Basket;
protected BasketClass | BasketOrder | BasketGuest $Basket;
/**
* Basket constructor.
......@@ -71,7 +71,7 @@ public function __construct(array $attributes = [])
* @param null|QUI\Locale $Locale
* @return string
*/
public function getName(QUI\Locale $Locale = null): string
public function getName(null | QUI\Locale $Locale = null): string
{
return 'Basket';
}
......@@ -87,7 +87,7 @@ public function getIcon(): string
/**
* @return BasketGuest|BasketClass|BasketOrder
*/
public function getBasket(): BasketGuest|BasketClass|BasketOrder
public function getBasket(): BasketGuest | BasketClass | BasketOrder
{
return $this->Basket;
}
......
......@@ -183,7 +183,7 @@ public function getBody(): string
* @param null|QUI\Locale $Locale
* @return string
*/
public function getName(QUI\Locale $Locale = null): string
public function getName(null | QUI\Locale $Locale = null): string
{
return 'Customer';
}
......@@ -466,7 +466,7 @@ public function save(): void
* @throws Exception
* @throws QUI\Permissions\Exception
*/
protected function getAddressById(int|string $addressId): bool|QUI\Users\Address|null
protected function getAddressById(int | string $addressId): bool | QUI\Users\Address | null
{
$User = QUI::getUserBySession();
$Address = null;
......@@ -499,7 +499,7 @@ protected function getAddressById(int|string $addressId): bool|QUI\Users\Address
/**
* @return null|QUI\Users\Address
*/
protected function getInvoiceAddress(): Address|null
protected function getInvoiceAddress(): Address | null
{
$Order = $this->getOrder();
$Customer = $Order->getCustomer();
......
......@@ -40,7 +40,7 @@ public function getBody(): string
* @param null|Locale $Locale
* @return string
*/
public function getName(Locale $Locale = null): string
public function getName(null | Locale $Locale = null): string
{
return 'Delivery';
}
......
......@@ -138,7 +138,7 @@ public function setProcessingProvider(QUI\ERP\Order\AbstractOrderProcessProvider
* @param null|QUI\Locale $Locale
* @return string
*/
public function getName($Locale = null): string
public function getName(null | QUI\Locale $Locale = null): string
{
return 'Processing';
}
......@@ -203,7 +203,7 @@ public function savePayment($payment): void
* @param Locale|null $Locale
* @return string
*/
public function getTitle(QUI\Locale $Locale = null): string
public function getTitle(null | QUI\Locale $Locale = null): string
{
if (!empty($this->title)) {
return $this->title;
......@@ -254,7 +254,7 @@ public function setContent(string $content): void
* @param Locale|null $Locale
* @return string|null
*/
public function getContent(QUI\Locale $Locale = null): ?string
public function getContent(null | QUI\Locale $Locale = null): ?string
{
if ($Locale === null) {
$Locale = QUI::getLocale();
......
......@@ -17,13 +17,13 @@ interface OrderingStepInterface
* @param null|Locale $Locale
* @return string
*/
public function getName(Locale $Locale = null): string;
public function getName(null | Locale $Locale = null): string;
/**
* @param null|Locale $Locale $Locale
* @return mixed
*/
public function getTitle(Locale $Locale = null): mixed;
public function getTitle(null | Locale $Locale = null): mixed;
/**
* @throws Exception
......
......@@ -36,8 +36,8 @@ class Factory extends QUI\Utils\Singleton
* @throws QUI\ERP\Order\Exception
*/
public function create(
QUI\Interfaces\Users\User $PermissionUser = null,
bool|string $hash = false,
null | QUI\Interfaces\Users\User $PermissionUser = null,
bool | string $hash = false,
?int $id = null,
string $globalProcessId = ''
): Order {
......@@ -162,7 +162,7 @@ public function createOrderProcess($PermissionUser = null): OrderInProcess
* @throws QUI\Exception
* @throws QUI\ERP\Order\Exception
*/
public function createOrderInProcess(QUI\Interfaces\Users\User $PermissionUser = null): OrderInProcess
public function createOrderInProcess(null | QUI\Interfaces\Users\User $PermissionUser = null): OrderInProcess
{
if ($PermissionUser === null) {
$PermissionUser = QUI::getUserBySession();
......@@ -185,7 +185,7 @@ public function createOrderInProcess(QUI\Interfaces\Users\User $PermissionUser =
* @return int - OrderInProcess ID
* @throws QUI\Database\Exception
*/
public function createOrderInProcessDataBaseEntry(QUI\Interfaces\Users\User $PermissionUser = null): int
public function createOrderInProcessDataBaseEntry(null | QUI\Interfaces\Users\User $PermissionUser = null): int
{
if ($PermissionUser === null) {
$PermissionUser = QUI::getUserBySession();
......
......@@ -119,7 +119,7 @@ public function table(): string
* @throws QUI\ERP\Order\Exception
* @throws QUI\Exception
*/
public function get(int|string $orderId): Order
public function get(int | string $orderId): Order
{
return new Order($orderId);
}
......@@ -135,7 +135,7 @@ public function get(int|string $orderId): Order
* @throws QUI\Exception
* @throws Exception
*/
public function getOrderByHash(string $hash): OrderInProcess|Order
public function getOrderByHash(string $hash): OrderInProcess | Order
{
$result = QUI::getDataBase()->fetch([
'select' => 'id',
......@@ -182,7 +182,7 @@ public function getOrderByHash(string $hash): OrderInProcess|Order
* @throws QUI\Exception
* @throws Exception
*/
public function getOrderByGlobalProcessId(int|string $id): Order
public function getOrderByGlobalProcessId(int | string $id): Order
{
$result = QUI::getDataBase()->fetch([
'select' => 'id',
......@@ -251,7 +251,7 @@ public function getOrdersByGlobalProcessId(string $id): array
* @throws QUI\Exception
* @throws Exception
*/
public function getOrderById(int|string $id): OrderInProcess|Order
public function getOrderById(int | string $id): OrderInProcess | Order
{
$result = QUI::getDataBase()->fetch([
'select' => 'id',
......@@ -308,7 +308,7 @@ public function getOrderById(int|string $id): OrderInProcess|Order
*
* @throws QUI\Database\Exception|QUI\ERP\Order\Exception
*/
public function getOrderData(int|string $orderId): array
public function getOrderData(int | string $orderId): array
{
$result = QUI::getDataBase()->fetch([
'from' => $this->table(),
......@@ -731,7 +731,7 @@ public function getLastOrderInProcessFromUser(QUI\Interfaces\Users\User $User):
* @throws QUI\ERP\Order\Exception
* @throws QUI\Database\Exception
*/
public function getOrderProcessData(int|string $orderId): array
public function getOrderProcessData(int | string $orderId): array
{
$result = QUI::getDataBase()->fetch([
'from' => $this->tableOrderProcess(),
......@@ -781,7 +781,7 @@ public function tableBasket(): string
* @throws QUI\Database\Exception
* @throws QUI\Exception
*/
public function getBasket(int|string $str, $User = null): Basket
public function getBasket(int | string $str, $User = null): Basket
{
if (is_numeric($str)) {
return self::getBasketById($str, $User);
......@@ -800,7 +800,7 @@ public function getBasket(int|string $str, $User = null): Basket
* @throws QUI\Database\Exception
* @throws QUI\Exception
*/
public function getBasketById(int|string $basketId, $User = null): Basket
public function getBasketById(int | string $basketId, $User = null): Basket
{
$data = QUI::getDataBase()->fetch([
'from' => QUI\ERP\Order\Handler::getInstance()->tableBasket(),
......@@ -916,7 +916,7 @@ public function getBasketFromUser(QUI\Interfaces\Users\User $User): Basket
* @throws QUI\Database\Exception
* @throws QUI\Exception
*/
public function getBasketData(int|string $basketId, QUI\Interfaces\Users\User $User = null): array
public function getBasketData(int | string $basketId, null | QUI\Interfaces\Users\User $User = null): array
{
if ($User === null) {
$User = QUI::getUserBySession();
......
......@@ -24,7 +24,7 @@ class Order implements NumberRangeInterface
*
* @return string
*/
public function getTitle(QUI\Locale $Locale = null): string
public function getTitle(null | QUI\Locale $Locale = null): string
{
if ($Locale === null) {
$Locale = QUI::getLocale();
......
......@@ -403,7 +403,7 @@ protected function cleanup(): void
*
* @throws QUI\Exception|\Exception
*/
protected function executePayableStatus(): bool|string
protected function executePayableStatus(): bool | string
{
$template = dirname(__FILE__) . '/Controls/OrderProcess.html';
$Engine = QUI::getTemplateManager()->getEngine();
......@@ -720,7 +720,7 @@ class_exists('QUI\ERP\Order\Guest\GuestOrder')
* @throws Exception
* @throws QUI\Exception
*/
protected function checkProcessing(): bool|string
protected function checkProcessing(): bool | string
{
$Current = $this->getCurrentStep();
$Order = $this->getOrder();
......@@ -922,7 +922,7 @@ protected function renderFinish(): mixed
* @throws Exception
* @throws Exception
*/
public function getCurrentStep(): Controls\OrderProcess\Processing|AbstractOrderingStep
public function getCurrentStep(): Controls\OrderProcess\Processing | AbstractOrderingStep
{
$steps = $this->getSteps();
$current = $this->getCurrentStepName();
......@@ -976,8 +976,9 @@ public function getLastStep(): mixed
*
* @throws Exception
*/
public function getNextStep(AbstractOrderingStep $StartStep = null): FinishControl|bool|AbstractOrderingStep
{
public function getNextStep(
null | AbstractOrderingStep $StartStep = null
): FinishControl | bool | AbstractOrderingStep {
if ($StartStep === null) {
$step = $this->getCurrentStepName();
} else {
......@@ -1038,7 +1039,7 @@ public function getNextStep(AbstractOrderingStep $StartStep = null): FinishContr
* @throws Exception
* @throws QUI\Exception
*/
public function getPreviousStep(AbstractOrderingStep $StartStep = null): ?AbstractOrderingStep
public function getPreviousStep(null | AbstractOrderingStep $StartStep = null): ?AbstractOrderingStep
{
if ($StartStep === null) {
$step = $this->getCurrentStepName();
......@@ -1102,7 +1103,7 @@ public function getPreviousStep(AbstractOrderingStep $StartStep = null): ?Abstra
* @throws Exception
* @throws QUI\Exception
*/
protected function getStepByName(string $name): bool|AbstractOrderingStep
protected function getStepByName(string $name): bool | AbstractOrderingStep
{
$steps = $this->getSteps();
......@@ -1148,7 +1149,7 @@ protected function getCurrentStepName(): string
* @throws Exception
* @throws QUI\Exception
*/
protected function getNextStepName(AbstractOrderingStep $StartStep = null): bool|string
protected function getNextStepName(null | AbstractOrderingStep $StartStep = null): bool | string
{
$Next = $this->getNextStep($StartStep);
......@@ -1168,7 +1169,7 @@ protected function getNextStepName(AbstractOrderingStep $StartStep = null): bool
* @throws Exception
* @throws QUI\Exception
*/
protected function getPreviousStepName(AbstractOrderingStep $StartStep = null): bool|string
protected function getPreviousStepName(null | AbstractOrderingStep $StartStep = null): bool | string
{
$Prev = $this->getPreviousStep($StartStep);
......@@ -1340,7 +1341,7 @@ public function getOrder(): ?AbstractOrder
/**
* @return Basket\Basket|Basket\BasketGuest|QUI\ERP\Order\Basket\BasketOrder
*/
protected function getBasket(): Basket\BasketGuest|Basket\Basket|Basket\BasketOrder
protected function getBasket(): Basket\BasketGuest | Basket\Basket | Basket\BasketOrder
{
if ($this->getAttribute('basketId')) {
try {
......
......@@ -24,7 +24,7 @@ class PaymentReceiver implements PaymentReceiverInterface
/**
* @var ?AbstractOrder
*/
protected AbstractOrder|null $Order = null;
protected AbstractOrder | null $Order = null;
/**
* Get entity type descriptor
......@@ -42,7 +42,7 @@ public static function getType(): string
* @param Locale|null $Locale $Locale (optional) - If omitted use \QUI::getLocale()
* @return string
*/
public static function getTypeTitle(Locale $Locale = null): string
public static function getTypeTitle(null | Locale $Locale = null): string
{
if (empty($Locale)) {
$Locale = QUI::getLocale();
......@@ -92,7 +92,7 @@ public function __construct($id)
*
* @return Address|false
*/
public function getDebtorAddress(): bool|Address
public function getDebtorAddress(): bool | Address
{
return $this->Order->getCustomer()->getStandardAddress();
}
......@@ -142,7 +142,7 @@ public function getDate(): DateTime
*
* @return DateTime|false
*/
public function getDueDate(): DateTime|bool
public function getDueDate(): DateTime | bool
{
$date = $this->Order->getAttribute('payment_time');
......@@ -200,7 +200,7 @@ public function getAmountPaid(): float
*
* @return PaymentInterface|false
*/
public function getPaymentMethod(): bool|PaymentInterface
public function getPaymentMethod(): bool | PaymentInterface
{
try {
return QUI\ERP\Accounting\Payments\Payments::getInstance()->getPayment(
......
......@@ -100,7 +100,7 @@ public function getProcessingStatusList(): array
*
* @throws Exception
*/
public function getProcessingStatus($id): StatusUnknown|Status
public function getProcessingStatus($id): StatusUnknown | Status
{
if ($id === 0) {
return new StatusUnknown();
......@@ -115,7 +115,7 @@ public function getProcessingStatus($id): StatusUnknown|Status
* @return Status|StatusUnknown
* @throws Exception
*/
public function getCancelledStatus(): Status|StatusUnknown
public function getCancelledStatus(): Status | StatusUnknown
{
$cancelledStatusId = $this->OrderConfig->get('orderStatus', 'cancelled');
......@@ -136,7 +136,7 @@ public function getCancelledStatus(): Status|StatusUnknown
*
* @todo permissions
*/
public function deleteProcessingStatus(int|string $id): void
public function deleteProcessingStatus(int | string $id): void
{
$Status = $this->getProcessingStatus($id);
......@@ -183,7 +183,7 @@ public function setProcessingStatusNotification(int $id, bool $notify): void
*
* @todo permissions
*/
public function updateProcessingStatus(int|string $id, int|string $color, array $title): void
public function updateProcessingStatus(int | string $id, int | string $color, array $title): void
{
$Status = $this->getProcessingStatus($id);
......@@ -271,8 +271,11 @@ public function createNotificationTranslations(int $id): void
*
* @throws QUI\Exception
*/
public function sendStatusChangeNotification(AbstractOrder $Order, int $statusId, string $message = null): void
{
public function sendStatusChangeNotification(
AbstractOrder $Order,
int $statusId,
null | string $message = null
): void {
$Customer = $Order->getCustomer();
$customerEmail = $Customer->getAttribute('email');
......
......@@ -39,7 +39,7 @@ class Status
* @param int|string $id - Processing status id
* @throws Exception
*/
public function __construct(int|string $id)
public function __construct(int | string $id)
{
$list = Handler::getInstance()->getList();
......@@ -85,7 +85,7 @@ public function getId(): int
* @param null|QUI\Locale $Locale (optional) $Locale
* @return string
*/
public function getTitle(QUI\Locale $Locale = null): string
public function getTitle(null | QUI\Locale $Locale = null): string
{
if (!($Locale instanceof QUI\Locale)) {
$Locale = QUI::getLocale();
......@@ -101,7 +101,7 @@ public function getTitle(QUI\Locale $Locale = null): string
* @param QUI\Locale|null $Locale (optional) - [default: QUI::getLocale()]
* @return string
*/
public function getStatusChangeNotificationText(AbstractOrder $Order, QUI\Locale $Locale = null): string
public function getStatusChangeNotificationText(AbstractOrder $Order, null | QUI\Locale $Locale = null): string
{
if (!($Locale instanceof QUI\Locale)) {
$Locale = QUI::getLocale();
......@@ -155,7 +155,7 @@ public function isAutoNotification(): bool
* @param null|QUI\Locale $Locale - optional. if no locale, all translations would be returned
* @return array
*/
public function toArray(QUI\Locale $Locale = null): array
public function toArray(null | QUI\Locale $Locale = null): array
{
$title = $this->getTitle($Locale);
$statusChangeText = [];
......
......@@ -43,7 +43,7 @@ public function __construct()
* @param null|QUI\Locale $Locale (optional) $Locale
* @return string
*/
public function getTitle(QUI\Locale $Locale = null): string
public function getTitle(null | QUI\Locale $Locale = null): string
{
if (!($Locale instanceof QUI\Locale)) {
$Locale = QUI::getLocale();
......
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren