From 6e866030496d1fed5f83afa23e42a8eba9ba0523 Mon Sep 17 00:00:00 2001
From: Henning <leutz@pcsg.de>
Date: Tue, 18 Feb 2025 15:01:19 +0100
Subject: [PATCH] fix(phpstan): improve code clarity and formatting

1. Simplified condition checks for 'firstname' and 'lastname' using the 'empty()' function.
2. Refactored the type hinting of parameters for the 'addUserToCustomerGroup',
'removeUserFromCustomerGroup', and 'setAttributesToCustomer' methods.
3. Updated the type hinting for the 'getEntityTypeTitle' method, adding a possibility to receive
null.

Related: quiqqer/customer#67
---
 src/QUI/ERP/Customer/Customers.php                   | 12 ++++++------
 .../ERP/Customer/OpenItemsList/OutputProvider.php    |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/QUI/ERP/Customer/Customers.php b/src/QUI/ERP/Customer/Customers.php
index 04398f7..3c7da2f 100644
--- a/src/QUI/ERP/Customer/Customers.php
+++ b/src/QUI/ERP/Customer/Customers.php
@@ -104,11 +104,11 @@ public function createCustomer($customerId, array $address = [], array $groupIds
 
             $Address->save();
 
-            if (!$User->getAttribute('firstname') || $User->getAttribute('firstname') === '') {
+            if (empty($User->getAttribute('firstname'))) {
                 $User->setAttribute('firstname', $address['firstname']);
             }
 
-            if (!$User->getAttribute('lastname') || $User->getAttribute('lastname') === '') {
+            if (empty($User->getAttribute('lastname'))) {
                 $User->setAttribute('lastname', $address['lastname']);
             }
         }
@@ -221,8 +221,8 @@ public function getCustomerGroup(): ?QUI\Groups\Group
      * @throws QUI\Users\Exception
      */
     public function addUserToCustomerGroup(
-        bool|int|string $userId,
-        QUI\Interfaces\Users\User $PermissionUser = null
+        bool | int | string $userId,
+        null | QUI\Interfaces\Users\User $PermissionUser = null
     ): void {
         if (!$userId) {
             return;
@@ -258,7 +258,7 @@ public function addUserToCustomerGroup(
      * @throws QUI\Exception
      * @throws QUI\Users\Exception
      */
-    public function removeUserFromCustomerGroup(bool|int|string $userId): void
+    public function removeUserFromCustomerGroup(bool | int | string $userId): void
     {
         $customerGroup = null;
 
@@ -287,7 +287,7 @@ public function removeUserFromCustomerGroup(bool|int|string $userId): void
      * @throws QUI\Permissions\Exception
      * @throws QUI\Users\Exception
      */
-    public function setAttributesToCustomer(bool|int|string $userId, array $attributes): void
+    public function setAttributesToCustomer(bool | int | string $userId, array $attributes): void
     {
         $User = QUI::getUsers()->get($userId);
 
diff --git a/src/QUI/ERP/Customer/OpenItemsList/OutputProvider.php b/src/QUI/ERP/Customer/OpenItemsList/OutputProvider.php
index 8a78f31..0966f0d 100644
--- a/src/QUI/ERP/Customer/OpenItemsList/OutputProvider.php
+++ b/src/QUI/ERP/Customer/OpenItemsList/OutputProvider.php
@@ -37,7 +37,7 @@ public static function getEntityType(): string
      * @param Locale|null $Locale $Locale (optional) - If ommitted use \QUI::getLocale()
      * @return string
      */
-    public static function getEntityTypeTitle(Locale $Locale = null): string
+    public static function getEntityTypeTitle(null | Locale $Locale = null): string
     {
         if (empty($Locale)) {
             $Locale = QUI::getLocale();
-- 
GitLab