From 8ebf0d6c6a3c9a81e5139f2d5bd9e2ef2f0f2500 Mon Sep 17 00:00:00 2001 From: Henning Leutz <leutz@pcsg.de> Date: Wed, 1 May 2024 09:39:41 +0200 Subject: [PATCH] fix: phpstan errors Class QUI\DataBase\Exception not found, variable $whereOr in empty() always exists and is not falsy --- src/QUI/ERP/Coupons/CouponCode.php | 5 ++--- src/QUI/ERP/Coupons/Handler.php | 12 +++++------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/QUI/ERP/Coupons/CouponCode.php b/src/QUI/ERP/Coupons/CouponCode.php index b6ef5d5..87a3644 100644 --- a/src/QUI/ERP/Coupons/CouponCode.php +++ b/src/QUI/ERP/Coupons/CouponCode.php @@ -7,7 +7,6 @@ use QUI; use QUI\ERP\Discount\Handler as DiscountHandler; use QUI\ERP\Order\AbstractOrder; -use QUI\ERP\Order\Order; use QUI\ERP\Order\OrderInterface; use QUI\ExceptionStack; use QUI\Interfaces\Users\User; @@ -123,7 +122,7 @@ public function __construct(int $id) 'id' => $id ] ]); - } catch (QUI\DataBase\Exception $Exception) { + } catch (QUI\Database\Exception $Exception) { QUI\System\Log::addError($Exception->getMessage()); throw new CouponCodeException([ @@ -591,7 +590,7 @@ public function delete(): void Handler::getTable(), ['id' => $this->id] ); - } catch (QUI\DataBase\Exception $Exception) { + } catch (QUI\Database\Exception $Exception) { QUI\System\Log::addError($Exception->getMessage()); } diff --git a/src/QUI/ERP/Coupons/Handler.php b/src/QUI/ERP/Coupons/Handler.php index dbd16d3..ae0a2b0 100644 --- a/src/QUI/ERP/Coupons/Handler.php +++ b/src/QUI/ERP/Coupons/Handler.php @@ -340,14 +340,12 @@ public static function search(array $searchParams, bool $countOnly = false): arr $whereOr[] = '`' . $searchColumn . '` LIKE :search'; } - if (!empty($whereOr)) { - $where[] = '(' . implode(' OR ', $whereOr) . ')'; + $where[] = '(' . implode(' OR ', $whereOr) . ')'; - $binds['search'] = [ - 'value' => '%' . $searchParams['search'] . '%', - 'type' => PDO::PARAM_STR - ]; - } + $binds['search'] = [ + 'value' => '%' . $searchParams['search'] . '%', + 'type' => PDO::PARAM_STR + ]; } // build WHERE query string -- GitLab