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

fix(phpstan): update phive and refactor ERP Currency Handler

- Updated the version of phive to ^2.0.4 in the phars.xml file
- Refactored the ERP Currency Handler in the following ways:
  - Rearranged the argument order and types in createCurrency function
  - Removed unused languageData in createCurrency function
  - Updated createCurrency, deleteCurrency, updateCurrency to return void
  - Updated getDefaultCurrency to return Currency|null
  - Fixed getCurrency to handle `isset($currency['code'])`
  - Updated getCurrencies to handle `null | QUI\\Locale`
  - Standardized exception catch statements to `QUI\\Exception` without variable
  - Minor cleanups and formatting for increased readability
Übergeordneter c23a81e7
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
2 Merge Requests!54Update 'next-3.x' with latest changes from 'main',!53feat(Currency.js): get default currency
Pipeline-Nr. 16541 bestanden
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive"> <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="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="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"/> <phar name="phpcbf" version="^3.10.1" installed="3.10.1" location="./tools/phpcbf" copy="false"/>
......
...@@ -57,19 +57,22 @@ public static function table(): string ...@@ -57,19 +57,22 @@ public static function table(): string
* Create a new currency * Create a new currency
* *
* @param string $currency - currency code * @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 * @param string $type (optional) - Currency type
* @throws QUI\Exception * @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'); QUI\Permissions\Permission::checkPermission('currency.create');
$Currency = null; $Currency = null;
try { try {
$Currency = self::getCurrency($currency); $Currency = self::getCurrency($currency);
} catch (QUI\Exception $Exception) { } catch (QUI\Exception) {
} }
if (!is_null($Currency)) { if (!is_null($Currency)) {
...@@ -94,10 +97,6 @@ public static function createCurrency(string $currency, $rate = 1, string $type ...@@ -94,10 +97,6 @@ public static function createCurrency(string $currency, $rate = 1, string $type
]); ]);
// create translations // create translations
$languageData = [
'datatype' => 'js,php'
];
$localeGroup = 'quiqqer/currency'; $localeGroup = 'quiqqer/currency';
$localeText = 'currency.' . $currency . '.text'; $localeText = 'currency.' . $currency . '.text';
$localeSign = 'currency.' . $currency . '.sign'; $localeSign = 'currency.' . $currency . '.sign';
...@@ -123,7 +122,7 @@ public static function createCurrency(string $currency, $rate = 1, string $type ...@@ -123,7 +122,7 @@ public static function createCurrency(string $currency, $rate = 1, string $type
'currency.' . $currency . '.text', 'currency.' . $currency . '.text',
'quiqqer/currency' 'quiqqer/currency'
); );
} catch (QUI\Exception $e) { } catch (QUI\Exception) {
} }
if (!empty($textData)) { if (!empty($textData)) {
...@@ -142,7 +141,7 @@ public static function createCurrency(string $currency, $rate = 1, string $type ...@@ -142,7 +141,7 @@ public static function createCurrency(string $currency, $rate = 1, string $type
'currency.' . $currency . '.sign', 'currency.' . $currency . '.sign',
'quiqqer/currency' 'quiqqer/currency'
); );
} catch (QUI\Exception $e) { } catch (QUI\Exception) {
} }
...@@ -164,7 +163,7 @@ public static function createCurrency(string $currency, $rate = 1, string $type ...@@ -164,7 +163,7 @@ public static function createCurrency(string $currency, $rate = 1, string $type
* @param string $currency - currency code * @param string $currency - currency code
* @throws QUI\Exception * @throws QUI\Exception
*/ */
public static function deleteCurrency(string $currency) public static function deleteCurrency(string $currency): void
{ {
QUI\Permissions\Permission::checkPermission('currency.delete'); QUI\Permissions\Permission::checkPermission('currency.delete');
...@@ -188,7 +187,7 @@ public static function deleteCurrency(string $currency) ...@@ -188,7 +187,7 @@ public static function deleteCurrency(string $currency)
/** /**
* Return the default currency * Return the default currency
* *
* @return Currency * @return Currency|null
* @throws QUI\Exception * @throws QUI\Exception
*/ */
public static function getDefaultCurrency(): ?Currency public static function getDefaultCurrency(): ?Currency
...@@ -200,7 +199,7 @@ public static function getDefaultCurrency(): ?Currency ...@@ -200,7 +199,7 @@ public static function getDefaultCurrency(): ?Currency
self::$Default = self::getCurrency( self::$Default = self::getCurrency(
$Config->getValue('currency', 'defaultCurrency') $Config->getValue('currency', 'defaultCurrency')
); );
} catch (QUI\Exception $Exception) { } catch (QUI\Exception) {
QUI\System\Log::addWarning('Default currency is missing'); QUI\System\Log::addWarning('Default currency is missing');
try { try {
...@@ -321,7 +320,7 @@ public static function getAllowedCurrencies(): array ...@@ -321,7 +320,7 @@ public static function getAllowedCurrencies(): array
foreach ($allowed as $currency) { foreach ($allowed as $currency) {
try { try {
$list[] = self::getCurrency($currency); $list[] = self::getCurrency($currency);
} catch (QUI\Exception $Exception) { } catch (QUI\Exception) {
} }
} }
...@@ -378,7 +377,7 @@ public static function getCurrency(Currency | string | array $currency): Currenc ...@@ -378,7 +377,7 @@ public static function getCurrency(Currency | string | array $currency): Currenc
if (is_string($currency)) { if (is_string($currency)) {
$code = $currency; $code = $currency;
} elseif (is_array($currency) && isset($currency['code'])) { } elseif (isset($currency['code'])) {
$code = $currency['code']; $code = $currency['code'];
} }
...@@ -415,10 +414,10 @@ public static function existCurrency(string $currency): bool ...@@ -415,10 +414,10 @@ public static function existCurrency(string $currency): bool
/** /**
* Return all currency entries * Return all currency entries
* *
* @param Locale|boolean $Locale - optional, for translation * @param Locale|null $Locale - optional, for translation
* @return array * @return array
*/ */
public static function getCurrencies($Locale = false): array public static function getCurrencies(null | QUI\Locale $Locale = null): array
{ {
if (!$Locale) { if (!$Locale) {
$Locale = QUI::getLocale(); $Locale = QUI::getLocale();
...@@ -429,12 +428,12 @@ public static function getCurrencies($Locale = false): array ...@@ -429,12 +428,12 @@ public static function getCurrencies($Locale = false): array
try { try {
return QUI\Cache\Manager::get($cacheNameLang); return QUI\Cache\Manager::get($cacheNameLang);
} catch (QUI\Exception $Exception) { } catch (QUI\Exception) {
} }
try { try {
$currencies = QUI\Cache\Manager::get($cacheName); $currencies = QUI\Cache\Manager::get($cacheName);
} catch (QUI\Exception $Exception) { } catch (QUI\Exception) {
$currencies = []; $currencies = [];
$data = self::getData(); $data = self::getData();
...@@ -448,7 +447,7 @@ public static function getCurrencies($Locale = false): array ...@@ -448,7 +447,7 @@ public static function getCurrencies($Locale = false): array
foreach ($currencies as $currency) { foreach ($currencies as $currency) {
try { try {
$Currency = self::getCurrency($currency); $Currency = self::getCurrency($currency);
} catch (QUI\Exception $Exception) { } catch (QUI\Exception) {
continue; continue;
} }
...@@ -465,7 +464,7 @@ public static function getCurrencies($Locale = false): array ...@@ -465,7 +464,7 @@ public static function getCurrencies($Locale = false): array
* @throws QUI\Database\Exception * @throws QUI\Database\Exception
* @throws QUI\Exception * @throws QUI\Exception
*/ */
public static function updateCurrency($currency, $data) public static function updateCurrency($currency, $data): void
{ {
QUI\Permissions\Permission::checkPermission('currency.edit'); QUI\Permissions\Permission::checkPermission('currency.edit');
......
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren