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

fix(phpstan): update function parameter data types

This commit changes the data type of the function parameters across various files. The
modifications are made in the 'phpstan-baseline.neon', 'AbstractCurrency.php',
'CurrencyInterface.php', and 'Handler.php' files. Certain function parameters which could have been
null are now specifically marked as available for null input. Improving the type hinting of these
functions enhances code readability, allows for better static analysis and reduces the scope for
bugs in the future.

Related: #9
Übergeordneter c4217d54
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
2 Merge Requests!52Update 'next-3.x' with latest changes from 'main',!51fix(phpstan): update function parameter data types
parameters: parameters:
ignoreErrors: ignoreErrors:
- \ No newline at end of file
message: "#^Call to method getDisplayPrice\\(\\) on an unknown class QUI\\\\ERP\\\\Money\\\\Price\\.$#"
count: 1
path: ajax/convertWithSign.php
-
message: "#^Instantiated class QUI\\\\ERP\\\\Money\\\\Price not found\\.$#"
count: 1
path: ajax/convertWithSign.php
-
message: "#^Parameter \\#1 \\$User of static method QUI\\\\ERP\\\\Currency\\\\Handler\\:\\:getUserCurrencyByCountry\\(\\) expects null, QUI\\\\Interfaces\\\\Users\\\\User given\\.$#"
count: 2
path: src/QUI/ERP/Currency/Handler.php
...@@ -182,7 +182,7 @@ public function toArray(): array ...@@ -182,7 +182,7 @@ public function toArray(): array
* @param null|QUI\Locale $Locale -optional * @param null|QUI\Locale $Locale -optional
* @return float * @return float
*/ */
public function amount($amount, QUI\Locale $Locale = null): float public function amount($amount, null |QUI\Locale $Locale = null): float
{ {
if (is_float($amount) || is_int($amount)) { if (is_float($amount) || is_int($amount)) {
return $amount; return $amount;
...@@ -215,7 +215,7 @@ public function amount($amount, QUI\Locale $Locale = null): float ...@@ -215,7 +215,7 @@ public function amount($amount, QUI\Locale $Locale = null): float
* @param null|QUI\Locale $Locale - optional, locale object * @param null|QUI\Locale $Locale - optional, locale object
* @return string * @return string
*/ */
public function format($amount, QUI\Locale $Locale = null): string public function format($amount, null|QUI\Locale $Locale = null): string
{ {
if (!$Locale) { if (!$Locale) {
$Locale = $this->Locale; $Locale = $this->Locale;
......
...@@ -17,7 +17,7 @@ interface CurrencyInterface ...@@ -17,7 +17,7 @@ interface CurrencyInterface
* @param QUI\Locale|null $Locale * @param QUI\Locale|null $Locale
* @return string * @return string
*/ */
public static function getCurrencyTypeTitle(?QUI\Locale $Locale = null): string; public static function getCurrencyTypeTitle(null|QUI\Locale $Locale = null): string;
/** /**
* Get internal identifier of the currency type. * Get internal identifier of the currency type.
...@@ -39,7 +39,7 @@ public static function getExtraSettingsFormHtml(): ?string; ...@@ -39,7 +39,7 @@ public static function getExtraSettingsFormHtml(): ?string;
* @param array $data * @param array $data
* @param QUI\Locale|null $Locale - Locale for the currency * @param QUI\Locale|null $Locale - Locale for the currency
*/ */
public function __construct(array $data, ?QUI\Locale $Locale = null); public function __construct(array $data, null|QUI\Locale $Locale = null);
/** /**
* Set the locale for the currency * Set the locale for the currency
...@@ -89,7 +89,7 @@ public function toArray(): array; ...@@ -89,7 +89,7 @@ public function toArray(): array;
* @param null|QUI\Locale $Locale -optional * @param null|QUI\Locale $Locale -optional
* @return float * @return float
*/ */
public function amount($amount, QUI\Locale $Locale = null): float; public function amount($amount, null|QUI\Locale $Locale = null): float;
/** /**
* Format an amount * Format an amount
...@@ -98,7 +98,7 @@ public function amount($amount, QUI\Locale $Locale = null): float; ...@@ -98,7 +98,7 @@ public function amount($amount, QUI\Locale $Locale = null): float;
* @param null|QUI\Locale $Locale - optional, locale object * @param null|QUI\Locale $Locale - optional, locale object
* @return string * @return string
*/ */
public function format($amount, QUI\Locale $Locale = null): string; public function format($amount, null|QUI\Locale $Locale = null): string;
/** /**
* updates the currency itself? * updates the currency itself?
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
use Exception; use Exception;
use QUI; use QUI;
use QUI\Interfaces\Users\User;
use QUI\Locale; use QUI\Locale;
use function class_exists; use function class_exists;
...@@ -224,7 +225,7 @@ public static function getDefaultCurrency(): ?Currency ...@@ -224,7 +225,7 @@ public static function getDefaultCurrency(): ?Currency
* @param null|QUI\Interfaces\Users\User $User - optional * @param null|QUI\Interfaces\Users\User $User - optional
* @return Currency|null * @return Currency|null
*/ */
public static function getUserCurrency(QUI\Interfaces\Users\User $User = null): ?Currency public static function getUserCurrency(null | QUI\Interfaces\Users\User $User = null): ?Currency
{ {
if ($User === null) { if ($User === null) {
$User = QUI::getUserBySession(); $User = QUI::getUserBySession();
...@@ -260,10 +261,10 @@ public static function getUserCurrency(QUI\Interfaces\Users\User $User = null): ...@@ -260,10 +261,10 @@ public static function getUserCurrency(QUI\Interfaces\Users\User $User = null):
/** /**
* Return the currency of the user by its country * Return the currency of the user by its country
* *
* @param null $User * @param User|null $User
* @return Currency|null * @return Currency|null
*/ */
public static function getUserCurrencyByCountry($User = null): ?Currency public static function getUserCurrencyByCountry(null | QUI\Interfaces\Users\User $User = null): ?Currency
{ {
if ($User === null) { if ($User === null) {
$User = QUI::getUserBySession(); $User = QUI::getUserBySession();
...@@ -366,7 +367,7 @@ public static function getData(): array ...@@ -366,7 +367,7 @@ public static function getData(): array
* @return Currency * @return Currency
* @throws QUI\Exception * @throws QUI\Exception
*/ */
public static function getCurrency(Currency|string|array $currency): Currency public static function getCurrency(Currency | string | array $currency): Currency
{ {
if ($currency instanceof Currency) { if ($currency instanceof Currency) {
return $currency; return $currency;
......
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