diff --git a/.phive/phars.xml b/.phive/phars.xml index 5bfa092bfad10dad9d23240281a5a2041acb815b..4ff573d4258efaa06e5ed882cef81b58ca6fddb3 100644 --- a/.phive/phars.xml +++ b/.phive/phars.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <phive xmlns="https://phar.io/phive"> - <phar name="phpstan" version="1.11.8" installed="1.11.8" location="./tools/phpstan" copy="false"/> + <phar name="phpstan" version="^2.0.4" installed="2.0.4" location="./tools/phpstan" copy="false"/> <phar name="phpunit" version="^10.5.20" installed="10.5.20" location="./tools/phpunit" copy="false"/> <phar name="phpcs" version="^3.10.1" installed="3.10.1" location="./tools/phpcs" copy="false"/> <phar name="phpcbf" version="^3.10.1" installed="3.10.1" location="./tools/phpcbf" copy="false"/> diff --git a/src/QUI/ERP/Currency/Handler.php b/src/QUI/ERP/Currency/Handler.php index 719c614c5af7a30aa6ea50d3c78198d7fc9641d4..1b71cc239772bf26ab6f6dda76b6ffb121fb1274 100644 --- a/src/QUI/ERP/Currency/Handler.php +++ b/src/QUI/ERP/Currency/Handler.php @@ -57,19 +57,22 @@ public static function table(): string * Create a new currency * * @param string $currency - currency code - * @param integer|float $rate - currency exchange rate, default = 1 + * @param float|integer $rate - currency exchange rate, default = 1 * @param string $type (optional) - Currency type * @throws QUI\Exception */ - public static function createCurrency(string $currency, $rate = 1, string $type = self::CURRENCY_TYPE_DEFAULT) - { + public static function createCurrency( + string $currency, + float | int | string $rate = 1, + string $type = self::CURRENCY_TYPE_DEFAULT + ): void { QUI\Permissions\Permission::checkPermission('currency.create'); $Currency = null; try { $Currency = self::getCurrency($currency); - } catch (QUI\Exception $Exception) { + } catch (QUI\Exception) { } if (!is_null($Currency)) { @@ -94,10 +97,6 @@ public static function createCurrency(string $currency, $rate = 1, string $type ]); // create translations - $languageData = [ - 'datatype' => 'js,php' - ]; - $localeGroup = 'quiqqer/currency'; $localeText = 'currency.' . $currency . '.text'; $localeSign = 'currency.' . $currency . '.sign'; @@ -123,7 +122,7 @@ public static function createCurrency(string $currency, $rate = 1, string $type 'currency.' . $currency . '.text', 'quiqqer/currency' ); - } catch (QUI\Exception $e) { + } catch (QUI\Exception) { } if (!empty($textData)) { @@ -142,7 +141,7 @@ public static function createCurrency(string $currency, $rate = 1, string $type 'currency.' . $currency . '.sign', 'quiqqer/currency' ); - } catch (QUI\Exception $e) { + } catch (QUI\Exception) { } @@ -164,7 +163,7 @@ public static function createCurrency(string $currency, $rate = 1, string $type * @param string $currency - currency code * @throws QUI\Exception */ - public static function deleteCurrency(string $currency) + public static function deleteCurrency(string $currency): void { QUI\Permissions\Permission::checkPermission('currency.delete'); @@ -188,7 +187,7 @@ public static function deleteCurrency(string $currency) /** * Return the default currency * - * @return Currency + * @return Currency|null * @throws QUI\Exception */ public static function getDefaultCurrency(): ?Currency @@ -200,7 +199,7 @@ public static function getDefaultCurrency(): ?Currency self::$Default = self::getCurrency( $Config->getValue('currency', 'defaultCurrency') ); - } catch (QUI\Exception $Exception) { + } catch (QUI\Exception) { QUI\System\Log::addWarning('Default currency is missing'); try { @@ -321,7 +320,7 @@ public static function getAllowedCurrencies(): array foreach ($allowed as $currency) { try { $list[] = self::getCurrency($currency); - } catch (QUI\Exception $Exception) { + } catch (QUI\Exception) { } } @@ -378,7 +377,7 @@ public static function getCurrency(Currency | string | array $currency): Currenc if (is_string($currency)) { $code = $currency; - } elseif (is_array($currency) && isset($currency['code'])) { + } elseif (isset($currency['code'])) { $code = $currency['code']; } @@ -415,10 +414,10 @@ public static function existCurrency(string $currency): bool /** * Return all currency entries * - * @param Locale|boolean $Locale - optional, for translation + * @param Locale|null $Locale - optional, for translation * @return array */ - public static function getCurrencies($Locale = false): array + public static function getCurrencies(null | QUI\Locale $Locale = null): array { if (!$Locale) { $Locale = QUI::getLocale(); @@ -429,12 +428,12 @@ public static function getCurrencies($Locale = false): array try { return QUI\Cache\Manager::get($cacheNameLang); - } catch (QUI\Exception $Exception) { + } catch (QUI\Exception) { } try { $currencies = QUI\Cache\Manager::get($cacheName); - } catch (QUI\Exception $Exception) { + } catch (QUI\Exception) { $currencies = []; $data = self::getData(); @@ -448,7 +447,7 @@ public static function getCurrencies($Locale = false): array foreach ($currencies as $currency) { try { $Currency = self::getCurrency($currency); - } catch (QUI\Exception $Exception) { + } catch (QUI\Exception) { continue; } @@ -465,7 +464,7 @@ public static function getCurrencies($Locale = false): array * @throws QUI\Database\Exception * @throws QUI\Exception */ - public static function updateCurrency($currency, $data) + public static function updateCurrency($currency, $data): void { QUI\Permissions\Permission::checkPermission('currency.edit');